Renamed PacketWriter/Reader to BinaryWriter/Reader + optimization to serializing

This commit is contained in:
themode 2020-08-19 20:34:21 +02:00
parent 65db4a48b4
commit 571bb7a866
210 changed files with 865 additions and 788 deletions

View File

@ -1,6 +1,6 @@
package fr.themode.demo; package fr.themode.demo;
import fr.themode.demo.entity.ChickenCreature; import fr.themode.demo.blocks.StoneBlock;
import fr.themode.demo.generator.ChunkGeneratorDemo; import fr.themode.demo.generator.ChunkGeneratorDemo;
import fr.themode.demo.generator.NoiseTestGenerator; import fr.themode.demo.generator.NoiseTestGenerator;
import net.minestom.server.MinecraftServer; import net.minestom.server.MinecraftServer;
@ -8,6 +8,7 @@ import net.minestom.server.benchmark.BenchmarkManager;
import net.minestom.server.benchmark.ThreadResult; import net.minestom.server.benchmark.ThreadResult;
import net.minestom.server.chat.ChatColor; import net.minestom.server.chat.ChatColor;
import net.minestom.server.chat.ColoredText; import net.minestom.server.chat.ColoredText;
import net.minestom.server.data.Data;
import net.minestom.server.entity.*; import net.minestom.server.entity.*;
import net.minestom.server.entity.damage.DamageType; import net.minestom.server.entity.damage.DamageType;
import net.minestom.server.event.entity.EntityAttackEvent; import net.minestom.server.event.entity.EntityAttackEvent;
@ -20,6 +21,7 @@ import net.minestom.server.instance.Instance;
import net.minestom.server.instance.InstanceContainer; import net.minestom.server.instance.InstanceContainer;
import net.minestom.server.instance.WorldBorder; import net.minestom.server.instance.WorldBorder;
import net.minestom.server.instance.block.Block; import net.minestom.server.instance.block.Block;
import net.minestom.server.instance.block.CustomBlock;
import net.minestom.server.inventory.Inventory; import net.minestom.server.inventory.Inventory;
import net.minestom.server.inventory.InventoryType; import net.minestom.server.inventory.InventoryType;
import net.minestom.server.item.ItemStack; import net.minestom.server.item.ItemStack;
@ -28,11 +30,13 @@ import net.minestom.server.item.metadata.MapMeta;
import net.minestom.server.network.ConnectionManager; import net.minestom.server.network.ConnectionManager;
import net.minestom.server.ping.ResponseDataConsumer; import net.minestom.server.ping.ResponseDataConsumer;
import net.minestom.server.scoreboard.Sidebar; import net.minestom.server.scoreboard.Sidebar;
import net.minestom.server.storage.StorageFolder;
import net.minestom.server.storage.StorageOptions;
import net.minestom.server.utils.BlockPosition;
import net.minestom.server.utils.MathUtils; import net.minestom.server.utils.MathUtils;
import net.minestom.server.utils.Position; import net.minestom.server.utils.Position;
import net.minestom.server.utils.Vector; import net.minestom.server.utils.Vector;
import net.minestom.server.utils.time.TimeUnit; import net.minestom.server.utils.time.TimeUnit;
import net.minestom.server.world.DimensionType;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
@ -44,11 +48,11 @@ public class PlayerInit {
private static volatile Inventory inventory; private static volatile Inventory inventory;
static { static {
//StorageFolder storageFolder = MinecraftServer.getStorageManager().getFolder("instance_data", new StorageOption().setCompression(true)); StorageFolder storageFolder = MinecraftServer.getStorageManager().getFolder("instance_data", new StorageOptions().setCompression(true));
ChunkGeneratorDemo chunkGeneratorDemo = new ChunkGeneratorDemo(); ChunkGeneratorDemo chunkGeneratorDemo = new ChunkGeneratorDemo();
NoiseTestGenerator noiseTestGenerator = new NoiseTestGenerator(); NoiseTestGenerator noiseTestGenerator = new NoiseTestGenerator();
//instanceContainer = MinecraftServer.getInstanceManager().createInstanceContainer(storageFolder); instanceContainer = MinecraftServer.getInstanceManager().createInstanceContainer(storageFolder);
instanceContainer = MinecraftServer.getInstanceManager().createInstanceContainer(DimensionType.OVERWORLD); //instanceContainer = MinecraftServer.getInstanceManager().createInstanceContainer(DimensionType.OVERWORLD);
instanceContainer.enableAutoChunkLoad(true); instanceContainer.enableAutoChunkLoad(true);
//instanceContainer.setChunkDecider((x,y) -> (pos) -> pos.getY()>40?(short)0:(short)1); //instanceContainer.setChunkDecider((x,y) -> (pos) -> pos.getY()>40?(short)0:(short)1);
instanceContainer.setChunkGenerator(noiseTestGenerator); instanceContainer.setChunkGenerator(noiseTestGenerator);
@ -153,10 +157,10 @@ public class PlayerInit {
p.teleport(player.getPosition()); p.teleport(player.getPosition());
}*/ }*/
for (int i = 0; i < 100; i++) { /*for (int i = 0; i < 100; i++) {
ChickenCreature chickenCreature = new ChickenCreature(player.getPosition()); ChickenCreature chickenCreature = new ChickenCreature(player.getPosition());
chickenCreature.setInstance(player.getInstance()); chickenCreature.setInstance(player.getInstance());
} }*/
/*EntityZombie zombie = new EntityZombie(player.getPosition()); /*EntityZombie zombie = new EntityZombie(player.getPosition());
zombie.setAttribute(Attribute.MOVEMENT_SPEED, 0.25f); zombie.setAttribute(Attribute.MOVEMENT_SPEED, 0.25f);
@ -183,6 +187,17 @@ public class PlayerInit {
if (event.getHand() != Player.Hand.MAIN) if (event.getHand() != Player.Hand.MAIN)
return; return;
final Instance instance = player.getInstance();
final BlockPosition blockPosition = event.getBlockPosition();
final CustomBlock customBlock = instance.getCustomBlock(blockPosition);
if (customBlock instanceof StoneBlock) {
final Data data = instance.getBlockData(blockPosition);
if (data != null) {
player.sendMessage("test: " + data.get("test"));
}
}
final short blockStateId = player.getInstance().getBlockStateId(event.getBlockPosition()); final short blockStateId = player.getInstance().getBlockStateId(event.getBlockPosition());
final Block block = Block.fromStateId(blockStateId); final Block block = Block.fromStateId(blockStateId);
player.sendMessage("You clicked at the block " + block); player.sendMessage("You clicked at the block " + block);

View File

@ -67,6 +67,8 @@ public class SimpleCommand implements CommandProcessor {
NotificationCenter.send(notification, player); NotificationCenter.send(notification, player);
NotificationCenter.send(notification, player); NotificationCenter.send(notification, player);
player.getInstance().saveChunksToStorageFolder(() -> System.out.println("end save"));
return true; return true;
} }

View File

@ -3,12 +3,12 @@ package fr.themode.demo.generator;
import de.articdive.jnoise.JNoise; import de.articdive.jnoise.JNoise;
import de.articdive.jnoise.interpolation.InterpolationType; import de.articdive.jnoise.interpolation.InterpolationType;
import net.minestom.server.MinecraftServer; import net.minestom.server.MinecraftServer;
import net.minestom.server.world.biomes.Biome;
import net.minestom.server.instance.Chunk; import net.minestom.server.instance.Chunk;
import net.minestom.server.instance.ChunkGenerator; import net.minestom.server.instance.ChunkGenerator;
import net.minestom.server.instance.ChunkPopulator; import net.minestom.server.instance.ChunkPopulator;
import net.minestom.server.instance.batch.ChunkBatch; import net.minestom.server.instance.batch.ChunkBatch;
import net.minestom.server.instance.block.Block; import net.minestom.server.instance.block.Block;
import net.minestom.server.world.biomes.Biome;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@ -28,7 +28,7 @@ public class NoiseTestGenerator extends ChunkGenerator {
if (random.nextInt(100) > 10) { if (random.nextInt(100) > 10) {
batch.setBlock(x, y, z, Block.DIAMOND_BLOCK); batch.setBlock(x, y, z, Block.DIAMOND_BLOCK);
} else { } else {
batch.setBlock(x, y, z, Block.GOLD_BLOCK); batch.setCustomBlock(x, y, z, "custom_block");
} }
} }
} }

View File

@ -79,7 +79,8 @@ public final class DataManager {
* @throws NullPointerException if none is found * @throws NullPointerException if none is found
*/ */
public <T> DataType<T> getDataType(Class<T> clazz) { public <T> DataType<T> getDataType(Class<T> clazz) {
return dataTypeMap.get(PrimitiveConversion.getObjectClass(clazz)); clazz = PrimitiveConversion.getObjectClass(clazz);
return dataTypeMap.get(clazz);
} }
} }

View File

@ -1,24 +1,24 @@
package net.minestom.server.data; package net.minestom.server.data;
import net.minestom.server.network.packet.PacketReader; import net.minestom.server.utils.binary.BinaryReader;
import net.minestom.server.network.packet.PacketWriter; import net.minestom.server.utils.binary.BinaryWriter;
public abstract class DataType<T> { public abstract class DataType<T> {
/** /**
* Encode the data type * Encode the data type
* *
* @param packetWriter the data writer * @param writer the data writer
* @param value the value to encode * @param value the value to encode
*/ */
public abstract void encode(PacketWriter packetWriter, T value); public abstract void encode(BinaryWriter writer, T value);
/** /**
* Decode the data type * Decode the data type
* *
* @param packetReader the data reader * @param reader the data reader
* @return the decoded value * @return the decoded value
*/ */
public abstract T decode(PacketReader packetReader); public abstract T decode(BinaryReader reader);
} }

View File

@ -1,13 +1,9 @@
package net.minestom.server.data; package net.minestom.server.data;
import net.minestom.server.MinecraftServer; import net.minestom.server.MinecraftServer;
import net.minestom.server.network.packet.PacketWriter;
import net.minestom.server.utils.PrimitiveConversion; import net.minestom.server.utils.PrimitiveConversion;
import net.minestom.server.utils.binary.BinaryWriter;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
public class SerializableData extends Data { public class SerializableData extends Data {
@ -52,36 +48,28 @@ public class SerializableData extends Data {
* to convert it back * to convert it back
* *
* @return the array representation of this data object * @return the array representation of this data object
* @throws IOException if an error occur when serializing the data
*/ */
public byte[] getSerializedData() throws IOException { public byte[] getSerializedData() {
ByteArrayOutputStream output = new ByteArrayOutputStream(); BinaryWriter binaryWriter = new BinaryWriter();
DataOutputStream dos = new DataOutputStream(output);
for (Map.Entry<String, Object> entry : data.entrySet()) { data.forEach((key, value) -> {
final String key = entry.getKey();
final Class type = dataType.get(key); final Class type = dataType.get(key);
final Object value = entry.getValue();
final DataType dataType = DATA_MANAGER.getDataType(type); final DataType dataType = DATA_MANAGER.getDataType(type);
final byte[] encodedType = PrimitiveConversion.getObjectClassString(type.getName()).getBytes(); // Data type (fix for primitives) // Write the data type
dos.writeShort(encodedType.length); final String encodedType = PrimitiveConversion.getObjectClassString(type.getName()); // Data type (fix for primitives)
dos.write(encodedType); binaryWriter.writeSizedString(encodedType);
final byte[] encodedName = key.getBytes(); // Data name // Write the data key
dos.writeShort(encodedName.length); binaryWriter.writeSizedString(key);
dos.write(encodedName);
PacketWriter packetWriter = new PacketWriter(); // Write the data (no length)
dataType.encode(packetWriter, value); // Encode dataType.encode(binaryWriter, value);
final byte[] encodedValue = packetWriter.toByteArray(); // Retrieve bytes });
dos.writeInt(encodedValue.length);
dos.write(encodedValue);
}
dos.writeShort(0xff); // End of data object binaryWriter.writeVarInt(0); // End of data object
return output.toByteArray(); return binaryWriter.toByteArray();
} }
} }

View File

@ -1,17 +1,17 @@
package net.minestom.server.data.type; package net.minestom.server.data.type;
import net.minestom.server.data.DataType; import net.minestom.server.data.DataType;
import net.minestom.server.network.packet.PacketReader; import net.minestom.server.utils.binary.BinaryReader;
import net.minestom.server.network.packet.PacketWriter; import net.minestom.server.utils.binary.BinaryWriter;
public class BooleanData extends DataType<Boolean> { public class BooleanData extends DataType<Boolean> {
@Override @Override
public void encode(PacketWriter packetWriter, Boolean value) { public void encode(BinaryWriter binaryWriter, Boolean value) {
packetWriter.writeBoolean(value); binaryWriter.writeBoolean(value);
} }
@Override @Override
public Boolean decode(PacketReader packetReader) { public Boolean decode(BinaryReader binaryReader) {
return packetReader.readBoolean(); return binaryReader.readBoolean();
} }
} }

View File

@ -1,17 +1,17 @@
package net.minestom.server.data.type; package net.minestom.server.data.type;
import net.minestom.server.data.DataType; import net.minestom.server.data.DataType;
import net.minestom.server.network.packet.PacketReader; import net.minestom.server.utils.binary.BinaryReader;
import net.minestom.server.network.packet.PacketWriter; import net.minestom.server.utils.binary.BinaryWriter;
public class ByteData extends DataType<Byte> { public class ByteData extends DataType<Byte> {
@Override @Override
public void encode(PacketWriter packetWriter, Byte value) { public void encode(BinaryWriter binaryWriter, Byte value) {
packetWriter.writeByte(value); binaryWriter.writeByte(value);
} }
@Override @Override
public Byte decode(PacketReader packetReader) { public Byte decode(BinaryReader binaryReader) {
return packetReader.readByte(); return binaryReader.readByte();
} }
} }

View File

@ -1,18 +1,18 @@
package net.minestom.server.data.type; package net.minestom.server.data.type;
import net.minestom.server.data.DataType; import net.minestom.server.data.DataType;
import net.minestom.server.network.packet.PacketReader; import net.minestom.server.utils.binary.BinaryReader;
import net.minestom.server.network.packet.PacketWriter; import net.minestom.server.utils.binary.BinaryWriter;
public class CharacterData extends DataType<Character> { public class CharacterData extends DataType<Character> {
@Override @Override
public void encode(PacketWriter packetWriter, Character value) { public void encode(BinaryWriter binaryWriter, Character value) {
packetWriter.writeChar(value); binaryWriter.writeChar(value);
} }
@Override @Override
public Character decode(PacketReader packetReader) { public Character decode(BinaryReader binaryReader) {
return packetReader.readChar(); return binaryReader.readChar();
} }
} }

View File

@ -1,18 +1,18 @@
package net.minestom.server.data.type; package net.minestom.server.data.type;
import net.minestom.server.data.DataType; import net.minestom.server.data.DataType;
import net.minestom.server.network.packet.PacketReader; import net.minestom.server.utils.binary.BinaryReader;
import net.minestom.server.network.packet.PacketWriter; import net.minestom.server.utils.binary.BinaryWriter;
public class DoubleData extends DataType<Double> { public class DoubleData extends DataType<Double> {
@Override @Override
public void encode(PacketWriter packetWriter, Double value) { public void encode(BinaryWriter binaryWriter, Double value) {
packetWriter.writeDouble(value); binaryWriter.writeDouble(value);
} }
@Override @Override
public Double decode(PacketReader packetReader) { public Double decode(BinaryReader binaryReader) {
return packetReader.readDouble(); return binaryReader.readDouble();
} }
} }

View File

@ -1,18 +1,18 @@
package net.minestom.server.data.type; package net.minestom.server.data.type;
import net.minestom.server.data.DataType; import net.minestom.server.data.DataType;
import net.minestom.server.network.packet.PacketReader; import net.minestom.server.utils.binary.BinaryReader;
import net.minestom.server.network.packet.PacketWriter; import net.minestom.server.utils.binary.BinaryWriter;
public class FloatData extends DataType<Float> { public class FloatData extends DataType<Float> {
@Override @Override
public void encode(PacketWriter packetWriter, Float value) { public void encode(BinaryWriter binaryWriter, Float value) {
packetWriter.writeFloat(value); binaryWriter.writeFloat(value);
} }
@Override @Override
public Float decode(PacketReader packetReader) { public Float decode(BinaryReader binaryReader) {
return packetReader.readFloat(); return binaryReader.readFloat();
} }
} }

View File

@ -1,18 +1,18 @@
package net.minestom.server.data.type; package net.minestom.server.data.type;
import net.minestom.server.data.DataType; import net.minestom.server.data.DataType;
import net.minestom.server.network.packet.PacketReader; import net.minestom.server.utils.binary.BinaryReader;
import net.minestom.server.network.packet.PacketWriter; import net.minestom.server.utils.binary.BinaryWriter;
public class IntegerData extends DataType<Integer> { public class IntegerData extends DataType<Integer> {
@Override @Override
public void encode(PacketWriter packetWriter, Integer value) { public void encode(BinaryWriter binaryWriter, Integer value) {
packetWriter.writeVarInt(value); binaryWriter.writeVarInt(value);
} }
@Override @Override
public Integer decode(PacketReader packetReader) { public Integer decode(BinaryReader binaryReader) {
return packetReader.readVarInt(); return binaryReader.readVarInt();
} }
} }

View File

@ -3,37 +3,37 @@ package net.minestom.server.data.type;
import net.minestom.server.data.DataType; import net.minestom.server.data.DataType;
import net.minestom.server.inventory.Inventory; import net.minestom.server.inventory.Inventory;
import net.minestom.server.inventory.InventoryType; import net.minestom.server.inventory.InventoryType;
import net.minestom.server.network.packet.PacketReader; import net.minestom.server.utils.binary.BinaryReader;
import net.minestom.server.network.packet.PacketWriter; import net.minestom.server.utils.binary.BinaryWriter;
public class InventoryData extends DataType<Inventory> { public class InventoryData extends DataType<Inventory> {
@Override @Override
public void encode(PacketWriter packetWriter, Inventory value) { public void encode(BinaryWriter binaryWriter, Inventory value) {
final InventoryType inventoryType = value.getInventoryType(); final InventoryType inventoryType = value.getInventoryType();
final int size = inventoryType.getAdditionalSlot(); final int size = inventoryType.getAdditionalSlot();
// Inventory title & type // Inventory title & type
packetWriter.writeSizedString(value.getTitle()); binaryWriter.writeSizedString(value.getTitle());
packetWriter.writeSizedString(inventoryType.name()); binaryWriter.writeSizedString(inventoryType.name());
// Write all item stacks // Write all item stacks
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
packetWriter.writeItemStack(value.getItemStack(i)); binaryWriter.writeItemStack(value.getItemStack(i));
} }
} }
@Override @Override
public Inventory decode(PacketReader packetReader) { public Inventory decode(BinaryReader binaryReader) {
final String title = packetReader.readSizedString(); final String title = binaryReader.readSizedString();
final InventoryType inventoryType = InventoryType.valueOf(packetReader.readSizedString()); final InventoryType inventoryType = InventoryType.valueOf(binaryReader.readSizedString());
final int size = inventoryType.getAdditionalSlot(); final int size = inventoryType.getAdditionalSlot();
Inventory inventory = new Inventory(inventoryType, title); Inventory inventory = new Inventory(inventoryType, title);
// Read all item stacks // Read all item stacks
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
inventory.setItemStack(i, packetReader.readSlot()); inventory.setItemStack(i, binaryReader.readSlot());
} }
return inventory; return inventory;

View File

@ -2,17 +2,17 @@ package net.minestom.server.data.type;
import net.minestom.server.data.DataType; import net.minestom.server.data.DataType;
import net.minestom.server.item.ItemStack; import net.minestom.server.item.ItemStack;
import net.minestom.server.network.packet.PacketReader; import net.minestom.server.utils.binary.BinaryReader;
import net.minestom.server.network.packet.PacketWriter; import net.minestom.server.utils.binary.BinaryWriter;
public class ItemStackData extends DataType<ItemStack> { public class ItemStackData extends DataType<ItemStack> {
@Override @Override
public void encode(PacketWriter packetWriter, ItemStack value) { public void encode(BinaryWriter binaryWriter, ItemStack value) {
packetWriter.writeItemStack(value); binaryWriter.writeItemStack(value);
} }
@Override @Override
public ItemStack decode(PacketReader packetReader) { public ItemStack decode(BinaryReader binaryReader) {
return packetReader.readSlot(); return binaryReader.readSlot();
} }
} }

View File

@ -1,17 +1,17 @@
package net.minestom.server.data.type; package net.minestom.server.data.type;
import net.minestom.server.data.DataType; import net.minestom.server.data.DataType;
import net.minestom.server.network.packet.PacketReader; import net.minestom.server.utils.binary.BinaryReader;
import net.minestom.server.network.packet.PacketWriter; import net.minestom.server.utils.binary.BinaryWriter;
public class LongData extends DataType<Long> { public class LongData extends DataType<Long> {
@Override @Override
public void encode(PacketWriter packetWriter, Long value) { public void encode(BinaryWriter binaryWriter, Long value) {
packetWriter.writeLong(value); binaryWriter.writeLong(value);
} }
@Override @Override
public Long decode(PacketReader packetReader) { public Long decode(BinaryReader binaryReader) {
return packetReader.readLong(); return binaryReader.readLong();
} }
} }

View File

@ -2,27 +2,20 @@ package net.minestom.server.data.type;
import net.minestom.server.data.DataType; import net.minestom.server.data.DataType;
import net.minestom.server.data.SerializableData; import net.minestom.server.data.SerializableData;
import net.minestom.server.network.packet.PacketReader;
import net.minestom.server.network.packet.PacketWriter;
import net.minestom.server.reader.DataReader; import net.minestom.server.reader.DataReader;
import net.minestom.server.utils.binary.BinaryReader;
import java.io.IOException; import net.minestom.server.utils.binary.BinaryWriter;
// Pretty weird name huh? // Pretty weird name huh?
public class SerializableDataData extends DataType<SerializableData> { public class SerializableDataData extends DataType<SerializableData> {
@Override @Override
public void encode(PacketWriter packetWriter, SerializableData value) { public void encode(BinaryWriter binaryWriter, SerializableData value) {
try { binaryWriter.writeBytes(value.getSerializedData());
packetWriter.writeBytes(value.getSerializedData());
} catch (IOException e) {
e.printStackTrace();
throw new IllegalArgumentException("error while writing the data");
}
} }
@Override @Override
public SerializableData decode(PacketReader packetReader) { public SerializableData decode(BinaryReader binaryReader) {
return DataReader.readData(packetReader.getBuffer()); return DataReader.readData(binaryReader);
} }
} }

View File

@ -1,18 +1,18 @@
package net.minestom.server.data.type; package net.minestom.server.data.type;
import net.minestom.server.data.DataType; import net.minestom.server.data.DataType;
import net.minestom.server.network.packet.PacketReader; import net.minestom.server.utils.binary.BinaryReader;
import net.minestom.server.network.packet.PacketWriter; import net.minestom.server.utils.binary.BinaryWriter;
public class ShortData extends DataType<Short> { public class ShortData extends DataType<Short> {
@Override @Override
public void encode(PacketWriter packetWriter, Short value) { public void encode(BinaryWriter binaryWriter, Short value) {
packetWriter.writeShort(value); binaryWriter.writeShort(value);
} }
@Override @Override
public Short decode(PacketReader packetReader) { public Short decode(BinaryReader binaryReader) {
return packetReader.readShort(); return binaryReader.readShort();
} }
} }

View File

@ -1,18 +1,18 @@
package net.minestom.server.data.type; package net.minestom.server.data.type;
import net.minestom.server.data.DataType; import net.minestom.server.data.DataType;
import net.minestom.server.network.packet.PacketReader; import net.minestom.server.utils.binary.BinaryReader;
import net.minestom.server.network.packet.PacketWriter; import net.minestom.server.utils.binary.BinaryWriter;
public class StringData extends DataType<String> { public class StringData extends DataType<String> {
@Override @Override
public void encode(PacketWriter packetWriter, String value) { public void encode(BinaryWriter binaryWriter, String value) {
packetWriter.writeSizedString(value); binaryWriter.writeSizedString(value);
} }
@Override @Override
public String decode(PacketReader packetReader) { public String decode(BinaryReader binaryReader) {
return packetReader.readSizedString(); return binaryReader.readSizedString();
} }
} }

View File

@ -1,19 +1,19 @@
package net.minestom.server.data.type; package net.minestom.server.data.type;
import net.minestom.server.data.DataType; import net.minestom.server.data.DataType;
import net.minestom.server.network.packet.PacketReader; import net.minestom.server.utils.binary.BinaryReader;
import net.minestom.server.network.packet.PacketWriter; import net.minestom.server.utils.binary.BinaryWriter;
import java.util.UUID; import java.util.UUID;
public class UuidType extends DataType<UUID> { public class UuidType extends DataType<UUID> {
@Override @Override
public void encode(PacketWriter packetWriter, UUID value) { public void encode(BinaryWriter binaryWriter, UUID value) {
packetWriter.writeUuid(value); binaryWriter.writeUuid(value);
} }
@Override @Override
public UUID decode(PacketReader packetReader) { public UUID decode(BinaryReader binaryReader) {
return packetReader.readUuid(); return binaryReader.readUuid();
} }
} }

View File

@ -1,24 +1,24 @@
package net.minestom.server.data.type.array; package net.minestom.server.data.type.array;
import net.minestom.server.data.DataType; import net.minestom.server.data.DataType;
import net.minestom.server.network.packet.PacketReader; import net.minestom.server.utils.binary.BinaryReader;
import net.minestom.server.network.packet.PacketWriter; import net.minestom.server.utils.binary.BinaryWriter;
public class BooleanArrayData extends DataType<boolean[]> { public class BooleanArrayData extends DataType<boolean[]> {
@Override @Override
public void encode(PacketWriter packetWriter, boolean[] value) { public void encode(BinaryWriter binaryWriter, boolean[] value) {
packetWriter.writeVarInt(value.length); binaryWriter.writeVarInt(value.length);
for (boolean val : value) { for (boolean val : value) {
packetWriter.writeBoolean(val); binaryWriter.writeBoolean(val);
} }
} }
@Override @Override
public boolean[] decode(PacketReader packetReader) { public boolean[] decode(BinaryReader binaryReader) {
boolean[] array = new boolean[packetReader.readVarInt()]; boolean[] array = new boolean[binaryReader.readVarInt()];
for (int i = 0; i < array.length; i++) { for (int i = 0; i < array.length; i++) {
array[i] = packetReader.readBoolean(); array[i] = binaryReader.readBoolean();
} }
return array; return array;
} }

View File

@ -1,31 +1,31 @@
package net.minestom.server.data.type.array; package net.minestom.server.data.type.array;
import net.minestom.server.data.DataType; import net.minestom.server.data.DataType;
import net.minestom.server.network.packet.PacketReader; import net.minestom.server.utils.binary.BinaryReader;
import net.minestom.server.network.packet.PacketWriter; import net.minestom.server.utils.binary.BinaryWriter;
public class ByteArrayData extends DataType<byte[]> { public class ByteArrayData extends DataType<byte[]> {
@Override @Override
public void encode(PacketWriter packetWriter, byte[] value) { public void encode(BinaryWriter binaryWriter, byte[] value) {
encodeByteArray(packetWriter, value); encodeByteArray(binaryWriter, value);
} }
@Override @Override
public byte[] decode(PacketReader packetReader) { public byte[] decode(BinaryReader binaryReader) {
return decodeByteArray(packetReader); return decodeByteArray(binaryReader);
} }
public static void encodeByteArray(PacketWriter packetWriter, byte[] value) { public static void encodeByteArray(BinaryWriter binaryWriter, byte[] value) {
packetWriter.writeVarInt(value.length); binaryWriter.writeVarInt(value.length);
for (byte val : value) { for (byte val : value) {
packetWriter.writeByte(val); binaryWriter.writeByte(val);
} }
} }
public static byte[] decodeByteArray(PacketReader packetReader) { public static byte[] decodeByteArray(BinaryReader binaryReader) {
byte[] array = new byte[packetReader.readVarInt()]; byte[] array = new byte[binaryReader.readVarInt()];
for (int i = 0; i < array.length; i++) { for (int i = 0; i < array.length; i++) {
array[i] = packetReader.readByte(); array[i] = binaryReader.readByte();
} }
return array; return array;
} }

View File

@ -1,23 +1,23 @@
package net.minestom.server.data.type.array; package net.minestom.server.data.type.array;
import net.minestom.server.data.DataType; import net.minestom.server.data.DataType;
import net.minestom.server.network.packet.PacketReader; import net.minestom.server.utils.binary.BinaryReader;
import net.minestom.server.network.packet.PacketWriter; import net.minestom.server.utils.binary.BinaryWriter;
public class CharacterArrayData extends DataType<char[]> { public class CharacterArrayData extends DataType<char[]> {
@Override @Override
public void encode(PacketWriter packetWriter, char[] value) { public void encode(BinaryWriter binaryWriter, char[] value) {
packetWriter.writeVarInt(value.length); binaryWriter.writeVarInt(value.length);
for (char val : value) { for (char val : value) {
packetWriter.writeChar(val); binaryWriter.writeChar(val);
} }
} }
@Override @Override
public char[] decode(PacketReader packetReader) { public char[] decode(BinaryReader binaryReader) {
char[] array = new char[packetReader.readVarInt()]; char[] array = new char[binaryReader.readVarInt()];
for (int i = 0; i < array.length; i++) { for (int i = 0; i < array.length; i++) {
array[i] = packetReader.readChar(); array[i] = binaryReader.readChar();
} }
return array; return array;
} }

View File

@ -1,24 +1,24 @@
package net.minestom.server.data.type.array; package net.minestom.server.data.type.array;
import net.minestom.server.data.DataType; import net.minestom.server.data.DataType;
import net.minestom.server.network.packet.PacketReader; import net.minestom.server.utils.binary.BinaryReader;
import net.minestom.server.network.packet.PacketWriter; import net.minestom.server.utils.binary.BinaryWriter;
public class DoubleArrayData extends DataType<double[]> { public class DoubleArrayData extends DataType<double[]> {
@Override @Override
public void encode(PacketWriter packetWriter, double[] value) { public void encode(BinaryWriter binaryWriter, double[] value) {
packetWriter.writeVarInt(value.length); binaryWriter.writeVarInt(value.length);
for (double val : value) { for (double val : value) {
packetWriter.writeDouble(val); binaryWriter.writeDouble(val);
} }
} }
@Override @Override
public double[] decode(PacketReader packetReader) { public double[] decode(BinaryReader binaryReader) {
double[] array = new double[packetReader.readVarInt()]; double[] array = new double[binaryReader.readVarInt()];
for (int i = 0; i < array.length; i++) { for (int i = 0; i < array.length; i++) {
array[i] = packetReader.readDouble(); array[i] = binaryReader.readDouble();
} }
return array; return array;
} }

View File

@ -1,24 +1,24 @@
package net.minestom.server.data.type.array; package net.minestom.server.data.type.array;
import net.minestom.server.data.DataType; import net.minestom.server.data.DataType;
import net.minestom.server.network.packet.PacketReader; import net.minestom.server.utils.binary.BinaryReader;
import net.minestom.server.network.packet.PacketWriter; import net.minestom.server.utils.binary.BinaryWriter;
public class FloatArrayData extends DataType<float[]> { public class FloatArrayData extends DataType<float[]> {
@Override @Override
public void encode(PacketWriter packetWriter, float[] value) { public void encode(BinaryWriter binaryWriter, float[] value) {
packetWriter.writeVarInt(value.length); binaryWriter.writeVarInt(value.length);
for (float val : value) { for (float val : value) {
packetWriter.writeFloat(val); binaryWriter.writeFloat(val);
} }
} }
@Override @Override
public float[] decode(PacketReader packetReader) { public float[] decode(BinaryReader binaryReader) {
float[] array = new float[packetReader.readVarInt()]; float[] array = new float[binaryReader.readVarInt()];
for (int i = 0; i < array.length; i++) { for (int i = 0; i < array.length; i++) {
array[i] = packetReader.readFloat(); array[i] = binaryReader.readFloat();
} }
return array; return array;
} }

View File

@ -1,24 +1,24 @@
package net.minestom.server.data.type.array; package net.minestom.server.data.type.array;
import net.minestom.server.data.DataType; import net.minestom.server.data.DataType;
import net.minestom.server.network.packet.PacketReader; import net.minestom.server.utils.binary.BinaryReader;
import net.minestom.server.network.packet.PacketWriter; import net.minestom.server.utils.binary.BinaryWriter;
public class IntegerArrayData extends DataType<int[]> { public class IntegerArrayData extends DataType<int[]> {
@Override @Override
public void encode(PacketWriter packetWriter, int[] value) { public void encode(BinaryWriter binaryWriter, int[] value) {
packetWriter.writeVarInt(value.length); binaryWriter.writeVarInt(value.length);
for (int val : value) { for (int val : value) {
packetWriter.writeInt(val); binaryWriter.writeInt(val);
} }
} }
@Override @Override
public int[] decode(PacketReader packetReader) { public int[] decode(BinaryReader binaryReader) {
int[] array = new int[packetReader.readVarInt()]; int[] array = new int[binaryReader.readVarInt()];
for (int i = 0; i < array.length; i++) { for (int i = 0; i < array.length; i++) {
array[i] = packetReader.readInteger(); array[i] = binaryReader.readInteger();
} }
return array; return array;
} }

View File

@ -2,23 +2,23 @@ package net.minestom.server.data.type.array;
import net.minestom.server.data.DataType; import net.minestom.server.data.DataType;
import net.minestom.server.item.ItemStack; import net.minestom.server.item.ItemStack;
import net.minestom.server.network.packet.PacketReader; import net.minestom.server.utils.binary.BinaryReader;
import net.minestom.server.network.packet.PacketWriter; import net.minestom.server.utils.binary.BinaryWriter;
public class ItemStackArrayData extends DataType<ItemStack[]> { public class ItemStackArrayData extends DataType<ItemStack[]> {
@Override @Override
public void encode(PacketWriter packetWriter, ItemStack[] value) { public void encode(BinaryWriter binaryWriter, ItemStack[] value) {
packetWriter.writeVarInt(value.length); binaryWriter.writeVarInt(value.length);
for (ItemStack itemStack : value) { for (ItemStack itemStack : value) {
packetWriter.writeItemStack(itemStack); binaryWriter.writeItemStack(itemStack);
} }
} }
@Override @Override
public ItemStack[] decode(PacketReader packetReader) { public ItemStack[] decode(BinaryReader binaryReader) {
ItemStack[] items = new ItemStack[packetReader.readVarInt()]; ItemStack[] items = new ItemStack[binaryReader.readVarInt()];
for (int i = 0; i < items.length; i++) { for (int i = 0; i < items.length; i++) {
items[i] = packetReader.readSlot(); items[i] = binaryReader.readSlot();
} }
return items; return items;
} }

View File

@ -1,24 +1,24 @@
package net.minestom.server.data.type.array; package net.minestom.server.data.type.array;
import net.minestom.server.data.DataType; import net.minestom.server.data.DataType;
import net.minestom.server.network.packet.PacketReader; import net.minestom.server.utils.binary.BinaryReader;
import net.minestom.server.network.packet.PacketWriter; import net.minestom.server.utils.binary.BinaryWriter;
public class LongArrayData extends DataType<long[]> { public class LongArrayData extends DataType<long[]> {
@Override @Override
public void encode(PacketWriter packetWriter, long[] value) { public void encode(BinaryWriter binaryWriter, long[] value) {
packetWriter.writeVarInt(value.length); binaryWriter.writeVarInt(value.length);
for (long val : value) { for (long val : value) {
packetWriter.writeLong(val); binaryWriter.writeLong(val);
} }
} }
@Override @Override
public long[] decode(PacketReader packetReader) { public long[] decode(BinaryReader binaryReader) {
long[] array = new long[packetReader.readVarInt()]; long[] array = new long[binaryReader.readVarInt()];
for (int i = 0; i < array.length; i++) { for (int i = 0; i < array.length; i++) {
array[i] = packetReader.readLong(); array[i] = binaryReader.readLong();
} }
return array; return array;
} }

View File

@ -1,24 +1,24 @@
package net.minestom.server.data.type.array; package net.minestom.server.data.type.array;
import net.minestom.server.data.DataType; import net.minestom.server.data.DataType;
import net.minestom.server.network.packet.PacketReader; import net.minestom.server.utils.binary.BinaryReader;
import net.minestom.server.network.packet.PacketWriter; import net.minestom.server.utils.binary.BinaryWriter;
public class ShortArrayData extends DataType<short[]> { public class ShortArrayData extends DataType<short[]> {
@Override @Override
public void encode(PacketWriter packetWriter, short[] value) { public void encode(BinaryWriter binaryWriter, short[] value) {
packetWriter.writeVarInt(value.length); binaryWriter.writeVarInt(value.length);
for (short val : value) { for (short val : value) {
packetWriter.writeShort(val); binaryWriter.writeShort(val);
} }
} }
@Override @Override
public short[] decode(PacketReader packetReader) { public short[] decode(BinaryReader binaryReader) {
short[] array = new short[packetReader.readVarInt()]; short[] array = new short[binaryReader.readVarInt()];
for (int i = 0; i < array.length; i++) { for (int i = 0; i < array.length; i++) {
array[i] = packetReader.readShort(); array[i] = binaryReader.readShort();
} }
return array; return array;
} }

View File

@ -1,24 +1,24 @@
package net.minestom.server.data.type.array; package net.minestom.server.data.type.array;
import net.minestom.server.data.DataType; import net.minestom.server.data.DataType;
import net.minestom.server.network.packet.PacketReader; import net.minestom.server.utils.binary.BinaryReader;
import net.minestom.server.network.packet.PacketWriter; import net.minestom.server.utils.binary.BinaryWriter;
public class StringArrayData extends DataType<String[]> { public class StringArrayData extends DataType<String[]> {
@Override @Override
public void encode(PacketWriter packetWriter, String[] value) { public void encode(BinaryWriter binaryWriter, String[] value) {
packetWriter.writeVarInt(value.length); binaryWriter.writeVarInt(value.length);
for (String val : value) { for (String val : value) {
packetWriter.writeSizedString(val); binaryWriter.writeSizedString(val);
} }
} }
@Override @Override
public String[] decode(PacketReader packetReader) { public String[] decode(BinaryReader binaryReader) {
String[] array = new String[packetReader.readVarInt()]; String[] array = new String[binaryReader.readVarInt()];
for (int i = 0; i < array.length; i++) { for (int i = 0; i < array.length; i++) {
array[i] = packetReader.readSizedString(); array[i] = binaryReader.readSizedString();
} }
return array; return array;
} }

View File

@ -19,12 +19,12 @@ import net.minestom.server.instance.Instance;
import net.minestom.server.instance.InstanceManager; import net.minestom.server.instance.InstanceManager;
import net.minestom.server.instance.WorldBorder; import net.minestom.server.instance.WorldBorder;
import net.minestom.server.instance.block.CustomBlock; import net.minestom.server.instance.block.CustomBlock;
import net.minestom.server.network.packet.PacketWriter;
import net.minestom.server.network.packet.server.play.*; import net.minestom.server.network.packet.server.play.*;
import net.minestom.server.utils.ArrayUtils; import net.minestom.server.utils.ArrayUtils;
import net.minestom.server.utils.BlockPosition; import net.minestom.server.utils.BlockPosition;
import net.minestom.server.utils.Position; import net.minestom.server.utils.Position;
import net.minestom.server.utils.Vector; import net.minestom.server.utils.Vector;
import net.minestom.server.utils.binary.BinaryWriter;
import net.minestom.server.utils.chunk.ChunkUtils; import net.minestom.server.utils.chunk.ChunkUtils;
import net.minestom.server.utils.entity.EntityUtils; import net.minestom.server.utils.entity.EntityUtils;
import net.minestom.server.utils.player.PlayerUtils; import net.minestom.server.utils.player.PlayerUtils;
@ -1195,7 +1195,7 @@ public abstract class Entity implements Viewable, EventHandler, DataContainer {
* *
* @return The consumer used to write {@link EntityMetaDataPacket} in {@link #getMetadataPacket()} * @return The consumer used to write {@link EntityMetaDataPacket} in {@link #getMetadataPacket()}
*/ */
public Consumer<PacketWriter> getMetadataConsumer() { public Consumer<BinaryWriter> getMetadataConsumer() {
return packet -> { return packet -> {
fillMetadataIndex(packet, 0); fillMetadataIndex(packet, 0);
fillMetadataIndex(packet, 1); fillMetadataIndex(packet, 1);
@ -1209,7 +1209,7 @@ public abstract class Entity implements Viewable, EventHandler, DataContainer {
/** /**
* Send a {@link EntityMetaDataPacket} containing only the specified index * Send a {@link EntityMetaDataPacket} containing only the specified index
* The index is wrote using {@link #fillMetadataIndex(PacketWriter, int)} * The index is wrote using {@link #fillMetadataIndex(BinaryWriter, int)}
* *
* @param index the metadata index * @param index the metadata index
*/ */
@ -1229,7 +1229,7 @@ public abstract class Entity implements Viewable, EventHandler, DataContainer {
* @param packet the packet writer * @param packet the packet writer
* @param index the index to fill/write * @param index the index to fill/write
*/ */
protected void fillMetadataIndex(PacketWriter packet, int index) { protected void fillMetadataIndex(BinaryWriter packet, int index) {
switch (index) { switch (index) {
case 0: case 0:
fillStateMetadata(packet); fillStateMetadata(packet);
@ -1255,7 +1255,7 @@ public abstract class Entity implements Viewable, EventHandler, DataContainer {
} }
} }
private void fillStateMetadata(PacketWriter packet) { private void fillStateMetadata(BinaryWriter packet) {
packet.writeByte((byte) 0); packet.writeByte((byte) 0);
packet.writeByte(METADATA_BYTE); packet.writeByte(METADATA_BYTE);
byte index0 = 0; byte index0 = 0;
@ -1278,13 +1278,13 @@ public abstract class Entity implements Viewable, EventHandler, DataContainer {
packet.writeByte(index0); packet.writeByte(index0);
} }
private void fillAirTickMetaData(PacketWriter packet) { private void fillAirTickMetaData(BinaryWriter packet) {
packet.writeByte((byte) 1); packet.writeByte((byte) 1);
packet.writeByte(METADATA_VARINT); packet.writeByte(METADATA_VARINT);
packet.writeVarInt(air); packet.writeVarInt(air);
} }
private void fillCustomNameMetaData(PacketWriter packet) { private void fillCustomNameMetaData(BinaryWriter packet) {
boolean hasCustomName = customName != null; boolean hasCustomName = customName != null;
packet.writeByte((byte) 2); packet.writeByte((byte) 2);
@ -1295,25 +1295,25 @@ public abstract class Entity implements Viewable, EventHandler, DataContainer {
} }
} }
private void fillCustomNameVisibleMetaData(PacketWriter packet) { private void fillCustomNameVisibleMetaData(BinaryWriter packet) {
packet.writeByte((byte) 3); packet.writeByte((byte) 3);
packet.writeByte(METADATA_BOOLEAN); packet.writeByte(METADATA_BOOLEAN);
packet.writeBoolean(customNameVisible); packet.writeBoolean(customNameVisible);
} }
private void fillSilentMetaData(PacketWriter packet) { private void fillSilentMetaData(BinaryWriter packet) {
packet.writeByte((byte) 4); packet.writeByte((byte) 4);
packet.writeByte(METADATA_BOOLEAN); packet.writeByte(METADATA_BOOLEAN);
packet.writeBoolean(silent); packet.writeBoolean(silent);
} }
private void fillNoGravityMetaData(PacketWriter packet) { private void fillNoGravityMetaData(BinaryWriter packet) {
packet.writeByte((byte) 5); packet.writeByte((byte) 5);
packet.writeByte(METADATA_BOOLEAN); packet.writeByte(METADATA_BOOLEAN);
packet.writeBoolean(noGravity); packet.writeBoolean(noGravity);
} }
private void fillPoseMetaData(PacketWriter packet) { private void fillPoseMetaData(BinaryWriter packet) {
packet.writeByte((byte) 6); packet.writeByte((byte) 6);
packet.writeByte(METADATA_POSE); packet.writeByte(METADATA_POSE);
packet.writeVarInt(pose.ordinal()); packet.writeVarInt(pose.ordinal());

View File

@ -4,8 +4,8 @@ import net.minestom.server.event.entity.EntityItemMergeEvent;
import net.minestom.server.instance.Chunk; import net.minestom.server.instance.Chunk;
import net.minestom.server.item.ItemStack; import net.minestom.server.item.ItemStack;
import net.minestom.server.item.StackingRule; import net.minestom.server.item.StackingRule;
import net.minestom.server.network.packet.PacketWriter;
import net.minestom.server.utils.Position; import net.minestom.server.utils.Position;
import net.minestom.server.utils.binary.BinaryWriter;
import net.minestom.server.utils.time.CooldownUtils; import net.minestom.server.utils.time.CooldownUtils;
import net.minestom.server.utils.time.TimeUnit; import net.minestom.server.utils.time.TimeUnit;
import net.minestom.server.utils.time.UpdateOption; import net.minestom.server.utils.time.UpdateOption;
@ -118,7 +118,7 @@ public class ItemEntity extends ObjectEntity {
} }
@Override @Override
public Consumer<PacketWriter> getMetadataConsumer() { public Consumer<BinaryWriter> getMetadataConsumer() {
return packet -> { return packet -> {
super.getMetadataConsumer().accept(packet); super.getMetadataConsumer().accept(packet);
fillMetadataIndex(packet, 7); fillMetadataIndex(packet, 7);
@ -126,7 +126,7 @@ public class ItemEntity extends ObjectEntity {
} }
@Override @Override
protected void fillMetadataIndex(PacketWriter packet, int index) { protected void fillMetadataIndex(BinaryWriter packet, int index) {
super.fillMetadataIndex(packet, index); super.fillMetadataIndex(packet, index);
if (index == 7) { if (index == 7) {
packet.writeByte((byte) 7); packet.writeByte((byte) 7);

View File

@ -10,7 +10,6 @@ import net.minestom.server.event.item.PickupItemEvent;
import net.minestom.server.instance.Chunk; import net.minestom.server.instance.Chunk;
import net.minestom.server.inventory.EquipmentHandler; import net.minestom.server.inventory.EquipmentHandler;
import net.minestom.server.item.ItemStack; import net.minestom.server.item.ItemStack;
import net.minestom.server.network.packet.PacketWriter;
import net.minestom.server.network.packet.server.play.CollectItemPacket; import net.minestom.server.network.packet.server.play.CollectItemPacket;
import net.minestom.server.network.packet.server.play.EntityAnimationPacket; import net.minestom.server.network.packet.server.play.EntityAnimationPacket;
import net.minestom.server.network.packet.server.play.EntityPropertiesPacket; import net.minestom.server.network.packet.server.play.EntityPropertiesPacket;
@ -19,6 +18,7 @@ import net.minestom.server.scoreboard.Team;
import net.minestom.server.sound.Sound; import net.minestom.server.sound.Sound;
import net.minestom.server.sound.SoundCategory; import net.minestom.server.sound.SoundCategory;
import net.minestom.server.utils.Position; import net.minestom.server.utils.Position;
import net.minestom.server.utils.binary.BinaryWriter;
import net.minestom.server.utils.time.TimeUnit; import net.minestom.server.utils.time.TimeUnit;
import java.util.Set; import java.util.Set;
@ -119,7 +119,7 @@ public abstract class LivingEntity extends Entity implements EquipmentHandler {
} }
@Override @Override
public Consumer<PacketWriter> getMetadataConsumer() { public Consumer<BinaryWriter> getMetadataConsumer() {
return packet -> { return packet -> {
super.getMetadataConsumer().accept(packet); super.getMetadataConsumer().accept(packet);
fillMetadataIndex(packet, 7); fillMetadataIndex(packet, 7);
@ -129,7 +129,7 @@ public abstract class LivingEntity extends Entity implements EquipmentHandler {
} }
@Override @Override
protected void fillMetadataIndex(PacketWriter packet, int index) { protected void fillMetadataIndex(BinaryWriter packet, int index) {
super.fillMetadataIndex(packet, index); super.fillMetadataIndex(packet, index);
if (index == 7) { if (index == 7) {
packet.writeByte((byte) 7); packet.writeByte((byte) 7);

View File

@ -24,7 +24,6 @@ import net.minestom.server.inventory.Inventory;
import net.minestom.server.inventory.PlayerInventory; import net.minestom.server.inventory.PlayerInventory;
import net.minestom.server.item.ItemStack; import net.minestom.server.item.ItemStack;
import net.minestom.server.item.Material; import net.minestom.server.item.Material;
import net.minestom.server.network.packet.PacketWriter;
import net.minestom.server.network.packet.client.ClientPlayPacket; import net.minestom.server.network.packet.client.ClientPlayPacket;
import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacket;
import net.minestom.server.network.packet.server.login.JoinGamePacket; import net.minestom.server.network.packet.server.login.JoinGamePacket;
@ -43,6 +42,7 @@ import net.minestom.server.utils.ArrayUtils;
import net.minestom.server.utils.BlockPosition; import net.minestom.server.utils.BlockPosition;
import net.minestom.server.utils.MathUtils; import net.minestom.server.utils.MathUtils;
import net.minestom.server.utils.Position; import net.minestom.server.utils.Position;
import net.minestom.server.utils.binary.BinaryWriter;
import net.minestom.server.utils.chunk.ChunkUtils; import net.minestom.server.utils.chunk.ChunkUtils;
import net.minestom.server.utils.validate.Check; import net.minestom.server.utils.validate.Check;
import net.minestom.server.world.DimensionType; import net.minestom.server.world.DimensionType;
@ -579,7 +579,7 @@ public class Player extends LivingEntity implements CommandSender {
} }
@Override @Override
public Consumer<PacketWriter> getMetadataConsumer() { public Consumer<BinaryWriter> getMetadataConsumer() {
return packet -> { return packet -> {
super.getMetadataConsumer().accept(packet); super.getMetadataConsumer().accept(packet);
fillMetadataIndex(packet, 14); fillMetadataIndex(packet, 14);
@ -588,7 +588,7 @@ public class Player extends LivingEntity implements CommandSender {
} }
@Override @Override
protected void fillMetadataIndex(PacketWriter packet, int index) { protected void fillMetadataIndex(BinaryWriter packet, int index) {
super.fillMetadataIndex(packet, index); super.fillMetadataIndex(packet, index);
if (index == 14) { if (index == 14) {
packet.writeByte((byte) 14); packet.writeByte((byte) 14);
@ -622,7 +622,7 @@ public class Player extends LivingEntity implements CommandSender {
*/ */
public void sendPluginMessage(String channel, String message) { public void sendPluginMessage(String channel, String message) {
// Write the data // Write the data
PacketWriter writer = new PacketWriter(); BinaryWriter writer = new BinaryWriter();
writer.writeSizedString(message); writer.writeSizedString(message);
// Retrieve the data // Retrieve the data
final byte[] data = writer.toByteArray(); final byte[] data = writer.toByteArray();

View File

@ -3,8 +3,8 @@ package net.minestom.server.entity.type.ambient;
import net.minestom.server.entity.EntityCreature; import net.minestom.server.entity.EntityCreature;
import net.minestom.server.entity.EntityType; import net.minestom.server.entity.EntityType;
import net.minestom.server.entity.type.Animal; import net.minestom.server.entity.type.Animal;
import net.minestom.server.network.packet.PacketWriter;
import net.minestom.server.utils.Position; import net.minestom.server.utils.Position;
import net.minestom.server.utils.binary.BinaryWriter;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -18,7 +18,7 @@ public class EntityBat extends EntityCreature implements Animal {
} }
@Override @Override
public Consumer<PacketWriter> getMetadataConsumer() { public Consumer<BinaryWriter> getMetadataConsumer() {
return packet -> { return packet -> {
super.getMetadataConsumer().accept(packet); super.getMetadataConsumer().accept(packet);
fillMetadataIndex(packet, 15); fillMetadataIndex(packet, 15);
@ -26,7 +26,7 @@ public class EntityBat extends EntityCreature implements Animal {
} }
@Override @Override
protected void fillMetadataIndex(PacketWriter packet, int index) { protected void fillMetadataIndex(BinaryWriter packet, int index) {
super.fillMetadataIndex(packet, index); super.fillMetadataIndex(packet, index);
if (index == 15) { if (index == 15) {
packet.writeByte((byte) 15); packet.writeByte((byte) 15);

View File

@ -3,8 +3,8 @@ package net.minestom.server.entity.type.animal;
import net.minestom.server.entity.EntityCreature; import net.minestom.server.entity.EntityCreature;
import net.minestom.server.entity.EntityType; import net.minestom.server.entity.EntityType;
import net.minestom.server.entity.type.Animal; import net.minestom.server.entity.type.Animal;
import net.minestom.server.network.packet.PacketWriter;
import net.minestom.server.utils.Position; import net.minestom.server.utils.Position;
import net.minestom.server.utils.binary.BinaryWriter;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -19,7 +19,7 @@ public class EntityMooshroom extends EntityCreature implements Animal {
} }
@Override @Override
public Consumer<PacketWriter> getMetadataConsumer() { public Consumer<BinaryWriter> getMetadataConsumer() {
return packet -> { return packet -> {
super.getMetadataConsumer().accept(packet); super.getMetadataConsumer().accept(packet);
fillMetadataIndex(packet, 16); fillMetadataIndex(packet, 16);
@ -27,7 +27,7 @@ public class EntityMooshroom extends EntityCreature implements Animal {
} }
@Override @Override
protected void fillMetadataIndex(PacketWriter packet, int index) { protected void fillMetadataIndex(BinaryWriter packet, int index) {
super.fillMetadataIndex(packet, index); super.fillMetadataIndex(packet, index);
if (index == 16) { if (index == 16) {
packet.writeByte((byte) 16); packet.writeByte((byte) 16);

View File

@ -3,8 +3,8 @@ package net.minestom.server.entity.type.animal;
import net.minestom.server.entity.EntityCreature; import net.minestom.server.entity.EntityCreature;
import net.minestom.server.entity.EntityType; import net.minestom.server.entity.EntityType;
import net.minestom.server.entity.type.Animal; import net.minestom.server.entity.type.Animal;
import net.minestom.server.network.packet.PacketWriter;
import net.minestom.server.utils.Position; import net.minestom.server.utils.Position;
import net.minestom.server.utils.binary.BinaryWriter;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -18,7 +18,7 @@ public class EntityPig extends EntityCreature implements Animal {
} }
@Override @Override
public Consumer<PacketWriter> getMetadataConsumer() { public Consumer<BinaryWriter> getMetadataConsumer() {
return packet -> { return packet -> {
super.getMetadataConsumer().accept(packet); super.getMetadataConsumer().accept(packet);
fillMetadataIndex(packet, 16); fillMetadataIndex(packet, 16);
@ -26,7 +26,7 @@ public class EntityPig extends EntityCreature implements Animal {
} }
@Override @Override
protected void fillMetadataIndex(PacketWriter packet, int index) { protected void fillMetadataIndex(BinaryWriter packet, int index) {
super.fillMetadataIndex(packet, index); super.fillMetadataIndex(packet, index);
if (index == 16) { if (index == 16) {
packet.writeByte((byte) 16); packet.writeByte((byte) 16);

View File

@ -3,8 +3,8 @@ package net.minestom.server.entity.type.animal;
import net.minestom.server.entity.EntityCreature; import net.minestom.server.entity.EntityCreature;
import net.minestom.server.entity.EntityType; import net.minestom.server.entity.EntityType;
import net.minestom.server.entity.type.Animal; import net.minestom.server.entity.type.Animal;
import net.minestom.server.network.packet.PacketWriter;
import net.minestom.server.utils.Position; import net.minestom.server.utils.Position;
import net.minestom.server.utils.binary.BinaryWriter;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -18,7 +18,7 @@ public class EntityPolarBear extends EntityCreature implements Animal {
} }
@Override @Override
public Consumer<PacketWriter> getMetadataConsumer() { public Consumer<BinaryWriter> getMetadataConsumer() {
return packet -> { return packet -> {
super.getMetadataConsumer().accept(packet); super.getMetadataConsumer().accept(packet);
fillMetadataIndex(packet, 16); fillMetadataIndex(packet, 16);
@ -26,7 +26,7 @@ public class EntityPolarBear extends EntityCreature implements Animal {
} }
@Override @Override
protected void fillMetadataIndex(PacketWriter packet, int index) { protected void fillMetadataIndex(BinaryWriter packet, int index) {
super.fillMetadataIndex(packet, index); super.fillMetadataIndex(packet, index);
if (index == 16) { if (index == 16) {
packet.writeByte((byte) 16); packet.writeByte((byte) 16);

View File

@ -3,8 +3,8 @@ package net.minestom.server.entity.type.animal;
import net.minestom.server.entity.EntityCreature; import net.minestom.server.entity.EntityCreature;
import net.minestom.server.entity.EntityType; import net.minestom.server.entity.EntityType;
import net.minestom.server.entity.type.Animal; import net.minestom.server.entity.type.Animal;
import net.minestom.server.network.packet.PacketWriter;
import net.minestom.server.utils.Position; import net.minestom.server.utils.Position;
import net.minestom.server.utils.binary.BinaryWriter;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -18,7 +18,7 @@ public class EntityRabbit extends EntityCreature implements Animal {
} }
@Override @Override
public Consumer<PacketWriter> getMetadataConsumer() { public Consumer<BinaryWriter> getMetadataConsumer() {
return packet -> { return packet -> {
super.getMetadataConsumer().accept(packet); super.getMetadataConsumer().accept(packet);
fillMetadataIndex(packet, 16); fillMetadataIndex(packet, 16);
@ -26,7 +26,7 @@ public class EntityRabbit extends EntityCreature implements Animal {
} }
@Override @Override
protected void fillMetadataIndex(PacketWriter packet, int index) { protected void fillMetadataIndex(BinaryWriter packet, int index) {
super.fillMetadataIndex(packet, index); super.fillMetadataIndex(packet, index);
if (index == 16) { if (index == 16) {
packet.writeByte((byte) 16); packet.writeByte((byte) 16);

View File

@ -6,10 +6,10 @@ import net.minestom.server.entity.Player;
import net.minestom.server.event.item.ArmorEquipEvent; import net.minestom.server.event.item.ArmorEquipEvent;
import net.minestom.server.inventory.EquipmentHandler; import net.minestom.server.inventory.EquipmentHandler;
import net.minestom.server.item.ItemStack; import net.minestom.server.item.ItemStack;
import net.minestom.server.network.packet.PacketWriter;
import net.minestom.server.network.packet.server.play.EntityEquipmentPacket; import net.minestom.server.network.packet.server.play.EntityEquipmentPacket;
import net.minestom.server.utils.Position; import net.minestom.server.utils.Position;
import net.minestom.server.utils.Vector; import net.minestom.server.utils.Vector;
import net.minestom.server.utils.binary.BinaryWriter;
import net.minestom.server.utils.item.ItemStackUtils; import net.minestom.server.utils.item.ItemStackUtils;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -73,7 +73,7 @@ public class EntityArmorStand extends ObjectEntity implements EquipmentHandler {
} }
@Override @Override
public Consumer<PacketWriter> getMetadataConsumer() { public Consumer<BinaryWriter> getMetadataConsumer() {
return packet -> { return packet -> {
super.getMetadataConsumer().accept(packet); super.getMetadataConsumer().accept(packet);
fillMetadataIndex(packet, 14); fillMetadataIndex(packet, 14);
@ -87,7 +87,7 @@ public class EntityArmorStand extends ObjectEntity implements EquipmentHandler {
} }
@Override @Override
protected void fillMetadataIndex(PacketWriter packet, int index) { protected void fillMetadataIndex(BinaryWriter packet, int index) {
super.fillMetadataIndex(packet, index); super.fillMetadataIndex(packet, index);
if (index == 14) { if (index == 14) {
packet.writeByte((byte) 14); packet.writeByte((byte) 14);

View File

@ -3,9 +3,9 @@ package net.minestom.server.entity.type.decoration;
import net.minestom.server.entity.EntityType; import net.minestom.server.entity.EntityType;
import net.minestom.server.entity.ObjectEntity; import net.minestom.server.entity.ObjectEntity;
import net.minestom.server.item.ItemStack; import net.minestom.server.item.ItemStack;
import net.minestom.server.network.packet.PacketWriter;
import net.minestom.server.utils.Position; import net.minestom.server.utils.Position;
import net.minestom.server.utils.Rotation; import net.minestom.server.utils.Rotation;
import net.minestom.server.utils.binary.BinaryWriter;
import net.minestom.server.utils.item.ItemStackUtils; import net.minestom.server.utils.item.ItemStackUtils;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -27,7 +27,7 @@ public class EntityItemFrame extends ObjectEntity {
} }
@Override @Override
public Consumer<PacketWriter> getMetadataConsumer() { public Consumer<BinaryWriter> getMetadataConsumer() {
return packet -> { return packet -> {
super.getMetadataConsumer().accept(packet); super.getMetadataConsumer().accept(packet);
fillMetadataIndex(packet, 7); fillMetadataIndex(packet, 7);
@ -36,7 +36,7 @@ public class EntityItemFrame extends ObjectEntity {
} }
@Override @Override
protected void fillMetadataIndex(PacketWriter packet, int index) { protected void fillMetadataIndex(BinaryWriter packet, int index) {
super.fillMetadataIndex(packet, index); super.fillMetadataIndex(packet, index);
if (index == 7) { if (index == 7) {
packet.writeByte((byte) 7); packet.writeByte((byte) 7);

View File

@ -3,8 +3,8 @@ package net.minestom.server.entity.type.monster;
import net.minestom.server.entity.EntityCreature; import net.minestom.server.entity.EntityCreature;
import net.minestom.server.entity.EntityType; import net.minestom.server.entity.EntityType;
import net.minestom.server.entity.type.Monster; import net.minestom.server.entity.type.Monster;
import net.minestom.server.network.packet.PacketWriter;
import net.minestom.server.utils.Position; import net.minestom.server.utils.Position;
import net.minestom.server.utils.binary.BinaryWriter;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -16,7 +16,7 @@ public class EntityBlaze extends EntityCreature implements Monster {
} }
@Override @Override
public Consumer<PacketWriter> getMetadataConsumer() { public Consumer<BinaryWriter> getMetadataConsumer() {
return packet -> { return packet -> {
super.getMetadataConsumer().accept(packet); super.getMetadataConsumer().accept(packet);
fillMetadataIndex(packet, 15); fillMetadataIndex(packet, 15);
@ -24,7 +24,7 @@ public class EntityBlaze extends EntityCreature implements Monster {
} }
@Override @Override
protected void fillMetadataIndex(PacketWriter packet, int index) { protected void fillMetadataIndex(BinaryWriter packet, int index) {
super.fillMetadataIndex(packet, index); super.fillMetadataIndex(packet, index);
if (index == 15) { if (index == 15) {
packet.writeByte((byte) 15); packet.writeByte((byte) 15);

View File

@ -3,8 +3,8 @@ package net.minestom.server.entity.type.monster;
import net.minestom.server.entity.EntityCreature; import net.minestom.server.entity.EntityCreature;
import net.minestom.server.entity.EntityType; import net.minestom.server.entity.EntityType;
import net.minestom.server.entity.type.Monster; import net.minestom.server.entity.type.Monster;
import net.minestom.server.network.packet.PacketWriter;
import net.minestom.server.utils.Position; import net.minestom.server.utils.Position;
import net.minestom.server.utils.binary.BinaryWriter;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -20,7 +20,7 @@ public class EntityCreeper extends EntityCreature implements Monster {
} }
@Override @Override
public Consumer<PacketWriter> getMetadataConsumer() { public Consumer<BinaryWriter> getMetadataConsumer() {
return packet -> { return packet -> {
super.getMetadataConsumer().accept(packet); super.getMetadataConsumer().accept(packet);
fillMetadataIndex(packet, 15); fillMetadataIndex(packet, 15);
@ -28,7 +28,7 @@ public class EntityCreeper extends EntityCreature implements Monster {
} }
@Override @Override
protected void fillMetadataIndex(PacketWriter packet, int index) { protected void fillMetadataIndex(BinaryWriter packet, int index) {
super.fillMetadataIndex(packet, index); super.fillMetadataIndex(packet, index);
if (index == 15) { if (index == 15) {
packet.writeByte((byte) 15); packet.writeByte((byte) 15);

View File

@ -3,8 +3,8 @@ package net.minestom.server.entity.type.monster;
import net.minestom.server.entity.EntityCreature; import net.minestom.server.entity.EntityCreature;
import net.minestom.server.entity.EntityType; import net.minestom.server.entity.EntityType;
import net.minestom.server.entity.type.Monster; import net.minestom.server.entity.type.Monster;
import net.minestom.server.network.packet.PacketWriter;
import net.minestom.server.utils.Position; import net.minestom.server.utils.Position;
import net.minestom.server.utils.binary.BinaryWriter;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -19,7 +19,7 @@ public class EntityGhast extends EntityCreature implements Monster {
} }
@Override @Override
public Consumer<PacketWriter> getMetadataConsumer() { public Consumer<BinaryWriter> getMetadataConsumer() {
return packet -> { return packet -> {
super.getMetadataConsumer().accept(packet); super.getMetadataConsumer().accept(packet);
fillMetadataIndex(packet, 15); fillMetadataIndex(packet, 15);
@ -27,7 +27,7 @@ public class EntityGhast extends EntityCreature implements Monster {
} }
@Override @Override
protected void fillMetadataIndex(PacketWriter packet, int index) { protected void fillMetadataIndex(BinaryWriter packet, int index) {
super.fillMetadataIndex(packet, index); super.fillMetadataIndex(packet, index);
if (index == 15) { if (index == 15) {
packet.writeByte((byte) 15); packet.writeByte((byte) 15);

View File

@ -4,8 +4,8 @@ import net.minestom.server.entity.Entity;
import net.minestom.server.entity.EntityCreature; import net.minestom.server.entity.EntityCreature;
import net.minestom.server.entity.EntityType; import net.minestom.server.entity.EntityType;
import net.minestom.server.entity.type.Monster; import net.minestom.server.entity.type.Monster;
import net.minestom.server.network.packet.PacketWriter;
import net.minestom.server.utils.Position; import net.minestom.server.utils.Position;
import net.minestom.server.utils.binary.BinaryWriter;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -20,7 +20,7 @@ public class EntityGuardian extends EntityCreature implements Monster {
} }
@Override @Override
public Consumer<PacketWriter> getMetadataConsumer() { public Consumer<BinaryWriter> getMetadataConsumer() {
return packet -> { return packet -> {
super.getMetadataConsumer().accept(packet); super.getMetadataConsumer().accept(packet);
fillMetadataIndex(packet, 15); fillMetadataIndex(packet, 15);
@ -29,7 +29,7 @@ public class EntityGuardian extends EntityCreature implements Monster {
} }
@Override @Override
protected void fillMetadataIndex(PacketWriter packet, int index) { protected void fillMetadataIndex(BinaryWriter packet, int index) {
super.fillMetadataIndex(packet, index); super.fillMetadataIndex(packet, index);
if (index == 15) { if (index == 15) {
packet.writeByte((byte) 15); packet.writeByte((byte) 15);

View File

@ -3,8 +3,8 @@ package net.minestom.server.entity.type.monster;
import net.minestom.server.entity.EntityCreature; import net.minestom.server.entity.EntityCreature;
import net.minestom.server.entity.EntityType; import net.minestom.server.entity.EntityType;
import net.minestom.server.entity.type.Monster; import net.minestom.server.entity.type.Monster;
import net.minestom.server.network.packet.PacketWriter;
import net.minestom.server.utils.Position; import net.minestom.server.utils.Position;
import net.minestom.server.utils.binary.BinaryWriter;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -18,7 +18,7 @@ public class EntityPhantom extends EntityCreature implements Monster {
} }
@Override @Override
public Consumer<PacketWriter> getMetadataConsumer() { public Consumer<BinaryWriter> getMetadataConsumer() {
return packet -> { return packet -> {
super.getMetadataConsumer().accept(packet); super.getMetadataConsumer().accept(packet);
fillMetadataIndex(packet, 15); fillMetadataIndex(packet, 15);
@ -26,7 +26,7 @@ public class EntityPhantom extends EntityCreature implements Monster {
} }
@Override @Override
protected void fillMetadataIndex(PacketWriter packet, int index) { protected void fillMetadataIndex(BinaryWriter packet, int index) {
super.fillMetadataIndex(packet, index); super.fillMetadataIndex(packet, index);
if (index == 15) { if (index == 15) {
packet.writeByte((byte) 15); packet.writeByte((byte) 15);

View File

@ -3,8 +3,8 @@ package net.minestom.server.entity.type.monster;
import net.minestom.server.entity.EntityCreature; import net.minestom.server.entity.EntityCreature;
import net.minestom.server.entity.EntityType; import net.minestom.server.entity.EntityType;
import net.minestom.server.entity.type.Monster; import net.minestom.server.entity.type.Monster;
import net.minestom.server.network.packet.PacketWriter;
import net.minestom.server.utils.Position; import net.minestom.server.utils.Position;
import net.minestom.server.utils.binary.BinaryWriter;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -18,7 +18,7 @@ public class EntitySlime extends EntityCreature implements Monster {
} }
@Override @Override
public Consumer<PacketWriter> getMetadataConsumer() { public Consumer<BinaryWriter> getMetadataConsumer() {
return packet -> { return packet -> {
super.getMetadataConsumer().accept(packet); super.getMetadataConsumer().accept(packet);
fillMetadataIndex(packet, 15); fillMetadataIndex(packet, 15);
@ -26,7 +26,7 @@ public class EntitySlime extends EntityCreature implements Monster {
} }
@Override @Override
protected void fillMetadataIndex(PacketWriter packet, int index) { protected void fillMetadataIndex(BinaryWriter packet, int index) {
super.fillMetadataIndex(packet, index); super.fillMetadataIndex(packet, index);
if (index == 15) { if (index == 15) {
packet.writeByte((byte) 15); packet.writeByte((byte) 15);

View File

@ -3,8 +3,8 @@ package net.minestom.server.entity.type.monster;
import net.minestom.server.entity.EntityCreature; import net.minestom.server.entity.EntityCreature;
import net.minestom.server.entity.EntityType; import net.minestom.server.entity.EntityType;
import net.minestom.server.entity.type.Monster; import net.minestom.server.entity.type.Monster;
import net.minestom.server.network.packet.PacketWriter;
import net.minestom.server.utils.Position; import net.minestom.server.utils.Position;
import net.minestom.server.utils.binary.BinaryWriter;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -19,7 +19,7 @@ public class EntitySpider extends EntityCreature implements Monster {
} }
@Override @Override
public Consumer<PacketWriter> getMetadataConsumer() { public Consumer<BinaryWriter> getMetadataConsumer() {
return packet -> { return packet -> {
super.getMetadataConsumer().accept(packet); super.getMetadataConsumer().accept(packet);
fillMetadataIndex(packet, 15); fillMetadataIndex(packet, 15);
@ -27,7 +27,7 @@ public class EntitySpider extends EntityCreature implements Monster {
} }
@Override @Override
protected void fillMetadataIndex(PacketWriter packet, int index) { protected void fillMetadataIndex(BinaryWriter packet, int index) {
super.fillMetadataIndex(packet, index); super.fillMetadataIndex(packet, index);
if (index == 15) { if (index == 15) {
packet.writeByte((byte) 15); packet.writeByte((byte) 15);

View File

@ -3,8 +3,8 @@ package net.minestom.server.entity.type.monster;
import net.minestom.server.entity.EntityCreature; import net.minestom.server.entity.EntityCreature;
import net.minestom.server.entity.EntityType; import net.minestom.server.entity.EntityType;
import net.minestom.server.entity.type.Monster; import net.minestom.server.entity.type.Monster;
import net.minestom.server.network.packet.PacketWriter;
import net.minestom.server.utils.Position; import net.minestom.server.utils.Position;
import net.minestom.server.utils.binary.BinaryWriter;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -19,7 +19,7 @@ public class EntityWitch extends EntityCreature implements Monster {
} }
@Override @Override
public Consumer<PacketWriter> getMetadataConsumer() { public Consumer<BinaryWriter> getMetadataConsumer() {
return packet -> { return packet -> {
super.getMetadataConsumer().accept(packet); super.getMetadataConsumer().accept(packet);
fillMetadataIndex(packet, 16); fillMetadataIndex(packet, 16);
@ -27,7 +27,7 @@ public class EntityWitch extends EntityCreature implements Monster {
} }
@Override @Override
protected void fillMetadataIndex(PacketWriter packet, int index) { protected void fillMetadataIndex(BinaryWriter packet, int index) {
super.fillMetadataIndex(packet, index); super.fillMetadataIndex(packet, index);
if (index == 16) { if (index == 16) {
packet.writeByte((byte) 16); packet.writeByte((byte) 16);

View File

@ -3,8 +3,8 @@ package net.minestom.server.entity.type.monster;
import net.minestom.server.entity.EntityCreature; import net.minestom.server.entity.EntityCreature;
import net.minestom.server.entity.EntityType; import net.minestom.server.entity.EntityType;
import net.minestom.server.entity.type.Monster; import net.minestom.server.entity.type.Monster;
import net.minestom.server.network.packet.PacketWriter;
import net.minestom.server.utils.Position; import net.minestom.server.utils.Position;
import net.minestom.server.utils.binary.BinaryWriter;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -19,7 +19,7 @@ public class EntityZombie extends EntityCreature implements Monster {
} }
@Override @Override
public Consumer<PacketWriter> getMetadataConsumer() { public Consumer<BinaryWriter> getMetadataConsumer() {
return packet -> { return packet -> {
super.getMetadataConsumer().accept(packet); super.getMetadataConsumer().accept(packet);
fillMetadataIndex(packet, 15); fillMetadataIndex(packet, 15);
@ -28,7 +28,7 @@ public class EntityZombie extends EntityCreature implements Monster {
} }
@Override @Override
protected void fillMetadataIndex(PacketWriter packet, int index) { protected void fillMetadataIndex(BinaryWriter packet, int index) {
super.fillMetadataIndex(packet, index); super.fillMetadataIndex(packet, index);
if (index == 15) { if (index == 15) {
packet.writeByte((byte) 15); packet.writeByte((byte) 15);

View File

@ -3,8 +3,8 @@ package net.minestom.server.entity.type.monster;
import net.minestom.server.entity.EntityCreature; import net.minestom.server.entity.EntityCreature;
import net.minestom.server.entity.EntityType; import net.minestom.server.entity.EntityType;
import net.minestom.server.entity.type.Monster; import net.minestom.server.entity.type.Monster;
import net.minestom.server.network.packet.PacketWriter;
import net.minestom.server.utils.Position; import net.minestom.server.utils.Position;
import net.minestom.server.utils.binary.BinaryWriter;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -19,7 +19,7 @@ public class EntityZombifiedPiglin extends EntityCreature implements Monster {
} }
@Override @Override
public Consumer<PacketWriter> getMetadataConsumer() { public Consumer<BinaryWriter> getMetadataConsumer() {
return packet -> { return packet -> {
super.getMetadataConsumer().accept(packet); super.getMetadataConsumer().accept(packet);
fillMetadataIndex(packet, 15); fillMetadataIndex(packet, 15);
@ -28,7 +28,7 @@ public class EntityZombifiedPiglin extends EntityCreature implements Monster {
} }
@Override @Override
protected void fillMetadataIndex(PacketWriter packet, int index) { protected void fillMetadataIndex(BinaryWriter packet, int index) {
super.fillMetadataIndex(packet, index); super.fillMetadataIndex(packet, index);
if (index == 15) { if (index == 15) {
packet.writeByte((byte) 15); packet.writeByte((byte) 15);

View File

@ -2,15 +2,15 @@ package net.minestom.server.entity.type.other;
import net.minestom.server.entity.EntityType; import net.minestom.server.entity.EntityType;
import net.minestom.server.entity.ObjectEntity; import net.minestom.server.entity.ObjectEntity;
import net.minestom.server.network.packet.PacketWriter;
import net.minestom.server.particle.Particle; import net.minestom.server.particle.Particle;
import net.minestom.server.utils.Position; import net.minestom.server.utils.Position;
import net.minestom.server.utils.binary.BinaryWriter;
import java.util.function.Consumer; import java.util.function.Consumer;
public class EntityAreaEffectCloud extends ObjectEntity { public class EntityAreaEffectCloud extends ObjectEntity {
public Consumer<PacketWriter> particleDataConsumer; public Consumer<BinaryWriter> particleDataConsumer;
private float radius; private float radius;
private int color; private int color;
private boolean ignoreRadius; private boolean ignoreRadius;
@ -27,7 +27,7 @@ public class EntityAreaEffectCloud extends ObjectEntity {
} }
@Override @Override
public Consumer<PacketWriter> getMetadataConsumer() { public Consumer<BinaryWriter> getMetadataConsumer() {
return packet -> { return packet -> {
super.getMetadataConsumer().accept(packet); super.getMetadataConsumer().accept(packet);
fillMetadataIndex(packet, 7); fillMetadataIndex(packet, 7);
@ -38,7 +38,7 @@ public class EntityAreaEffectCloud extends ObjectEntity {
} }
@Override @Override
protected void fillMetadataIndex(PacketWriter packet, int index) { protected void fillMetadataIndex(BinaryWriter packet, int index) {
super.fillMetadataIndex(packet, index); super.fillMetadataIndex(packet, index);
if (index == 7) { if (index == 7) {
packet.writeByte((byte) 7); packet.writeByte((byte) 7);
@ -102,7 +102,7 @@ public class EntityAreaEffectCloud extends ObjectEntity {
sendMetadataIndex(10); sendMetadataIndex(10);
} }
public Consumer<PacketWriter> getParticleDataConsumer() { public Consumer<BinaryWriter> getParticleDataConsumer() {
return particleDataConsumer; return particleDataConsumer;
} }
@ -112,7 +112,7 @@ public class EntityAreaEffectCloud extends ObjectEntity {
* @param particleDataConsumer the particle data consumer * @param particleDataConsumer the particle data consumer
* @see @see <a href="https://wiki.vg/Data_types#Particle">Particle data</a> * @see @see <a href="https://wiki.vg/Data_types#Particle">Particle data</a>
*/ */
public void setParticleDataConsumer(Consumer<PacketWriter> particleDataConsumer) { public void setParticleDataConsumer(Consumer<BinaryWriter> particleDataConsumer) {
this.particleDataConsumer = particleDataConsumer; this.particleDataConsumer = particleDataConsumer;
} }
} }

View File

@ -3,8 +3,8 @@ package net.minestom.server.entity.type.other;
import net.minestom.server.entity.EntityCreature; import net.minestom.server.entity.EntityCreature;
import net.minestom.server.entity.EntityType; import net.minestom.server.entity.EntityType;
import net.minestom.server.entity.type.Constructable; import net.minestom.server.entity.type.Constructable;
import net.minestom.server.network.packet.PacketWriter;
import net.minestom.server.utils.Position; import net.minestom.server.utils.Position;
import net.minestom.server.utils.binary.BinaryWriter;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -18,7 +18,7 @@ public class EntityIronGolem extends EntityCreature implements Constructable {
} }
@Override @Override
public Consumer<PacketWriter> getMetadataConsumer() { public Consumer<BinaryWriter> getMetadataConsumer() {
return packet -> { return packet -> {
super.getMetadataConsumer().accept(packet); super.getMetadataConsumer().accept(packet);
fillMetadataIndex(packet, 15); fillMetadataIndex(packet, 15);
@ -26,7 +26,7 @@ public class EntityIronGolem extends EntityCreature implements Constructable {
} }
@Override @Override
protected void fillMetadataIndex(PacketWriter packet, int index) { protected void fillMetadataIndex(BinaryWriter packet, int index) {
super.fillMetadataIndex(packet, index); super.fillMetadataIndex(packet, index);
if (index == 15) { if (index == 15) {
packet.writeByte((byte) 15); packet.writeByte((byte) 15);

View File

@ -3,8 +3,8 @@ package net.minestom.server.entity.type.other;
import net.minestom.server.entity.EntityCreature; import net.minestom.server.entity.EntityCreature;
import net.minestom.server.entity.EntityType; import net.minestom.server.entity.EntityType;
import net.minestom.server.entity.type.Constructable; import net.minestom.server.entity.type.Constructable;
import net.minestom.server.network.packet.PacketWriter;
import net.minestom.server.utils.Position; import net.minestom.server.utils.Position;
import net.minestom.server.utils.binary.BinaryWriter;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -18,7 +18,7 @@ public class EntitySnowman extends EntityCreature implements Constructable {
} }
@Override @Override
public Consumer<PacketWriter> getMetadataConsumer() { public Consumer<BinaryWriter> getMetadataConsumer() {
return packet -> { return packet -> {
super.getMetadataConsumer().accept(packet); super.getMetadataConsumer().accept(packet);
fillMetadataIndex(packet, 15); fillMetadataIndex(packet, 15);
@ -26,7 +26,7 @@ public class EntitySnowman extends EntityCreature implements Constructable {
} }
@Override @Override
protected void fillMetadataIndex(PacketWriter packet, int index) { protected void fillMetadataIndex(BinaryWriter packet, int index) {
super.fillMetadataIndex(packet, index); super.fillMetadataIndex(packet, index);
if (index == 15) { if (index == 15) {
packet.writeByte((byte) 15); packet.writeByte((byte) 15);

View File

@ -5,8 +5,8 @@ import net.minestom.server.entity.ObjectEntity;
import net.minestom.server.entity.type.Projectile; import net.minestom.server.entity.type.Projectile;
import net.minestom.server.item.ItemStack; import net.minestom.server.item.ItemStack;
import net.minestom.server.item.Material; import net.minestom.server.item.Material;
import net.minestom.server.network.packet.PacketWriter;
import net.minestom.server.utils.Position; import net.minestom.server.utils.Position;
import net.minestom.server.utils.binary.BinaryWriter;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -19,7 +19,7 @@ public class EntityEyeOfEnder extends ObjectEntity implements Projectile {
} }
@Override @Override
public Consumer<PacketWriter> getMetadataConsumer() { public Consumer<BinaryWriter> getMetadataConsumer() {
return packet -> { return packet -> {
super.getMetadataConsumer().accept(packet); super.getMetadataConsumer().accept(packet);
fillMetadataIndex(packet, 7); fillMetadataIndex(packet, 7);
@ -27,7 +27,7 @@ public class EntityEyeOfEnder extends ObjectEntity implements Projectile {
} }
@Override @Override
protected void fillMetadataIndex(PacketWriter packet, int index) { protected void fillMetadataIndex(BinaryWriter packet, int index) {
super.fillMetadataIndex(packet, index); super.fillMetadataIndex(packet, index);
if (index == 7) { if (index == 7) {
packet.writeByte((byte) 7); packet.writeByte((byte) 7);

View File

@ -4,8 +4,8 @@ import net.minestom.server.entity.EntityType;
import net.minestom.server.entity.ObjectEntity; import net.minestom.server.entity.ObjectEntity;
import net.minestom.server.entity.type.Projectile; import net.minestom.server.entity.type.Projectile;
import net.minestom.server.item.ItemStack; import net.minestom.server.item.ItemStack;
import net.minestom.server.network.packet.PacketWriter;
import net.minestom.server.utils.Position; import net.minestom.server.utils.Position;
import net.minestom.server.utils.binary.BinaryWriter;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -20,7 +20,7 @@ public class EntityPotion extends ObjectEntity implements Projectile {
} }
@Override @Override
public Consumer<PacketWriter> getMetadataConsumer() { public Consumer<BinaryWriter> getMetadataConsumer() {
return packet -> { return packet -> {
super.getMetadataConsumer().accept(packet); super.getMetadataConsumer().accept(packet);
fillMetadataIndex(packet, 7); fillMetadataIndex(packet, 7);
@ -28,7 +28,7 @@ public class EntityPotion extends ObjectEntity implements Projectile {
} }
@Override @Override
protected void fillMetadataIndex(PacketWriter packet, int index) { protected void fillMetadataIndex(BinaryWriter packet, int index) {
super.fillMetadataIndex(packet, index); super.fillMetadataIndex(packet, index);
if (index == 7) { if (index == 7) {
packet.writeByte((byte) 7); packet.writeByte((byte) 7);

View File

@ -3,8 +3,8 @@ package net.minestom.server.entity.type.vehicle;
import net.minestom.server.entity.EntityType; import net.minestom.server.entity.EntityType;
import net.minestom.server.entity.ObjectEntity; import net.minestom.server.entity.ObjectEntity;
import net.minestom.server.entity.type.Vehicle; import net.minestom.server.entity.type.Vehicle;
import net.minestom.server.network.packet.PacketWriter;
import net.minestom.server.utils.Position; import net.minestom.server.utils.Position;
import net.minestom.server.utils.binary.BinaryWriter;
import net.minestom.server.utils.validate.Check; import net.minestom.server.utils.validate.Check;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -27,7 +27,7 @@ public class EntityBoat extends ObjectEntity implements Vehicle {
} }
@Override @Override
public Consumer<PacketWriter> getMetadataConsumer() { public Consumer<BinaryWriter> getMetadataConsumer() {
return packet -> { return packet -> {
super.getMetadataConsumer().accept(packet); super.getMetadataConsumer().accept(packet);
fillMetadataIndex(packet, 10); fillMetadataIndex(packet, 10);
@ -39,7 +39,7 @@ public class EntityBoat extends ObjectEntity implements Vehicle {
} }
@Override @Override
protected void fillMetadataIndex(PacketWriter packet, int index) { protected void fillMetadataIndex(BinaryWriter packet, int index) {
super.fillMetadataIndex(packet, index); super.fillMetadataIndex(packet, index);
if (index == 10) { if (index == 10) {
packet.writeByte((byte) 10); packet.writeByte((byte) 10);

View File

@ -26,7 +26,6 @@ import net.minestom.server.utils.time.UpdateOption;
import net.minestom.server.utils.validate.Check; import net.minestom.server.utils.validate.Check;
import net.minestom.server.world.biomes.Biome; import net.minestom.server.world.biomes.Biome;
import java.io.IOException;
import java.util.*; import java.util.*;
import java.util.concurrent.CopyOnWriteArraySet; import java.util.concurrent.CopyOnWriteArraySet;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -229,9 +228,8 @@ public abstract class Chunk implements Viewable {
* Serialize the chunk * Serialize the chunk
* *
* @return the serialized chunk * @return the serialized chunk
* @throws IOException
*/ */
protected abstract byte[] getSerializedData() throws IOException; protected abstract byte[] getSerializedData();
/** /**
* Get a {@link ChunkDataPacket} which should contain the full chunk * Get a {@link ChunkDataPacket} which should contain the full chunk

View File

@ -9,11 +9,9 @@ import net.minestom.server.instance.block.CustomBlock;
import net.minestom.server.instance.block.UpdateConsumer; import net.minestom.server.instance.block.UpdateConsumer;
import net.minestom.server.network.packet.server.play.ChunkDataPacket; import net.minestom.server.network.packet.server.play.ChunkDataPacket;
import net.minestom.server.utils.MathUtils; import net.minestom.server.utils.MathUtils;
import net.minestom.server.utils.binary.BinaryWriter;
import net.minestom.server.world.biomes.Biome; import net.minestom.server.world.biomes.Biome;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.concurrent.CopyOnWriteArraySet; import java.util.concurrent.CopyOnWriteArraySet;
public class DynamicChunk extends Chunk { public class DynamicChunk extends Chunk {
@ -146,12 +144,13 @@ public class DynamicChunk extends Chunk {
} }
@Override @Override
protected byte[] getSerializedData() throws IOException { protected byte[] getSerializedData() {
ByteArrayOutputStream output = new ByteArrayOutputStream(); BinaryWriter binaryWriter = new BinaryWriter();
DataOutputStream dos = new DataOutputStream(output);
// Write the biomes id
for (int i = 0; i < BIOME_COUNT; i++) { for (int i = 0; i < BIOME_COUNT; i++) {
dos.writeByte(biomes[i].getId()); final byte id = (byte) biomes[i].getId();
binaryWriter.writeByte(id);
} }
for (byte x = 0; x < CHUNK_SIZE_X; x++) { for (byte x = 0; x < CHUNK_SIZE_X; x++) {
@ -162,33 +161,32 @@ public class DynamicChunk extends Chunk {
final short blockStateId = blocksStateId[index]; final short blockStateId = blocksStateId[index];
final short customBlockId = customBlocksId[index]; final short customBlockId = customBlocksId[index];
// No block at the position
if (blockStateId == 0 && customBlockId == 0) if (blockStateId == 0 && customBlockId == 0)
continue; continue;
final Data data = blocksData.get(index);
// Chunk coordinates // Chunk coordinates
dos.writeInt(x); binaryWriter.writeByte(x);
dos.writeInt(y); binaryWriter.writeShort(y);
dos.writeInt(z); binaryWriter.writeByte(z);
// Id // Block ids
dos.writeShort(blockStateId); binaryWriter.writeShort(blockStateId);
dos.writeShort(customBlockId); binaryWriter.writeShort(customBlockId);
// Data // Data
final Data data = blocksData.get(index);
final boolean hasData = data instanceof SerializableData; final boolean hasData = data instanceof SerializableData;
dos.writeBoolean(hasData); binaryWriter.writeBoolean(hasData);
if (hasData) { if (hasData) {
final byte[] d = ((SerializableData) data).getSerializedData(); final byte[] serializedData = ((SerializableData) data).getSerializedData();
dos.writeInt(d.length); binaryWriter.writeBytes(serializedData);
dos.write(d);
} }
} }
} }
} }
return output.toByteArray(); return binaryWriter.toByteArray();
} }
@Override @Override

View File

@ -5,7 +5,6 @@ import net.minestom.server.storage.StorageFolder;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.function.Consumer; import java.util.function.Consumer;
public class MinestomBasicChunkLoader implements IChunkLoader { public class MinestomBasicChunkLoader implements IChunkLoader {
@ -27,7 +26,6 @@ public class MinestomBasicChunkLoader implements IChunkLoader {
final int chunkX = chunk.getChunkX(); final int chunkX = chunk.getChunkX();
final int chunkZ = chunk.getChunkZ(); final int chunkZ = chunk.getChunkZ();
try {
final String key = getChunkKey(chunkX, chunkZ); final String key = getChunkKey(chunkX, chunkZ);
final byte[] data = chunk.getSerializedData(); final byte[] data = chunk.getSerializedData();
if (data == null) if (data == null)
@ -36,9 +34,6 @@ public class MinestomBasicChunkLoader implements IChunkLoader {
if (callback != null) if (callback != null)
callback.run(); callback.run();
} catch (IOException e) {
e.printStackTrace();
}
} }
@Override @Override

View File

@ -5,7 +5,6 @@ import io.netty.channel.socket.SocketChannel;
import net.minestom.server.MinecraftServer; import net.minestom.server.MinecraftServer;
import net.minestom.server.entity.Player; import net.minestom.server.entity.Player;
import net.minestom.server.network.netty.packet.InboundPacket; import net.minestom.server.network.netty.packet.InboundPacket;
import net.minestom.server.network.packet.PacketReader;
import net.minestom.server.network.packet.client.ClientPlayPacket; import net.minestom.server.network.packet.client.ClientPlayPacket;
import net.minestom.server.network.packet.client.ClientPreplayPacket; import net.minestom.server.network.packet.client.ClientPreplayPacket;
import net.minestom.server.network.packet.client.handler.ClientLoginPacketsHandler; import net.minestom.server.network.packet.client.handler.ClientLoginPacketsHandler;
@ -14,6 +13,7 @@ import net.minestom.server.network.packet.client.handler.ClientStatusPacketsHand
import net.minestom.server.network.packet.client.handshake.HandshakePacket; import net.minestom.server.network.packet.client.handshake.HandshakePacket;
import net.minestom.server.network.player.NettyPlayerConnection; import net.minestom.server.network.player.NettyPlayerConnection;
import net.minestom.server.network.player.PlayerConnection; import net.minestom.server.network.player.PlayerConnection;
import net.minestom.server.utils.binary.BinaryReader;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@ -55,13 +55,13 @@ public class PacketProcessor {
//System.out.println("RECEIVED ID: 0x" + Integer.toHexString(id) + " State: " + connectionState); //System.out.println("RECEIVED ID: 0x" + Integer.toHexString(id) + " State: " + connectionState);
//} //}
PacketReader packetReader = new PacketReader(packet.body); BinaryReader binaryReader = new BinaryReader(packet.body);
if (connectionState == ConnectionState.UNKNOWN) { if (connectionState == ConnectionState.UNKNOWN) {
// Should be handshake packet // Should be handshake packet
if (packet.packetId == 0) { if (packet.packetId == 0) {
HandshakePacket handshakePacket = new HandshakePacket(); HandshakePacket handshakePacket = new HandshakePacket();
handshakePacket.read(packetReader); handshakePacket.read(binaryReader);
handshakePacket.process(playerConnection, connectionManager); handshakePacket.process(playerConnection, connectionManager);
} }
return; return;
@ -71,17 +71,17 @@ public class PacketProcessor {
case PLAY: case PLAY:
final Player player = playerConnection.getPlayer(); final Player player = playerConnection.getPlayer();
ClientPlayPacket playPacket = (ClientPlayPacket) playPacketsHandler.getPacketInstance(packet.packetId); ClientPlayPacket playPacket = (ClientPlayPacket) playPacketsHandler.getPacketInstance(packet.packetId);
playPacket.read(packetReader); playPacket.read(binaryReader);
player.addPacketToQueue(playPacket); player.addPacketToQueue(playPacket);
break; break;
case LOGIN: case LOGIN:
final ClientPreplayPacket loginPacket = (ClientPreplayPacket) loginPacketsHandler.getPacketInstance(packet.packetId); final ClientPreplayPacket loginPacket = (ClientPreplayPacket) loginPacketsHandler.getPacketInstance(packet.packetId);
loginPacket.read(packetReader); loginPacket.read(binaryReader);
loginPacket.process(playerConnection, connectionManager); loginPacket.process(playerConnection, connectionManager);
break; break;
case STATUS: case STATUS:
final ClientPreplayPacket statusPacket = (ClientPreplayPacket) statusPacketsHandler.getPacketInstance(packet.packetId); final ClientPreplayPacket statusPacket = (ClientPreplayPacket) statusPacketsHandler.getPacketInstance(packet.packetId);
statusPacket.read(packetReader); statusPacket.read(binaryReader);
statusPacket.process(playerConnection, connectionManager); statusPacket.process(playerConnection, connectionManager);
break; break;

View File

@ -1,9 +1,9 @@
package net.minestom.server.network.packet.client; package net.minestom.server.network.packet.client;
import net.minestom.server.network.packet.PacketReader; import net.minestom.server.utils.binary.BinaryReader;
public interface ClientPacket { public interface ClientPacket {
void read(PacketReader reader); void read(BinaryReader reader);
} }

View File

@ -5,10 +5,10 @@ import net.minestom.server.chat.ChatColor;
import net.minestom.server.chat.ColoredText; import net.minestom.server.chat.ColoredText;
import net.minestom.server.network.ConnectionManager; import net.minestom.server.network.ConnectionManager;
import net.minestom.server.network.ConnectionState; import net.minestom.server.network.ConnectionState;
import net.minestom.server.network.packet.PacketReader;
import net.minestom.server.network.packet.client.ClientPreplayPacket; import net.minestom.server.network.packet.client.ClientPreplayPacket;
import net.minestom.server.network.packet.server.login.LoginDisconnect; import net.minestom.server.network.packet.server.login.LoginDisconnect;
import net.minestom.server.network.player.PlayerConnection; import net.minestom.server.network.player.PlayerConnection;
import net.minestom.server.utils.binary.BinaryReader;
public class HandshakePacket implements ClientPreplayPacket { public class HandshakePacket implements ClientPreplayPacket {
@ -18,7 +18,7 @@ public class HandshakePacket implements ClientPreplayPacket {
private int nextState; private int nextState;
@Override @Override
public void read(PacketReader reader) { public void read(BinaryReader reader) {
this.protocolVersion = reader.readVarInt(); this.protocolVersion = reader.readVarInt();
this.serverAddress = reader.readSizedString(); this.serverAddress = reader.readSizedString();
this.serverPort = reader.readUnsignedShort(); this.serverPort = reader.readUnsignedShort();

View File

@ -7,11 +7,11 @@ import net.minestom.server.data.type.array.ByteArrayData;
import net.minestom.server.extras.mojangAuth.MojangCrypt; import net.minestom.server.extras.mojangAuth.MojangCrypt;
import net.minestom.server.network.ConnectionManager; import net.minestom.server.network.ConnectionManager;
import net.minestom.server.network.ConnectionState; import net.minestom.server.network.ConnectionState;
import net.minestom.server.network.packet.PacketReader;
import net.minestom.server.network.packet.client.ClientPreplayPacket; import net.minestom.server.network.packet.client.ClientPreplayPacket;
import net.minestom.server.network.packet.server.login.LoginSuccessPacket; import net.minestom.server.network.packet.server.login.LoginSuccessPacket;
import net.minestom.server.network.player.NettyPlayerConnection; import net.minestom.server.network.player.NettyPlayerConnection;
import net.minestom.server.network.player.PlayerConnection; import net.minestom.server.network.player.PlayerConnection;
import net.minestom.server.utils.binary.BinaryReader;
import javax.crypto.SecretKey; import javax.crypto.SecretKey;
import java.math.BigInteger; import java.math.BigInteger;
@ -58,7 +58,7 @@ public class EncryptionResponsePacket implements ClientPreplayPacket {
} }
@Override @Override
public void read(PacketReader reader) { public void read(BinaryReader reader) {
sharedSecret = ByteArrayData.decodeByteArray(reader); sharedSecret = ByteArrayData.decodeByteArray(reader);
verifyToken = ByteArrayData.decodeByteArray(reader); verifyToken = ByteArrayData.decodeByteArray(reader);
} }

View File

@ -6,12 +6,12 @@ import net.minestom.server.chat.ColoredText;
import net.minestom.server.extras.MojangAuth; import net.minestom.server.extras.MojangAuth;
import net.minestom.server.network.ConnectionManager; import net.minestom.server.network.ConnectionManager;
import net.minestom.server.network.ConnectionState; import net.minestom.server.network.ConnectionState;
import net.minestom.server.network.packet.PacketReader;
import net.minestom.server.network.packet.client.ClientPreplayPacket; import net.minestom.server.network.packet.client.ClientPreplayPacket;
import net.minestom.server.network.packet.server.login.EncryptionRequestPacket; import net.minestom.server.network.packet.server.login.EncryptionRequestPacket;
import net.minestom.server.network.packet.server.login.LoginDisconnect; import net.minestom.server.network.packet.server.login.LoginDisconnect;
import net.minestom.server.network.packet.server.login.LoginSuccessPacket; import net.minestom.server.network.packet.server.login.LoginSuccessPacket;
import net.minestom.server.network.player.PlayerConnection; import net.minestom.server.network.player.PlayerConnection;
import net.minestom.server.utils.binary.BinaryReader;
import java.util.UUID; import java.util.UUID;
@ -53,7 +53,7 @@ public class LoginStartPacket implements ClientPreplayPacket {
} }
@Override @Override
public void read(PacketReader reader) { public void read(BinaryReader reader) {
this.username = reader.readSizedString(); this.username = reader.readSizedString();
} }

View File

@ -1,8 +1,8 @@
package net.minestom.server.network.packet.client.play; package net.minestom.server.network.packet.client.play;
import net.minestom.server.advancements.AdvancementAction; import net.minestom.server.advancements.AdvancementAction;
import net.minestom.server.network.packet.PacketReader;
import net.minestom.server.network.packet.client.ClientPlayPacket; import net.minestom.server.network.packet.client.ClientPlayPacket;
import net.minestom.server.utils.binary.BinaryReader;
public class ClientAdvancementTabPacket extends ClientPlayPacket { public class ClientAdvancementTabPacket extends ClientPlayPacket {
@ -10,7 +10,7 @@ public class ClientAdvancementTabPacket extends ClientPlayPacket {
public String tabIdentifier; public String tabIdentifier;
@Override @Override
public void read(PacketReader reader) { public void read(BinaryReader reader) {
this.action = AdvancementAction.values()[reader.readVarInt()]; this.action = AdvancementAction.values()[reader.readVarInt()];
if (action == AdvancementAction.OPENED_TAB) { if (action == AdvancementAction.OPENED_TAB) {

View File

@ -1,15 +1,15 @@
package net.minestom.server.network.packet.client.play; package net.minestom.server.network.packet.client.play;
import net.minestom.server.entity.Player; import net.minestom.server.entity.Player;
import net.minestom.server.network.packet.PacketReader;
import net.minestom.server.network.packet.client.ClientPlayPacket; import net.minestom.server.network.packet.client.ClientPlayPacket;
import net.minestom.server.utils.binary.BinaryReader;
public class ClientAnimationPacket extends ClientPlayPacket { public class ClientAnimationPacket extends ClientPlayPacket {
public Player.Hand hand; public Player.Hand hand;
@Override @Override
public void read(PacketReader reader) { public void read(BinaryReader reader) {
this.hand = Player.Hand.values()[reader.readVarInt()]; this.hand = Player.Hand.values()[reader.readVarInt()];
} }
} }

View File

@ -1,14 +1,14 @@
package net.minestom.server.network.packet.client.play; package net.minestom.server.network.packet.client.play;
import net.minestom.server.network.packet.PacketReader;
import net.minestom.server.network.packet.client.ClientPlayPacket; import net.minestom.server.network.packet.client.ClientPlayPacket;
import net.minestom.server.utils.binary.BinaryReader;
public class ClientChatMessagePacket extends ClientPlayPacket { public class ClientChatMessagePacket extends ClientPlayPacket {
public String message; public String message;
@Override @Override
public void read(PacketReader reader) { public void read(BinaryReader reader) {
this.message = reader.readSizedString(); this.message = reader.readSizedString();
} }
} }

View File

@ -1,7 +1,7 @@
package net.minestom.server.network.packet.client.play; package net.minestom.server.network.packet.client.play;
import net.minestom.server.network.packet.PacketReader;
import net.minestom.server.network.packet.client.ClientPlayPacket; import net.minestom.server.network.packet.client.ClientPlayPacket;
import net.minestom.server.utils.binary.BinaryReader;
public class ClientClickWindowButtonPacket extends ClientPlayPacket { public class ClientClickWindowButtonPacket extends ClientPlayPacket {
@ -9,7 +9,7 @@ public class ClientClickWindowButtonPacket extends ClientPlayPacket {
public byte buttonId; public byte buttonId;
@Override @Override
public void read(PacketReader reader) { public void read(BinaryReader reader) {
this.windowId = reader.readByte(); this.windowId = reader.readByte();
this.buttonId = reader.readByte(); this.buttonId = reader.readByte();
} }

View File

@ -1,8 +1,8 @@
package net.minestom.server.network.packet.client.play; package net.minestom.server.network.packet.client.play;
import net.minestom.server.item.ItemStack; import net.minestom.server.item.ItemStack;
import net.minestom.server.network.packet.PacketReader;
import net.minestom.server.network.packet.client.ClientPlayPacket; import net.minestom.server.network.packet.client.ClientPlayPacket;
import net.minestom.server.utils.binary.BinaryReader;
public class ClientClickWindowPacket extends ClientPlayPacket { public class ClientClickWindowPacket extends ClientPlayPacket {
@ -14,7 +14,7 @@ public class ClientClickWindowPacket extends ClientPlayPacket {
public ItemStack item; public ItemStack item;
@Override @Override
public void read(PacketReader reader) { public void read(BinaryReader reader) {
this.windowId = reader.readByte(); this.windowId = reader.readByte();
this.slot = reader.readShort(); this.slot = reader.readShort();
this.button = reader.readByte(); this.button = reader.readByte();

View File

@ -1,14 +1,14 @@
package net.minestom.server.network.packet.client.play; package net.minestom.server.network.packet.client.play;
import net.minestom.server.network.packet.PacketReader;
import net.minestom.server.network.packet.client.ClientPlayPacket; import net.minestom.server.network.packet.client.ClientPlayPacket;
import net.minestom.server.utils.binary.BinaryReader;
public class ClientCloseWindow extends ClientPlayPacket { public class ClientCloseWindow extends ClientPlayPacket {
public int windowId; public int windowId;
@Override @Override
public void read(PacketReader reader) { public void read(BinaryReader reader) {
this.windowId = reader.readVarInt(); this.windowId = reader.readVarInt();
} }
} }

View File

@ -1,7 +1,7 @@
package net.minestom.server.network.packet.client.play; package net.minestom.server.network.packet.client.play;
import net.minestom.server.network.packet.PacketReader;
import net.minestom.server.network.packet.client.ClientPlayPacket; import net.minestom.server.network.packet.client.ClientPlayPacket;
import net.minestom.server.utils.binary.BinaryReader;
public class ClientCraftRecipeRequest extends ClientPlayPacket { public class ClientCraftRecipeRequest extends ClientPlayPacket {
@ -10,7 +10,7 @@ public class ClientCraftRecipeRequest extends ClientPlayPacket {
public boolean makeAll; public boolean makeAll;
@Override @Override
public void read(PacketReader reader) { public void read(BinaryReader reader) {
this.windowId = reader.readByte(); this.windowId = reader.readByte();
this.recipe = reader.readSizedString(); this.recipe = reader.readSizedString();
this.makeAll = reader.readBoolean(); this.makeAll = reader.readBoolean();

View File

@ -1,8 +1,8 @@
package net.minestom.server.network.packet.client.play; package net.minestom.server.network.packet.client.play;
import net.minestom.server.item.ItemStack; import net.minestom.server.item.ItemStack;
import net.minestom.server.network.packet.PacketReader;
import net.minestom.server.network.packet.client.ClientPlayPacket; import net.minestom.server.network.packet.client.ClientPlayPacket;
import net.minestom.server.utils.binary.BinaryReader;
public class ClientCreativeInventoryActionPacket extends ClientPlayPacket { public class ClientCreativeInventoryActionPacket extends ClientPlayPacket {
@ -10,7 +10,7 @@ public class ClientCreativeInventoryActionPacket extends ClientPlayPacket {
public ItemStack item; public ItemStack item;
@Override @Override
public void read(PacketReader reader) { public void read(BinaryReader reader) {
this.slot = reader.readShort(); this.slot = reader.readShort();
this.item = reader.readSlot(); this.item = reader.readSlot();
} }

View File

@ -1,7 +1,7 @@
package net.minestom.server.network.packet.client.play; package net.minestom.server.network.packet.client.play;
import net.minestom.server.network.packet.PacketReader;
import net.minestom.server.network.packet.client.ClientPlayPacket; import net.minestom.server.network.packet.client.ClientPlayPacket;
import net.minestom.server.utils.binary.BinaryReader;
public class ClientEntityActionPacket extends ClientPlayPacket { public class ClientEntityActionPacket extends ClientPlayPacket {
@ -10,7 +10,7 @@ public class ClientEntityActionPacket extends ClientPlayPacket {
public int horseJumpBoost; public int horseJumpBoost;
@Override @Override
public void read(PacketReader reader) { public void read(BinaryReader reader) {
this.playerId = reader.readVarInt(); this.playerId = reader.readVarInt();
this.action = Action.values()[reader.readVarInt()]; this.action = Action.values()[reader.readVarInt()];
this.horseJumpBoost = reader.readVarInt(); this.horseJumpBoost = reader.readVarInt();

View File

@ -1,14 +1,14 @@
package net.minestom.server.network.packet.client.play; package net.minestom.server.network.packet.client.play;
import net.minestom.server.network.packet.PacketReader;
import net.minestom.server.network.packet.client.ClientPlayPacket; import net.minestom.server.network.packet.client.ClientPlayPacket;
import net.minestom.server.utils.binary.BinaryReader;
public class ClientHeldItemChangePacket extends ClientPlayPacket { public class ClientHeldItemChangePacket extends ClientPlayPacket {
public short slot; public short slot;
@Override @Override
public void read(PacketReader reader) { public void read(BinaryReader reader) {
this.slot = reader.readShort(); this.slot = reader.readShort();
} }
} }

View File

@ -1,8 +1,8 @@
package net.minestom.server.network.packet.client.play; package net.minestom.server.network.packet.client.play;
import net.minestom.server.entity.Player; import net.minestom.server.entity.Player;
import net.minestom.server.network.packet.PacketReader;
import net.minestom.server.network.packet.client.ClientPlayPacket; import net.minestom.server.network.packet.client.ClientPlayPacket;
import net.minestom.server.utils.binary.BinaryReader;
public class ClientInteractEntityPacket extends ClientPlayPacket { public class ClientInteractEntityPacket extends ClientPlayPacket {
@ -15,7 +15,7 @@ public class ClientInteractEntityPacket extends ClientPlayPacket {
public boolean sneaking; public boolean sneaking;
@Override @Override
public void read(PacketReader reader) { public void read(BinaryReader reader) {
this.targetId = reader.readVarInt(); this.targetId = reader.readVarInt();
this.type = Type.values()[reader.readVarInt()]; this.type = Type.values()[reader.readVarInt()];

View File

@ -1,14 +1,14 @@
package net.minestom.server.network.packet.client.play; package net.minestom.server.network.packet.client.play;
import net.minestom.server.network.packet.PacketReader;
import net.minestom.server.network.packet.client.ClientPlayPacket; import net.minestom.server.network.packet.client.ClientPlayPacket;
import net.minestom.server.utils.binary.BinaryReader;
public class ClientKeepAlivePacket extends ClientPlayPacket { public class ClientKeepAlivePacket extends ClientPlayPacket {
public long id; public long id;
@Override @Override
public void read(PacketReader reader) { public void read(BinaryReader reader) {
this.id = reader.readLong(); this.id = reader.readLong();
} }
} }

View File

@ -1,14 +1,14 @@
package net.minestom.server.network.packet.client.play; package net.minestom.server.network.packet.client.play;
import net.minestom.server.network.packet.PacketReader;
import net.minestom.server.network.packet.client.ClientPlayPacket; import net.minestom.server.network.packet.client.ClientPlayPacket;
import net.minestom.server.utils.binary.BinaryReader;
public class ClientNameItemPacket extends ClientPlayPacket { public class ClientNameItemPacket extends ClientPlayPacket {
public String itemName; public String itemName;
@Override @Override
public void read(PacketReader reader) { public void read(BinaryReader reader) {
this.itemName = reader.readSizedString(); this.itemName = reader.readSizedString();
} }
} }

View File

@ -1,14 +1,14 @@
package net.minestom.server.network.packet.client.play; package net.minestom.server.network.packet.client.play;
import net.minestom.server.network.packet.PacketReader;
import net.minestom.server.network.packet.client.ClientPlayPacket; import net.minestom.server.network.packet.client.ClientPlayPacket;
import net.minestom.server.utils.binary.BinaryReader;
public class ClientPickItemPacket extends ClientPlayPacket { public class ClientPickItemPacket extends ClientPlayPacket {
public int slotToUse; public int slotToUse;
@Override @Override
public void read(PacketReader reader) { public void read(BinaryReader reader) {
this.slotToUse = reader.readVarInt(); this.slotToUse = reader.readVarInt();
} }
} }

View File

@ -1,14 +1,14 @@
package net.minestom.server.network.packet.client.play; package net.minestom.server.network.packet.client.play;
import net.minestom.server.network.packet.PacketReader;
import net.minestom.server.network.packet.client.ClientPlayPacket; import net.minestom.server.network.packet.client.ClientPlayPacket;
import net.minestom.server.utils.binary.BinaryReader;
public class ClientPlayerAbilitiesPacket extends ClientPlayPacket { public class ClientPlayerAbilitiesPacket extends ClientPlayPacket {
public byte flags; public byte flags;
@Override @Override
public void read(PacketReader reader) { public void read(BinaryReader reader) {
this.flags = reader.readByte(); this.flags = reader.readByte();
} }
} }

View File

@ -2,9 +2,9 @@ package net.minestom.server.network.packet.client.play;
import net.minestom.server.entity.Player; import net.minestom.server.entity.Player;
import net.minestom.server.instance.block.BlockFace; import net.minestom.server.instance.block.BlockFace;
import net.minestom.server.network.packet.PacketReader;
import net.minestom.server.network.packet.client.ClientPlayPacket; import net.minestom.server.network.packet.client.ClientPlayPacket;
import net.minestom.server.utils.BlockPosition; import net.minestom.server.utils.BlockPosition;
import net.minestom.server.utils.binary.BinaryReader;
public class ClientPlayerBlockPlacementPacket extends ClientPlayPacket { public class ClientPlayerBlockPlacementPacket extends ClientPlayPacket {
@ -15,7 +15,7 @@ public class ClientPlayerBlockPlacementPacket extends ClientPlayPacket {
public boolean insideBlock; public boolean insideBlock;
@Override @Override
public void read(PacketReader reader) { public void read(BinaryReader reader) {
this.hand = Player.Hand.values()[reader.readVarInt()]; this.hand = Player.Hand.values()[reader.readVarInt()];
this.blockPosition = reader.readBlockPosition(); this.blockPosition = reader.readBlockPosition();
this.blockFace = BlockFace.values()[reader.readVarInt()]; this.blockFace = BlockFace.values()[reader.readVarInt()];

View File

@ -1,9 +1,9 @@
package net.minestom.server.network.packet.client.play; package net.minestom.server.network.packet.client.play;
import net.minestom.server.instance.block.BlockFace; import net.minestom.server.instance.block.BlockFace;
import net.minestom.server.network.packet.PacketReader;
import net.minestom.server.network.packet.client.ClientPlayPacket; import net.minestom.server.network.packet.client.ClientPlayPacket;
import net.minestom.server.utils.BlockPosition; import net.minestom.server.utils.BlockPosition;
import net.minestom.server.utils.binary.BinaryReader;
public class ClientPlayerDiggingPacket extends ClientPlayPacket { public class ClientPlayerDiggingPacket extends ClientPlayPacket {
@ -12,7 +12,7 @@ public class ClientPlayerDiggingPacket extends ClientPlayPacket {
public BlockFace blockFace; public BlockFace blockFace;
@Override @Override
public void read(PacketReader reader) { public void read(BinaryReader reader) {
this.status = Status.values()[reader.readVarInt()]; this.status = Status.values()[reader.readVarInt()];
this.blockPosition = reader.readBlockPosition(); this.blockPosition = reader.readBlockPosition();
this.blockFace = BlockFace.values()[reader.readVarInt()]; this.blockFace = BlockFace.values()[reader.readVarInt()];

View File

@ -1,14 +1,14 @@
package net.minestom.server.network.packet.client.play; package net.minestom.server.network.packet.client.play;
import net.minestom.server.network.packet.PacketReader;
import net.minestom.server.network.packet.client.ClientPlayPacket; import net.minestom.server.network.packet.client.ClientPlayPacket;
import net.minestom.server.utils.binary.BinaryReader;
public class ClientPlayerPacket extends ClientPlayPacket { public class ClientPlayerPacket extends ClientPlayPacket {
public boolean onGround; public boolean onGround;
@Override @Override
public void read(PacketReader reader) { public void read(BinaryReader reader) {
this.onGround = reader.readBoolean(); this.onGround = reader.readBoolean();
} }
} }

View File

@ -1,7 +1,7 @@
package net.minestom.server.network.packet.client.play; package net.minestom.server.network.packet.client.play;
import net.minestom.server.network.packet.PacketReader;
import net.minestom.server.network.packet.client.ClientPlayPacket; import net.minestom.server.network.packet.client.ClientPlayPacket;
import net.minestom.server.utils.binary.BinaryReader;
public class ClientPlayerPositionAndRotationPacket extends ClientPlayPacket { public class ClientPlayerPositionAndRotationPacket extends ClientPlayPacket {
@ -10,7 +10,7 @@ public class ClientPlayerPositionAndRotationPacket extends ClientPlayPacket {
public boolean onGround; public boolean onGround;
@Override @Override
public void read(PacketReader reader) { public void read(BinaryReader reader) {
this.x = reader.readDouble(); this.x = reader.readDouble();
this.y = reader.readDouble(); this.y = reader.readDouble();
this.z = reader.readDouble(); this.z = reader.readDouble();

View File

@ -1,7 +1,7 @@
package net.minestom.server.network.packet.client.play; package net.minestom.server.network.packet.client.play;
import net.minestom.server.network.packet.PacketReader;
import net.minestom.server.network.packet.client.ClientPlayPacket; import net.minestom.server.network.packet.client.ClientPlayPacket;
import net.minestom.server.utils.binary.BinaryReader;
public class ClientPlayerPositionPacket extends ClientPlayPacket { public class ClientPlayerPositionPacket extends ClientPlayPacket {
@ -9,7 +9,7 @@ public class ClientPlayerPositionPacket extends ClientPlayPacket {
public boolean onGround; public boolean onGround;
@Override @Override
public void read(PacketReader reader) { public void read(BinaryReader reader) {
this.x = reader.readDouble(); this.x = reader.readDouble();
this.y = reader.readDouble(); this.y = reader.readDouble();
this.z = reader.readDouble(); this.z = reader.readDouble();

View File

@ -1,7 +1,7 @@
package net.minestom.server.network.packet.client.play; package net.minestom.server.network.packet.client.play;
import net.minestom.server.network.packet.PacketReader;
import net.minestom.server.network.packet.client.ClientPlayPacket; import net.minestom.server.network.packet.client.ClientPlayPacket;
import net.minestom.server.utils.binary.BinaryReader;
public class ClientPlayerRotationPacket extends ClientPlayPacket { public class ClientPlayerRotationPacket extends ClientPlayPacket {
@ -9,7 +9,7 @@ public class ClientPlayerRotationPacket extends ClientPlayPacket {
public boolean onGround; public boolean onGround;
@Override @Override
public void read(PacketReader reader) { public void read(BinaryReader reader) {
this.yaw = reader.readFloat(); this.yaw = reader.readFloat();
this.pitch = reader.readFloat(); this.pitch = reader.readFloat();
this.onGround = reader.readBoolean(); this.onGround = reader.readBoolean();

View File

@ -1,7 +1,7 @@
package net.minestom.server.network.packet.client.play; package net.minestom.server.network.packet.client.play;
import net.minestom.server.network.packet.PacketReader;
import net.minestom.server.network.packet.client.ClientPlayPacket; import net.minestom.server.network.packet.client.ClientPlayPacket;
import net.minestom.server.utils.binary.BinaryReader;
public class ClientPluginMessagePacket extends ClientPlayPacket { public class ClientPluginMessagePacket extends ClientPlayPacket {
@ -9,7 +9,7 @@ public class ClientPluginMessagePacket extends ClientPlayPacket {
public byte[] data; public byte[] data;
@Override @Override
public void read(PacketReader reader) { public void read(BinaryReader reader) {
this.channel = reader.readSizedString(); this.channel = reader.readSizedString();
this.data = reader.getRemainingBytes(); this.data = reader.getRemainingBytes();
} }

View File

@ -1,7 +1,7 @@
package net.minestom.server.network.packet.client.play; package net.minestom.server.network.packet.client.play;
import net.minestom.server.network.packet.PacketReader;
import net.minestom.server.network.packet.client.ClientPlayPacket; import net.minestom.server.network.packet.client.ClientPlayPacket;
import net.minestom.server.utils.binary.BinaryReader;
public class ClientRecipeBookData extends ClientPlayPacket { public class ClientRecipeBookData extends ClientPlayPacket {
@ -19,7 +19,7 @@ public class ClientRecipeBookData extends ClientPlayPacket {
public boolean smokingRecipeFilterActive; public boolean smokingRecipeFilterActive;
@Override @Override
public void read(PacketReader reader) { public void read(BinaryReader reader) {
this.type = reader.readVarInt(); this.type = reader.readVarInt();
switch (type) { switch (type) {

View File

@ -1,15 +1,15 @@
package net.minestom.server.network.packet.client.play; package net.minestom.server.network.packet.client.play;
import net.minestom.server.network.packet.PacketReader;
import net.minestom.server.network.packet.client.ClientPlayPacket; import net.minestom.server.network.packet.client.ClientPlayPacket;
import net.minestom.server.resourcepack.ResourcePackStatus; import net.minestom.server.resourcepack.ResourcePackStatus;
import net.minestom.server.utils.binary.BinaryReader;
public class ClientResourcePackStatusPacket extends ClientPlayPacket { public class ClientResourcePackStatusPacket extends ClientPlayPacket {
public ResourcePackStatus result; public ResourcePackStatus result;
@Override @Override
public void read(PacketReader reader) { public void read(BinaryReader reader) {
this.result = ResourcePackStatus.values()[reader.readVarInt()]; this.result = ResourcePackStatus.values()[reader.readVarInt()];
} }

View File

@ -1,14 +1,14 @@
package net.minestom.server.network.packet.client.play; package net.minestom.server.network.packet.client.play;
import net.minestom.server.network.packet.PacketReader;
import net.minestom.server.network.packet.client.ClientPlayPacket; import net.minestom.server.network.packet.client.ClientPlayPacket;
import net.minestom.server.utils.binary.BinaryReader;
public class ClientSelectTradePacket extends ClientPlayPacket { public class ClientSelectTradePacket extends ClientPlayPacket {
public int selectedSlot; public int selectedSlot;
@Override @Override
public void read(PacketReader reader) { public void read(BinaryReader reader) {
this.selectedSlot = reader.readVarInt(); this.selectedSlot = reader.readVarInt();
} }
} }

View File

@ -1,8 +1,8 @@
package net.minestom.server.network.packet.client.play; package net.minestom.server.network.packet.client.play;
import net.minestom.server.entity.Player; import net.minestom.server.entity.Player;
import net.minestom.server.network.packet.PacketReader;
import net.minestom.server.network.packet.client.ClientPlayPacket; import net.minestom.server.network.packet.client.ClientPlayPacket;
import net.minestom.server.utils.binary.BinaryReader;
public class ClientSettingsPacket extends ClientPlayPacket { public class ClientSettingsPacket extends ClientPlayPacket {
@ -14,7 +14,7 @@ public class ClientSettingsPacket extends ClientPlayPacket {
public Player.MainHand mainHand; public Player.MainHand mainHand;
@Override @Override
public void read(PacketReader reader) { public void read(BinaryReader reader) {
this.locale = reader.readSizedString(); this.locale = reader.readSizedString();
this.viewDistance = reader.readByte(); this.viewDistance = reader.readByte();
this.chatMode = Player.ChatMode.values()[reader.readVarInt()]; this.chatMode = Player.ChatMode.values()[reader.readVarInt()];

View File

@ -1,7 +1,7 @@
package net.minestom.server.network.packet.client.play; package net.minestom.server.network.packet.client.play;
import net.minestom.server.network.packet.PacketReader;
import net.minestom.server.network.packet.client.ClientPlayPacket; import net.minestom.server.network.packet.client.ClientPlayPacket;
import net.minestom.server.utils.binary.BinaryReader;
import java.util.UUID; import java.util.UUID;
@ -10,7 +10,7 @@ public class ClientSpectatePacket extends ClientPlayPacket {
public UUID targetUuid; public UUID targetUuid;
@Override @Override
public void read(PacketReader reader) { public void read(BinaryReader reader) {
// TODO reader uuid // TODO reader uuid
} }
} }

View File

@ -1,14 +1,14 @@
package net.minestom.server.network.packet.client.play; package net.minestom.server.network.packet.client.play;
import net.minestom.server.network.packet.PacketReader;
import net.minestom.server.network.packet.client.ClientPlayPacket; import net.minestom.server.network.packet.client.ClientPlayPacket;
import net.minestom.server.utils.binary.BinaryReader;
public class ClientStatusPacket extends ClientPlayPacket { public class ClientStatusPacket extends ClientPlayPacket {
public Action action; public Action action;
@Override @Override
public void read(PacketReader reader) { public void read(BinaryReader reader) {
this.action = Action.values()[reader.readVarInt()]; this.action = Action.values()[reader.readVarInt()];
} }

View File

@ -1,7 +1,7 @@
package net.minestom.server.network.packet.client.play; package net.minestom.server.network.packet.client.play;
import net.minestom.server.network.packet.PacketReader;
import net.minestom.server.network.packet.client.ClientPlayPacket; import net.minestom.server.network.packet.client.ClientPlayPacket;
import net.minestom.server.utils.binary.BinaryReader;
public class ClientSteerBoatPacket extends ClientPlayPacket { public class ClientSteerBoatPacket extends ClientPlayPacket {
@ -9,7 +9,7 @@ public class ClientSteerBoatPacket extends ClientPlayPacket {
public boolean rightPaddleTurning; public boolean rightPaddleTurning;
@Override @Override
public void read(PacketReader reader) { public void read(BinaryReader reader) {
this.leftPaddleTurning = reader.readBoolean(); this.leftPaddleTurning = reader.readBoolean();
this.rightPaddleTurning = reader.readBoolean(); this.rightPaddleTurning = reader.readBoolean();
} }

View File

@ -1,7 +1,7 @@
package net.minestom.server.network.packet.client.play; package net.minestom.server.network.packet.client.play;
import net.minestom.server.network.packet.PacketReader;
import net.minestom.server.network.packet.client.ClientPlayPacket; import net.minestom.server.network.packet.client.ClientPlayPacket;
import net.minestom.server.utils.binary.BinaryReader;
public class ClientSteerVehiclePacket extends ClientPlayPacket { public class ClientSteerVehiclePacket extends ClientPlayPacket {
@ -10,7 +10,7 @@ public class ClientSteerVehiclePacket extends ClientPlayPacket {
public byte flags; public byte flags;
@Override @Override
public void read(PacketReader reader) { public void read(BinaryReader reader) {
this.sideways = reader.readFloat(); this.sideways = reader.readFloat();
this.forward = reader.readFloat(); this.forward = reader.readFloat();
this.flags = reader.readByte(); this.flags = reader.readByte();

View File

@ -1,7 +1,7 @@
package net.minestom.server.network.packet.client.play; package net.minestom.server.network.packet.client.play;
import net.minestom.server.network.packet.PacketReader;
import net.minestom.server.network.packet.client.ClientPlayPacket; import net.minestom.server.network.packet.client.ClientPlayPacket;
import net.minestom.server.utils.binary.BinaryReader;
public class ClientTabCompletePacket extends ClientPlayPacket { public class ClientTabCompletePacket extends ClientPlayPacket {
@ -9,7 +9,7 @@ public class ClientTabCompletePacket extends ClientPlayPacket {
public String text; public String text;
@Override @Override
public void read(PacketReader reader) { public void read(BinaryReader reader) {
this.transactionId = reader.readVarInt(); this.transactionId = reader.readVarInt();
this.text = reader.readSizedString(); this.text = reader.readSizedString();
} }

View File

@ -1,14 +1,14 @@
package net.minestom.server.network.packet.client.play; package net.minestom.server.network.packet.client.play;
import net.minestom.server.network.packet.PacketReader;
import net.minestom.server.network.packet.client.ClientPlayPacket; import net.minestom.server.network.packet.client.ClientPlayPacket;
import net.minestom.server.utils.binary.BinaryReader;
public class ClientTeleportConfirmPacket extends ClientPlayPacket { public class ClientTeleportConfirmPacket extends ClientPlayPacket {
public int teleportId; public int teleportId;
@Override @Override
public void read(PacketReader reader) { public void read(BinaryReader reader) {
this.teleportId = reader.readVarInt(); this.teleportId = reader.readVarInt();
} }
} }

View File

@ -1,7 +1,7 @@
package net.minestom.server.network.packet.client.play; package net.minestom.server.network.packet.client.play;
import net.minestom.server.network.packet.PacketReader;
import net.minestom.server.network.packet.client.ClientPlayPacket; import net.minestom.server.network.packet.client.ClientPlayPacket;
import net.minestom.server.utils.binary.BinaryReader;
public class ClientUpdateCommandBlockMinecartPacket extends ClientPlayPacket { public class ClientUpdateCommandBlockMinecartPacket extends ClientPlayPacket {
@ -10,7 +10,7 @@ public class ClientUpdateCommandBlockMinecartPacket extends ClientPlayPacket {
public boolean trackOutput; public boolean trackOutput;
@Override @Override
public void read(PacketReader reader) { public void read(BinaryReader reader) {
this.entityId = reader.readVarInt(); this.entityId = reader.readVarInt();
this.command = reader.readSizedString(); this.command = reader.readSizedString();
this.trackOutput = reader.readBoolean(); this.trackOutput = reader.readBoolean();

View File

@ -1,8 +1,8 @@
package net.minestom.server.network.packet.client.play; package net.minestom.server.network.packet.client.play;
import net.minestom.server.network.packet.PacketReader;
import net.minestom.server.network.packet.client.ClientPlayPacket; import net.minestom.server.network.packet.client.ClientPlayPacket;
import net.minestom.server.utils.BlockPosition; import net.minestom.server.utils.BlockPosition;
import net.minestom.server.utils.binary.BinaryReader;
public class ClientUpdateCommandBlockPacket extends ClientPlayPacket { public class ClientUpdateCommandBlockPacket extends ClientPlayPacket {
@ -12,7 +12,7 @@ public class ClientUpdateCommandBlockPacket extends ClientPlayPacket {
public byte flags; public byte flags;
@Override @Override
public void read(PacketReader reader) { public void read(BinaryReader reader) {
this.blockPosition = reader.readBlockPosition(); this.blockPosition = reader.readBlockPosition();
this.command = reader.readSizedString(); this.command = reader.readSizedString();
this.mode = Mode.values()[reader.readVarInt()]; this.mode = Mode.values()[reader.readVarInt()];

View File

@ -1,8 +1,8 @@
package net.minestom.server.network.packet.client.play; package net.minestom.server.network.packet.client.play;
import net.minestom.server.network.packet.PacketReader;
import net.minestom.server.network.packet.client.ClientPlayPacket; import net.minestom.server.network.packet.client.ClientPlayPacket;
import net.minestom.server.utils.BlockPosition; import net.minestom.server.utils.BlockPosition;
import net.minestom.server.utils.binary.BinaryReader;
public class ClientUpdateSignPacket extends ClientPlayPacket { public class ClientUpdateSignPacket extends ClientPlayPacket {
@ -13,7 +13,7 @@ public class ClientUpdateSignPacket extends ClientPlayPacket {
public String line4; public String line4;
@Override @Override
public void read(PacketReader reader) { public void read(BinaryReader reader) {
this.blockPosition = reader.readBlockPosition(); this.blockPosition = reader.readBlockPosition();
this.line1 = reader.readSizedString(); this.line1 = reader.readSizedString();
this.line2 = reader.readSizedString(); this.line2 = reader.readSizedString();

View File

@ -1,15 +1,15 @@
package net.minestom.server.network.packet.client.play; package net.minestom.server.network.packet.client.play;
import net.minestom.server.entity.Player; import net.minestom.server.entity.Player;
import net.minestom.server.network.packet.PacketReader;
import net.minestom.server.network.packet.client.ClientPlayPacket; import net.minestom.server.network.packet.client.ClientPlayPacket;
import net.minestom.server.utils.binary.BinaryReader;
public class ClientUseItemPacket extends ClientPlayPacket { public class ClientUseItemPacket extends ClientPlayPacket {
public Player.Hand hand; public Player.Hand hand;
@Override @Override
public void read(PacketReader reader) { public void read(BinaryReader reader) {
this.hand = Player.Hand.values()[reader.readVarInt()]; this.hand = Player.Hand.values()[reader.readVarInt()];
} }
} }

Some files were not shown because too many files have changed in this diff Show More