mirror of
https://github.com/Minestom/Minestom.git
synced 2024-11-17 16:15:32 +01:00
Renamed PacketWriter/Reader to BinaryWriter/Reader + optimization to serializing
This commit is contained in:
parent
65db4a48b4
commit
571bb7a866
@ -1,6 +1,6 @@
|
||||
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.NoiseTestGenerator;
|
||||
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.chat.ChatColor;
|
||||
import net.minestom.server.chat.ColoredText;
|
||||
import net.minestom.server.data.Data;
|
||||
import net.minestom.server.entity.*;
|
||||
import net.minestom.server.entity.damage.DamageType;
|
||||
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.WorldBorder;
|
||||
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.InventoryType;
|
||||
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.ping.ResponseDataConsumer;
|
||||
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.Position;
|
||||
import net.minestom.server.utils.Vector;
|
||||
import net.minestom.server.utils.time.TimeUnit;
|
||||
import net.minestom.server.world.DimensionType;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
@ -44,11 +48,11 @@ public class PlayerInit {
|
||||
private static volatile Inventory inventory;
|
||||
|
||||
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();
|
||||
NoiseTestGenerator noiseTestGenerator = new NoiseTestGenerator();
|
||||
//instanceContainer = MinecraftServer.getInstanceManager().createInstanceContainer(storageFolder);
|
||||
instanceContainer = MinecraftServer.getInstanceManager().createInstanceContainer(DimensionType.OVERWORLD);
|
||||
instanceContainer = MinecraftServer.getInstanceManager().createInstanceContainer(storageFolder);
|
||||
//instanceContainer = MinecraftServer.getInstanceManager().createInstanceContainer(DimensionType.OVERWORLD);
|
||||
instanceContainer.enableAutoChunkLoad(true);
|
||||
//instanceContainer.setChunkDecider((x,y) -> (pos) -> pos.getY()>40?(short)0:(short)1);
|
||||
instanceContainer.setChunkGenerator(noiseTestGenerator);
|
||||
@ -153,10 +157,10 @@ public class PlayerInit {
|
||||
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.setInstance(player.getInstance());
|
||||
}
|
||||
}*/
|
||||
|
||||
/*EntityZombie zombie = new EntityZombie(player.getPosition());
|
||||
zombie.setAttribute(Attribute.MOVEMENT_SPEED, 0.25f);
|
||||
@ -183,6 +187,17 @@ public class PlayerInit {
|
||||
if (event.getHand() != Player.Hand.MAIN)
|
||||
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 Block block = Block.fromStateId(blockStateId);
|
||||
player.sendMessage("You clicked at the block " + block);
|
||||
|
@ -67,6 +67,8 @@ public class SimpleCommand implements CommandProcessor {
|
||||
NotificationCenter.send(notification, player);
|
||||
NotificationCenter.send(notification, player);
|
||||
|
||||
player.getInstance().saveChunksToStorageFolder(() -> System.out.println("end save"));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -3,12 +3,12 @@ package fr.themode.demo.generator;
|
||||
import de.articdive.jnoise.JNoise;
|
||||
import de.articdive.jnoise.interpolation.InterpolationType;
|
||||
import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.world.biomes.Biome;
|
||||
import net.minestom.server.instance.Chunk;
|
||||
import net.minestom.server.instance.ChunkGenerator;
|
||||
import net.minestom.server.instance.ChunkPopulator;
|
||||
import net.minestom.server.instance.batch.ChunkBatch;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import net.minestom.server.world.biomes.Biome;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@ -28,7 +28,7 @@ public class NoiseTestGenerator extends ChunkGenerator {
|
||||
if (random.nextInt(100) > 10) {
|
||||
batch.setBlock(x, y, z, Block.DIAMOND_BLOCK);
|
||||
} else {
|
||||
batch.setBlock(x, y, z, Block.GOLD_BLOCK);
|
||||
batch.setCustomBlock(x, y, z, "custom_block");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -79,7 +79,8 @@ public final class DataManager {
|
||||
* @throws NullPointerException if none is found
|
||||
*/
|
||||
public <T> DataType<T> getDataType(Class<T> clazz) {
|
||||
return dataTypeMap.get(PrimitiveConversion.getObjectClass(clazz));
|
||||
clazz = PrimitiveConversion.getObjectClass(clazz);
|
||||
return dataTypeMap.get(clazz);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,24 +1,24 @@
|
||||
package net.minestom.server.data;
|
||||
|
||||
import net.minestom.server.network.packet.PacketReader;
|
||||
import net.minestom.server.network.packet.PacketWriter;
|
||||
import net.minestom.server.utils.binary.BinaryReader;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
|
||||
public abstract class DataType<T> {
|
||||
|
||||
/**
|
||||
* Encode the data type
|
||||
*
|
||||
* @param packetWriter the data writer
|
||||
* @param writer the data writer
|
||||
* @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
|
||||
*
|
||||
* @param packetReader the data reader
|
||||
* @param reader the data reader
|
||||
* @return the decoded value
|
||||
*/
|
||||
public abstract T decode(PacketReader packetReader);
|
||||
public abstract T decode(BinaryReader reader);
|
||||
|
||||
}
|
@ -1,13 +1,9 @@
|
||||
package net.minestom.server.data;
|
||||
|
||||
import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.network.packet.PacketWriter;
|
||||
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;
|
||||
|
||||
public class SerializableData extends Data {
|
||||
@ -52,36 +48,28 @@ public class SerializableData extends Data {
|
||||
* to convert it back
|
||||
*
|
||||
* @return the array representation of this data object
|
||||
* @throws IOException if an error occur when serializing the data
|
||||
*/
|
||||
public byte[] getSerializedData() throws IOException {
|
||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||
DataOutputStream dos = new DataOutputStream(output);
|
||||
public byte[] getSerializedData() {
|
||||
BinaryWriter binaryWriter = new BinaryWriter();
|
||||
|
||||
for (Map.Entry<String, Object> entry : data.entrySet()) {
|
||||
final String key = entry.getKey();
|
||||
data.forEach((key, value) -> {
|
||||
final Class type = dataType.get(key);
|
||||
final Object value = entry.getValue();
|
||||
final DataType dataType = DATA_MANAGER.getDataType(type);
|
||||
|
||||
final byte[] encodedType = PrimitiveConversion.getObjectClassString(type.getName()).getBytes(); // Data type (fix for primitives)
|
||||
dos.writeShort(encodedType.length);
|
||||
dos.write(encodedType);
|
||||
// Write the data type
|
||||
final String encodedType = PrimitiveConversion.getObjectClassString(type.getName()); // Data type (fix for primitives)
|
||||
binaryWriter.writeSizedString(encodedType);
|
||||
|
||||
final byte[] encodedName = key.getBytes(); // Data name
|
||||
dos.writeShort(encodedName.length);
|
||||
dos.write(encodedName);
|
||||
// Write the data key
|
||||
binaryWriter.writeSizedString(key);
|
||||
|
||||
PacketWriter packetWriter = new PacketWriter();
|
||||
dataType.encode(packetWriter, value); // Encode
|
||||
final byte[] encodedValue = packetWriter.toByteArray(); // Retrieve bytes
|
||||
dos.writeInt(encodedValue.length);
|
||||
dos.write(encodedValue);
|
||||
}
|
||||
// Write the data (no length)
|
||||
dataType.encode(binaryWriter, value);
|
||||
});
|
||||
|
||||
dos.writeShort(0xff); // End of data object
|
||||
binaryWriter.writeVarInt(0); // End of data object
|
||||
|
||||
return output.toByteArray();
|
||||
return binaryWriter.toByteArray();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,17 +1,17 @@
|
||||
package net.minestom.server.data.type;
|
||||
|
||||
import net.minestom.server.data.DataType;
|
||||
import net.minestom.server.network.packet.PacketReader;
|
||||
import net.minestom.server.network.packet.PacketWriter;
|
||||
import net.minestom.server.utils.binary.BinaryReader;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
|
||||
public class BooleanData extends DataType<Boolean> {
|
||||
@Override
|
||||
public void encode(PacketWriter packetWriter, Boolean value) {
|
||||
packetWriter.writeBoolean(value);
|
||||
public void encode(BinaryWriter binaryWriter, Boolean value) {
|
||||
binaryWriter.writeBoolean(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean decode(PacketReader packetReader) {
|
||||
return packetReader.readBoolean();
|
||||
public Boolean decode(BinaryReader binaryReader) {
|
||||
return binaryReader.readBoolean();
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,17 @@
|
||||
package net.minestom.server.data.type;
|
||||
|
||||
import net.minestom.server.data.DataType;
|
||||
import net.minestom.server.network.packet.PacketReader;
|
||||
import net.minestom.server.network.packet.PacketWriter;
|
||||
import net.minestom.server.utils.binary.BinaryReader;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
|
||||
public class ByteData extends DataType<Byte> {
|
||||
@Override
|
||||
public void encode(PacketWriter packetWriter, Byte value) {
|
||||
packetWriter.writeByte(value);
|
||||
public void encode(BinaryWriter binaryWriter, Byte value) {
|
||||
binaryWriter.writeByte(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Byte decode(PacketReader packetReader) {
|
||||
return packetReader.readByte();
|
||||
public Byte decode(BinaryReader binaryReader) {
|
||||
return binaryReader.readByte();
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,18 @@
|
||||
package net.minestom.server.data.type;
|
||||
|
||||
import net.minestom.server.data.DataType;
|
||||
import net.minestom.server.network.packet.PacketReader;
|
||||
import net.minestom.server.network.packet.PacketWriter;
|
||||
import net.minestom.server.utils.binary.BinaryReader;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
|
||||
public class CharacterData extends DataType<Character> {
|
||||
|
||||
@Override
|
||||
public void encode(PacketWriter packetWriter, Character value) {
|
||||
packetWriter.writeChar(value);
|
||||
public void encode(BinaryWriter binaryWriter, Character value) {
|
||||
binaryWriter.writeChar(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Character decode(PacketReader packetReader) {
|
||||
return packetReader.readChar();
|
||||
public Character decode(BinaryReader binaryReader) {
|
||||
return binaryReader.readChar();
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,18 @@
|
||||
package net.minestom.server.data.type;
|
||||
|
||||
import net.minestom.server.data.DataType;
|
||||
import net.minestom.server.network.packet.PacketReader;
|
||||
import net.minestom.server.network.packet.PacketWriter;
|
||||
import net.minestom.server.utils.binary.BinaryReader;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
|
||||
public class DoubleData extends DataType<Double> {
|
||||
|
||||
@Override
|
||||
public void encode(PacketWriter packetWriter, Double value) {
|
||||
packetWriter.writeDouble(value);
|
||||
public void encode(BinaryWriter binaryWriter, Double value) {
|
||||
binaryWriter.writeDouble(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double decode(PacketReader packetReader) {
|
||||
return packetReader.readDouble();
|
||||
public Double decode(BinaryReader binaryReader) {
|
||||
return binaryReader.readDouble();
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,18 @@
|
||||
package net.minestom.server.data.type;
|
||||
|
||||
import net.minestom.server.data.DataType;
|
||||
import net.minestom.server.network.packet.PacketReader;
|
||||
import net.minestom.server.network.packet.PacketWriter;
|
||||
import net.minestom.server.utils.binary.BinaryReader;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
|
||||
public class FloatData extends DataType<Float> {
|
||||
|
||||
@Override
|
||||
public void encode(PacketWriter packetWriter, Float value) {
|
||||
packetWriter.writeFloat(value);
|
||||
public void encode(BinaryWriter binaryWriter, Float value) {
|
||||
binaryWriter.writeFloat(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Float decode(PacketReader packetReader) {
|
||||
return packetReader.readFloat();
|
||||
public Float decode(BinaryReader binaryReader) {
|
||||
return binaryReader.readFloat();
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,18 @@
|
||||
package net.minestom.server.data.type;
|
||||
|
||||
import net.minestom.server.data.DataType;
|
||||
import net.minestom.server.network.packet.PacketReader;
|
||||
import net.minestom.server.network.packet.PacketWriter;
|
||||
import net.minestom.server.utils.binary.BinaryReader;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
|
||||
public class IntegerData extends DataType<Integer> {
|
||||
|
||||
@Override
|
||||
public void encode(PacketWriter packetWriter, Integer value) {
|
||||
packetWriter.writeVarInt(value);
|
||||
public void encode(BinaryWriter binaryWriter, Integer value) {
|
||||
binaryWriter.writeVarInt(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer decode(PacketReader packetReader) {
|
||||
return packetReader.readVarInt();
|
||||
public Integer decode(BinaryReader binaryReader) {
|
||||
return binaryReader.readVarInt();
|
||||
}
|
||||
}
|
@ -3,37 +3,37 @@ package net.minestom.server.data.type;
|
||||
import net.minestom.server.data.DataType;
|
||||
import net.minestom.server.inventory.Inventory;
|
||||
import net.minestom.server.inventory.InventoryType;
|
||||
import net.minestom.server.network.packet.PacketReader;
|
||||
import net.minestom.server.network.packet.PacketWriter;
|
||||
import net.minestom.server.utils.binary.BinaryReader;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
|
||||
public class InventoryData extends DataType<Inventory> {
|
||||
|
||||
@Override
|
||||
public void encode(PacketWriter packetWriter, Inventory value) {
|
||||
public void encode(BinaryWriter binaryWriter, Inventory value) {
|
||||
final InventoryType inventoryType = value.getInventoryType();
|
||||
final int size = inventoryType.getAdditionalSlot();
|
||||
|
||||
// Inventory title & type
|
||||
packetWriter.writeSizedString(value.getTitle());
|
||||
packetWriter.writeSizedString(inventoryType.name());
|
||||
binaryWriter.writeSizedString(value.getTitle());
|
||||
binaryWriter.writeSizedString(inventoryType.name());
|
||||
|
||||
// Write all item stacks
|
||||
for (int i = 0; i < size; i++) {
|
||||
packetWriter.writeItemStack(value.getItemStack(i));
|
||||
binaryWriter.writeItemStack(value.getItemStack(i));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventory decode(PacketReader packetReader) {
|
||||
final String title = packetReader.readSizedString();
|
||||
final InventoryType inventoryType = InventoryType.valueOf(packetReader.readSizedString());
|
||||
public Inventory decode(BinaryReader binaryReader) {
|
||||
final String title = binaryReader.readSizedString();
|
||||
final InventoryType inventoryType = InventoryType.valueOf(binaryReader.readSizedString());
|
||||
final int size = inventoryType.getAdditionalSlot();
|
||||
|
||||
Inventory inventory = new Inventory(inventoryType, title);
|
||||
|
||||
// Read all item stacks
|
||||
for (int i = 0; i < size; i++) {
|
||||
inventory.setItemStack(i, packetReader.readSlot());
|
||||
inventory.setItemStack(i, binaryReader.readSlot());
|
||||
}
|
||||
|
||||
return inventory;
|
||||
|
@ -2,17 +2,17 @@ package net.minestom.server.data.type;
|
||||
|
||||
import net.minestom.server.data.DataType;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import net.minestom.server.network.packet.PacketReader;
|
||||
import net.minestom.server.network.packet.PacketWriter;
|
||||
import net.minestom.server.utils.binary.BinaryReader;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
|
||||
public class ItemStackData extends DataType<ItemStack> {
|
||||
@Override
|
||||
public void encode(PacketWriter packetWriter, ItemStack value) {
|
||||
packetWriter.writeItemStack(value);
|
||||
public void encode(BinaryWriter binaryWriter, ItemStack value) {
|
||||
binaryWriter.writeItemStack(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decode(PacketReader packetReader) {
|
||||
return packetReader.readSlot();
|
||||
public ItemStack decode(BinaryReader binaryReader) {
|
||||
return binaryReader.readSlot();
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,17 @@
|
||||
package net.minestom.server.data.type;
|
||||
|
||||
import net.minestom.server.data.DataType;
|
||||
import net.minestom.server.network.packet.PacketReader;
|
||||
import net.minestom.server.network.packet.PacketWriter;
|
||||
import net.minestom.server.utils.binary.BinaryReader;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
|
||||
public class LongData extends DataType<Long> {
|
||||
@Override
|
||||
public void encode(PacketWriter packetWriter, Long value) {
|
||||
packetWriter.writeLong(value);
|
||||
public void encode(BinaryWriter binaryWriter, Long value) {
|
||||
binaryWriter.writeLong(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long decode(PacketReader packetReader) {
|
||||
return packetReader.readLong();
|
||||
public Long decode(BinaryReader binaryReader) {
|
||||
return binaryReader.readLong();
|
||||
}
|
||||
}
|
||||
|
@ -2,27 +2,20 @@ package net.minestom.server.data.type;
|
||||
|
||||
import net.minestom.server.data.DataType;
|
||||
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 java.io.IOException;
|
||||
import net.minestom.server.utils.binary.BinaryReader;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
|
||||
// Pretty weird name huh?
|
||||
public class SerializableDataData extends DataType<SerializableData> {
|
||||
|
||||
@Override
|
||||
public void encode(PacketWriter packetWriter, SerializableData value) {
|
||||
try {
|
||||
packetWriter.writeBytes(value.getSerializedData());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
throw new IllegalArgumentException("error while writing the data");
|
||||
}
|
||||
public void encode(BinaryWriter binaryWriter, SerializableData value) {
|
||||
binaryWriter.writeBytes(value.getSerializedData());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SerializableData decode(PacketReader packetReader) {
|
||||
return DataReader.readData(packetReader.getBuffer());
|
||||
public SerializableData decode(BinaryReader binaryReader) {
|
||||
return DataReader.readData(binaryReader);
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,18 @@
|
||||
package net.minestom.server.data.type;
|
||||
|
||||
import net.minestom.server.data.DataType;
|
||||
import net.minestom.server.network.packet.PacketReader;
|
||||
import net.minestom.server.network.packet.PacketWriter;
|
||||
import net.minestom.server.utils.binary.BinaryReader;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
|
||||
public class ShortData extends DataType<Short> {
|
||||
|
||||
@Override
|
||||
public void encode(PacketWriter packetWriter, Short value) {
|
||||
packetWriter.writeShort(value);
|
||||
public void encode(BinaryWriter binaryWriter, Short value) {
|
||||
binaryWriter.writeShort(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Short decode(PacketReader packetReader) {
|
||||
return packetReader.readShort();
|
||||
public Short decode(BinaryReader binaryReader) {
|
||||
return binaryReader.readShort();
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,18 @@
|
||||
package net.minestom.server.data.type;
|
||||
|
||||
import net.minestom.server.data.DataType;
|
||||
import net.minestom.server.network.packet.PacketReader;
|
||||
import net.minestom.server.network.packet.PacketWriter;
|
||||
import net.minestom.server.utils.binary.BinaryReader;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
|
||||
public class StringData extends DataType<String> {
|
||||
|
||||
@Override
|
||||
public void encode(PacketWriter packetWriter, String value) {
|
||||
packetWriter.writeSizedString(value);
|
||||
public void encode(BinaryWriter binaryWriter, String value) {
|
||||
binaryWriter.writeSizedString(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String decode(PacketReader packetReader) {
|
||||
return packetReader.readSizedString();
|
||||
public String decode(BinaryReader binaryReader) {
|
||||
return binaryReader.readSizedString();
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +1,19 @@
|
||||
package net.minestom.server.data.type;
|
||||
|
||||
import net.minestom.server.data.DataType;
|
||||
import net.minestom.server.network.packet.PacketReader;
|
||||
import net.minestom.server.network.packet.PacketWriter;
|
||||
import net.minestom.server.utils.binary.BinaryReader;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class UuidType extends DataType<UUID> {
|
||||
@Override
|
||||
public void encode(PacketWriter packetWriter, UUID value) {
|
||||
packetWriter.writeUuid(value);
|
||||
public void encode(BinaryWriter binaryWriter, UUID value) {
|
||||
binaryWriter.writeUuid(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID decode(PacketReader packetReader) {
|
||||
return packetReader.readUuid();
|
||||
public UUID decode(BinaryReader binaryReader) {
|
||||
return binaryReader.readUuid();
|
||||
}
|
||||
}
|
||||
|
@ -1,24 +1,24 @@
|
||||
package net.minestom.server.data.type.array;
|
||||
|
||||
import net.minestom.server.data.DataType;
|
||||
import net.minestom.server.network.packet.PacketReader;
|
||||
import net.minestom.server.network.packet.PacketWriter;
|
||||
import net.minestom.server.utils.binary.BinaryReader;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
|
||||
public class BooleanArrayData extends DataType<boolean[]> {
|
||||
|
||||
@Override
|
||||
public void encode(PacketWriter packetWriter, boolean[] value) {
|
||||
packetWriter.writeVarInt(value.length);
|
||||
public void encode(BinaryWriter binaryWriter, boolean[] value) {
|
||||
binaryWriter.writeVarInt(value.length);
|
||||
for (boolean val : value) {
|
||||
packetWriter.writeBoolean(val);
|
||||
binaryWriter.writeBoolean(val);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean[] decode(PacketReader packetReader) {
|
||||
boolean[] array = new boolean[packetReader.readVarInt()];
|
||||
public boolean[] decode(BinaryReader binaryReader) {
|
||||
boolean[] array = new boolean[binaryReader.readVarInt()];
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
array[i] = packetReader.readBoolean();
|
||||
array[i] = binaryReader.readBoolean();
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
@ -1,31 +1,31 @@
|
||||
package net.minestom.server.data.type.array;
|
||||
|
||||
import net.minestom.server.data.DataType;
|
||||
import net.minestom.server.network.packet.PacketReader;
|
||||
import net.minestom.server.network.packet.PacketWriter;
|
||||
import net.minestom.server.utils.binary.BinaryReader;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
|
||||
public class ByteArrayData extends DataType<byte[]> {
|
||||
@Override
|
||||
public void encode(PacketWriter packetWriter, byte[] value) {
|
||||
encodeByteArray(packetWriter, value);
|
||||
public void encode(BinaryWriter binaryWriter, byte[] value) {
|
||||
encodeByteArray(binaryWriter, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] decode(PacketReader packetReader) {
|
||||
return decodeByteArray(packetReader);
|
||||
public byte[] decode(BinaryReader binaryReader) {
|
||||
return decodeByteArray(binaryReader);
|
||||
}
|
||||
|
||||
public static void encodeByteArray(PacketWriter packetWriter, byte[] value) {
|
||||
packetWriter.writeVarInt(value.length);
|
||||
public static void encodeByteArray(BinaryWriter binaryWriter, byte[] value) {
|
||||
binaryWriter.writeVarInt(value.length);
|
||||
for (byte val : value) {
|
||||
packetWriter.writeByte(val);
|
||||
binaryWriter.writeByte(val);
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] decodeByteArray(PacketReader packetReader) {
|
||||
byte[] array = new byte[packetReader.readVarInt()];
|
||||
public static byte[] decodeByteArray(BinaryReader binaryReader) {
|
||||
byte[] array = new byte[binaryReader.readVarInt()];
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
array[i] = packetReader.readByte();
|
||||
array[i] = binaryReader.readByte();
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
@ -1,23 +1,23 @@
|
||||
package net.minestom.server.data.type.array;
|
||||
|
||||
import net.minestom.server.data.DataType;
|
||||
import net.minestom.server.network.packet.PacketReader;
|
||||
import net.minestom.server.network.packet.PacketWriter;
|
||||
import net.minestom.server.utils.binary.BinaryReader;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
|
||||
public class CharacterArrayData extends DataType<char[]> {
|
||||
@Override
|
||||
public void encode(PacketWriter packetWriter, char[] value) {
|
||||
packetWriter.writeVarInt(value.length);
|
||||
public void encode(BinaryWriter binaryWriter, char[] value) {
|
||||
binaryWriter.writeVarInt(value.length);
|
||||
for (char val : value) {
|
||||
packetWriter.writeChar(val);
|
||||
binaryWriter.writeChar(val);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] decode(PacketReader packetReader) {
|
||||
char[] array = new char[packetReader.readVarInt()];
|
||||
public char[] decode(BinaryReader binaryReader) {
|
||||
char[] array = new char[binaryReader.readVarInt()];
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
array[i] = packetReader.readChar();
|
||||
array[i] = binaryReader.readChar();
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
@ -1,24 +1,24 @@
|
||||
package net.minestom.server.data.type.array;
|
||||
|
||||
import net.minestom.server.data.DataType;
|
||||
import net.minestom.server.network.packet.PacketReader;
|
||||
import net.minestom.server.network.packet.PacketWriter;
|
||||
import net.minestom.server.utils.binary.BinaryReader;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
|
||||
public class DoubleArrayData extends DataType<double[]> {
|
||||
|
||||
@Override
|
||||
public void encode(PacketWriter packetWriter, double[] value) {
|
||||
packetWriter.writeVarInt(value.length);
|
||||
public void encode(BinaryWriter binaryWriter, double[] value) {
|
||||
binaryWriter.writeVarInt(value.length);
|
||||
for (double val : value) {
|
||||
packetWriter.writeDouble(val);
|
||||
binaryWriter.writeDouble(val);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double[] decode(PacketReader packetReader) {
|
||||
double[] array = new double[packetReader.readVarInt()];
|
||||
public double[] decode(BinaryReader binaryReader) {
|
||||
double[] array = new double[binaryReader.readVarInt()];
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
array[i] = packetReader.readDouble();
|
||||
array[i] = binaryReader.readDouble();
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
@ -1,24 +1,24 @@
|
||||
package net.minestom.server.data.type.array;
|
||||
|
||||
import net.minestom.server.data.DataType;
|
||||
import net.minestom.server.network.packet.PacketReader;
|
||||
import net.minestom.server.network.packet.PacketWriter;
|
||||
import net.minestom.server.utils.binary.BinaryReader;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
|
||||
public class FloatArrayData extends DataType<float[]> {
|
||||
|
||||
@Override
|
||||
public void encode(PacketWriter packetWriter, float[] value) {
|
||||
packetWriter.writeVarInt(value.length);
|
||||
public void encode(BinaryWriter binaryWriter, float[] value) {
|
||||
binaryWriter.writeVarInt(value.length);
|
||||
for (float val : value) {
|
||||
packetWriter.writeFloat(val);
|
||||
binaryWriter.writeFloat(val);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float[] decode(PacketReader packetReader) {
|
||||
float[] array = new float[packetReader.readVarInt()];
|
||||
public float[] decode(BinaryReader binaryReader) {
|
||||
float[] array = new float[binaryReader.readVarInt()];
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
array[i] = packetReader.readFloat();
|
||||
array[i] = binaryReader.readFloat();
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
@ -1,24 +1,24 @@
|
||||
package net.minestom.server.data.type.array;
|
||||
|
||||
import net.minestom.server.data.DataType;
|
||||
import net.minestom.server.network.packet.PacketReader;
|
||||
import net.minestom.server.network.packet.PacketWriter;
|
||||
import net.minestom.server.utils.binary.BinaryReader;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
|
||||
public class IntegerArrayData extends DataType<int[]> {
|
||||
|
||||
@Override
|
||||
public void encode(PacketWriter packetWriter, int[] value) {
|
||||
packetWriter.writeVarInt(value.length);
|
||||
public void encode(BinaryWriter binaryWriter, int[] value) {
|
||||
binaryWriter.writeVarInt(value.length);
|
||||
for (int val : value) {
|
||||
packetWriter.writeInt(val);
|
||||
binaryWriter.writeInt(val);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] decode(PacketReader packetReader) {
|
||||
int[] array = new int[packetReader.readVarInt()];
|
||||
public int[] decode(BinaryReader binaryReader) {
|
||||
int[] array = new int[binaryReader.readVarInt()];
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
array[i] = packetReader.readInteger();
|
||||
array[i] = binaryReader.readInteger();
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
@ -2,23 +2,23 @@ package net.minestom.server.data.type.array;
|
||||
|
||||
import net.minestom.server.data.DataType;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import net.minestom.server.network.packet.PacketReader;
|
||||
import net.minestom.server.network.packet.PacketWriter;
|
||||
import net.minestom.server.utils.binary.BinaryReader;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
|
||||
public class ItemStackArrayData extends DataType<ItemStack[]> {
|
||||
@Override
|
||||
public void encode(PacketWriter packetWriter, ItemStack[] value) {
|
||||
packetWriter.writeVarInt(value.length);
|
||||
public void encode(BinaryWriter binaryWriter, ItemStack[] value) {
|
||||
binaryWriter.writeVarInt(value.length);
|
||||
for (ItemStack itemStack : value) {
|
||||
packetWriter.writeItemStack(itemStack);
|
||||
binaryWriter.writeItemStack(itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] decode(PacketReader packetReader) {
|
||||
ItemStack[] items = new ItemStack[packetReader.readVarInt()];
|
||||
public ItemStack[] decode(BinaryReader binaryReader) {
|
||||
ItemStack[] items = new ItemStack[binaryReader.readVarInt()];
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
items[i] = packetReader.readSlot();
|
||||
items[i] = binaryReader.readSlot();
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
@ -1,24 +1,24 @@
|
||||
package net.minestom.server.data.type.array;
|
||||
|
||||
import net.minestom.server.data.DataType;
|
||||
import net.minestom.server.network.packet.PacketReader;
|
||||
import net.minestom.server.network.packet.PacketWriter;
|
||||
import net.minestom.server.utils.binary.BinaryReader;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
|
||||
public class LongArrayData extends DataType<long[]> {
|
||||
|
||||
@Override
|
||||
public void encode(PacketWriter packetWriter, long[] value) {
|
||||
packetWriter.writeVarInt(value.length);
|
||||
public void encode(BinaryWriter binaryWriter, long[] value) {
|
||||
binaryWriter.writeVarInt(value.length);
|
||||
for (long val : value) {
|
||||
packetWriter.writeLong(val);
|
||||
binaryWriter.writeLong(val);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long[] decode(PacketReader packetReader) {
|
||||
long[] array = new long[packetReader.readVarInt()];
|
||||
public long[] decode(BinaryReader binaryReader) {
|
||||
long[] array = new long[binaryReader.readVarInt()];
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
array[i] = packetReader.readLong();
|
||||
array[i] = binaryReader.readLong();
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
@ -1,24 +1,24 @@
|
||||
package net.minestom.server.data.type.array;
|
||||
|
||||
import net.minestom.server.data.DataType;
|
||||
import net.minestom.server.network.packet.PacketReader;
|
||||
import net.minestom.server.network.packet.PacketWriter;
|
||||
import net.minestom.server.utils.binary.BinaryReader;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
|
||||
public class ShortArrayData extends DataType<short[]> {
|
||||
|
||||
@Override
|
||||
public void encode(PacketWriter packetWriter, short[] value) {
|
||||
packetWriter.writeVarInt(value.length);
|
||||
public void encode(BinaryWriter binaryWriter, short[] value) {
|
||||
binaryWriter.writeVarInt(value.length);
|
||||
for (short val : value) {
|
||||
packetWriter.writeShort(val);
|
||||
binaryWriter.writeShort(val);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public short[] decode(PacketReader packetReader) {
|
||||
short[] array = new short[packetReader.readVarInt()];
|
||||
public short[] decode(BinaryReader binaryReader) {
|
||||
short[] array = new short[binaryReader.readVarInt()];
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
array[i] = packetReader.readShort();
|
||||
array[i] = binaryReader.readShort();
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
@ -1,24 +1,24 @@
|
||||
package net.minestom.server.data.type.array;
|
||||
|
||||
import net.minestom.server.data.DataType;
|
||||
import net.minestom.server.network.packet.PacketReader;
|
||||
import net.minestom.server.network.packet.PacketWriter;
|
||||
import net.minestom.server.utils.binary.BinaryReader;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
|
||||
public class StringArrayData extends DataType<String[]> {
|
||||
|
||||
@Override
|
||||
public void encode(PacketWriter packetWriter, String[] value) {
|
||||
packetWriter.writeVarInt(value.length);
|
||||
public void encode(BinaryWriter binaryWriter, String[] value) {
|
||||
binaryWriter.writeVarInt(value.length);
|
||||
for (String val : value) {
|
||||
packetWriter.writeSizedString(val);
|
||||
binaryWriter.writeSizedString(val);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] decode(PacketReader packetReader) {
|
||||
String[] array = new String[packetReader.readVarInt()];
|
||||
public String[] decode(BinaryReader binaryReader) {
|
||||
String[] array = new String[binaryReader.readVarInt()];
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
array[i] = packetReader.readSizedString();
|
||||
array[i] = binaryReader.readSizedString();
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
@ -19,12 +19,12 @@ import net.minestom.server.instance.Instance;
|
||||
import net.minestom.server.instance.InstanceManager;
|
||||
import net.minestom.server.instance.WorldBorder;
|
||||
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.utils.ArrayUtils;
|
||||
import net.minestom.server.utils.BlockPosition;
|
||||
import net.minestom.server.utils.Position;
|
||||
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.entity.EntityUtils;
|
||||
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()}
|
||||
*/
|
||||
public Consumer<PacketWriter> getMetadataConsumer() {
|
||||
public Consumer<BinaryWriter> getMetadataConsumer() {
|
||||
return packet -> {
|
||||
fillMetadataIndex(packet, 0);
|
||||
fillMetadataIndex(packet, 1);
|
||||
@ -1209,7 +1209,7 @@ public abstract class Entity implements Viewable, EventHandler, DataContainer {
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
@ -1229,7 +1229,7 @@ public abstract class Entity implements Viewable, EventHandler, DataContainer {
|
||||
* @param packet the packet writer
|
||||
* @param index the index to fill/write
|
||||
*/
|
||||
protected void fillMetadataIndex(PacketWriter packet, int index) {
|
||||
protected void fillMetadataIndex(BinaryWriter packet, int index) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
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(METADATA_BYTE);
|
||||
byte index0 = 0;
|
||||
@ -1278,13 +1278,13 @@ public abstract class Entity implements Viewable, EventHandler, DataContainer {
|
||||
packet.writeByte(index0);
|
||||
}
|
||||
|
||||
private void fillAirTickMetaData(PacketWriter packet) {
|
||||
private void fillAirTickMetaData(BinaryWriter packet) {
|
||||
packet.writeByte((byte) 1);
|
||||
packet.writeByte(METADATA_VARINT);
|
||||
packet.writeVarInt(air);
|
||||
}
|
||||
|
||||
private void fillCustomNameMetaData(PacketWriter packet) {
|
||||
private void fillCustomNameMetaData(BinaryWriter packet) {
|
||||
boolean hasCustomName = customName != null;
|
||||
|
||||
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(METADATA_BOOLEAN);
|
||||
packet.writeBoolean(customNameVisible);
|
||||
}
|
||||
|
||||
private void fillSilentMetaData(PacketWriter packet) {
|
||||
private void fillSilentMetaData(BinaryWriter packet) {
|
||||
packet.writeByte((byte) 4);
|
||||
packet.writeByte(METADATA_BOOLEAN);
|
||||
packet.writeBoolean(silent);
|
||||
}
|
||||
|
||||
private void fillNoGravityMetaData(PacketWriter packet) {
|
||||
private void fillNoGravityMetaData(BinaryWriter packet) {
|
||||
packet.writeByte((byte) 5);
|
||||
packet.writeByte(METADATA_BOOLEAN);
|
||||
packet.writeBoolean(noGravity);
|
||||
}
|
||||
|
||||
private void fillPoseMetaData(PacketWriter packet) {
|
||||
private void fillPoseMetaData(BinaryWriter packet) {
|
||||
packet.writeByte((byte) 6);
|
||||
packet.writeByte(METADATA_POSE);
|
||||
packet.writeVarInt(pose.ordinal());
|
||||
|
@ -4,8 +4,8 @@ import net.minestom.server.event.entity.EntityItemMergeEvent;
|
||||
import net.minestom.server.instance.Chunk;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import net.minestom.server.item.StackingRule;
|
||||
import net.minestom.server.network.packet.PacketWriter;
|
||||
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.TimeUnit;
|
||||
import net.minestom.server.utils.time.UpdateOption;
|
||||
@ -118,7 +118,7 @@ public class ItemEntity extends ObjectEntity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<PacketWriter> getMetadataConsumer() {
|
||||
public Consumer<BinaryWriter> getMetadataConsumer() {
|
||||
return packet -> {
|
||||
super.getMetadataConsumer().accept(packet);
|
||||
fillMetadataIndex(packet, 7);
|
||||
@ -126,7 +126,7 @@ public class ItemEntity extends ObjectEntity {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillMetadataIndex(PacketWriter packet, int index) {
|
||||
protected void fillMetadataIndex(BinaryWriter packet, int index) {
|
||||
super.fillMetadataIndex(packet, index);
|
||||
if (index == 7) {
|
||||
packet.writeByte((byte) 7);
|
||||
|
@ -10,7 +10,6 @@ import net.minestom.server.event.item.PickupItemEvent;
|
||||
import net.minestom.server.instance.Chunk;
|
||||
import net.minestom.server.inventory.EquipmentHandler;
|
||||
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.EntityAnimationPacket;
|
||||
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.SoundCategory;
|
||||
import net.minestom.server.utils.Position;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import net.minestom.server.utils.time.TimeUnit;
|
||||
|
||||
import java.util.Set;
|
||||
@ -119,7 +119,7 @@ public abstract class LivingEntity extends Entity implements EquipmentHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<PacketWriter> getMetadataConsumer() {
|
||||
public Consumer<BinaryWriter> getMetadataConsumer() {
|
||||
return packet -> {
|
||||
super.getMetadataConsumer().accept(packet);
|
||||
fillMetadataIndex(packet, 7);
|
||||
@ -129,7 +129,7 @@ public abstract class LivingEntity extends Entity implements EquipmentHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillMetadataIndex(PacketWriter packet, int index) {
|
||||
protected void fillMetadataIndex(BinaryWriter packet, int index) {
|
||||
super.fillMetadataIndex(packet, index);
|
||||
if (index == 7) {
|
||||
packet.writeByte((byte) 7);
|
||||
|
@ -24,7 +24,6 @@ import net.minestom.server.inventory.Inventory;
|
||||
import net.minestom.server.inventory.PlayerInventory;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
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.server.ServerPacket;
|
||||
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.MathUtils;
|
||||
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.validate.Check;
|
||||
import net.minestom.server.world.DimensionType;
|
||||
@ -579,7 +579,7 @@ public class Player extends LivingEntity implements CommandSender {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<PacketWriter> getMetadataConsumer() {
|
||||
public Consumer<BinaryWriter> getMetadataConsumer() {
|
||||
return packet -> {
|
||||
super.getMetadataConsumer().accept(packet);
|
||||
fillMetadataIndex(packet, 14);
|
||||
@ -588,7 +588,7 @@ public class Player extends LivingEntity implements CommandSender {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillMetadataIndex(PacketWriter packet, int index) {
|
||||
protected void fillMetadataIndex(BinaryWriter packet, int index) {
|
||||
super.fillMetadataIndex(packet, index);
|
||||
if (index == 14) {
|
||||
packet.writeByte((byte) 14);
|
||||
@ -622,7 +622,7 @@ public class Player extends LivingEntity implements CommandSender {
|
||||
*/
|
||||
public void sendPluginMessage(String channel, String message) {
|
||||
// Write the data
|
||||
PacketWriter writer = new PacketWriter();
|
||||
BinaryWriter writer = new BinaryWriter();
|
||||
writer.writeSizedString(message);
|
||||
// Retrieve the data
|
||||
final byte[] data = writer.toByteArray();
|
||||
|
@ -3,8 +3,8 @@ package net.minestom.server.entity.type.ambient;
|
||||
import net.minestom.server.entity.EntityCreature;
|
||||
import net.minestom.server.entity.EntityType;
|
||||
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.binary.BinaryWriter;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@ -18,7 +18,7 @@ public class EntityBat extends EntityCreature implements Animal {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<PacketWriter> getMetadataConsumer() {
|
||||
public Consumer<BinaryWriter> getMetadataConsumer() {
|
||||
return packet -> {
|
||||
super.getMetadataConsumer().accept(packet);
|
||||
fillMetadataIndex(packet, 15);
|
||||
@ -26,7 +26,7 @@ public class EntityBat extends EntityCreature implements Animal {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillMetadataIndex(PacketWriter packet, int index) {
|
||||
protected void fillMetadataIndex(BinaryWriter packet, int index) {
|
||||
super.fillMetadataIndex(packet, index);
|
||||
if (index == 15) {
|
||||
packet.writeByte((byte) 15);
|
||||
|
@ -3,8 +3,8 @@ package net.minestom.server.entity.type.animal;
|
||||
import net.minestom.server.entity.EntityCreature;
|
||||
import net.minestom.server.entity.EntityType;
|
||||
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.binary.BinaryWriter;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@ -19,7 +19,7 @@ public class EntityMooshroom extends EntityCreature implements Animal {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<PacketWriter> getMetadataConsumer() {
|
||||
public Consumer<BinaryWriter> getMetadataConsumer() {
|
||||
return packet -> {
|
||||
super.getMetadataConsumer().accept(packet);
|
||||
fillMetadataIndex(packet, 16);
|
||||
@ -27,7 +27,7 @@ public class EntityMooshroom extends EntityCreature implements Animal {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillMetadataIndex(PacketWriter packet, int index) {
|
||||
protected void fillMetadataIndex(BinaryWriter packet, int index) {
|
||||
super.fillMetadataIndex(packet, index);
|
||||
if (index == 16) {
|
||||
packet.writeByte((byte) 16);
|
||||
|
@ -3,8 +3,8 @@ package net.minestom.server.entity.type.animal;
|
||||
import net.minestom.server.entity.EntityCreature;
|
||||
import net.minestom.server.entity.EntityType;
|
||||
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.binary.BinaryWriter;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@ -18,7 +18,7 @@ public class EntityPig extends EntityCreature implements Animal {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<PacketWriter> getMetadataConsumer() {
|
||||
public Consumer<BinaryWriter> getMetadataConsumer() {
|
||||
return packet -> {
|
||||
super.getMetadataConsumer().accept(packet);
|
||||
fillMetadataIndex(packet, 16);
|
||||
@ -26,7 +26,7 @@ public class EntityPig extends EntityCreature implements Animal {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillMetadataIndex(PacketWriter packet, int index) {
|
||||
protected void fillMetadataIndex(BinaryWriter packet, int index) {
|
||||
super.fillMetadataIndex(packet, index);
|
||||
if (index == 16) {
|
||||
packet.writeByte((byte) 16);
|
||||
|
@ -3,8 +3,8 @@ package net.minestom.server.entity.type.animal;
|
||||
import net.minestom.server.entity.EntityCreature;
|
||||
import net.minestom.server.entity.EntityType;
|
||||
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.binary.BinaryWriter;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@ -18,7 +18,7 @@ public class EntityPolarBear extends EntityCreature implements Animal {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<PacketWriter> getMetadataConsumer() {
|
||||
public Consumer<BinaryWriter> getMetadataConsumer() {
|
||||
return packet -> {
|
||||
super.getMetadataConsumer().accept(packet);
|
||||
fillMetadataIndex(packet, 16);
|
||||
@ -26,7 +26,7 @@ public class EntityPolarBear extends EntityCreature implements Animal {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillMetadataIndex(PacketWriter packet, int index) {
|
||||
protected void fillMetadataIndex(BinaryWriter packet, int index) {
|
||||
super.fillMetadataIndex(packet, index);
|
||||
if (index == 16) {
|
||||
packet.writeByte((byte) 16);
|
||||
|
@ -3,8 +3,8 @@ package net.minestom.server.entity.type.animal;
|
||||
import net.minestom.server.entity.EntityCreature;
|
||||
import net.minestom.server.entity.EntityType;
|
||||
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.binary.BinaryWriter;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@ -18,7 +18,7 @@ public class EntityRabbit extends EntityCreature implements Animal {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<PacketWriter> getMetadataConsumer() {
|
||||
public Consumer<BinaryWriter> getMetadataConsumer() {
|
||||
return packet -> {
|
||||
super.getMetadataConsumer().accept(packet);
|
||||
fillMetadataIndex(packet, 16);
|
||||
@ -26,7 +26,7 @@ public class EntityRabbit extends EntityCreature implements Animal {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillMetadataIndex(PacketWriter packet, int index) {
|
||||
protected void fillMetadataIndex(BinaryWriter packet, int index) {
|
||||
super.fillMetadataIndex(packet, index);
|
||||
if (index == 16) {
|
||||
packet.writeByte((byte) 16);
|
||||
|
@ -6,10 +6,10 @@ import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.item.ArmorEquipEvent;
|
||||
import net.minestom.server.inventory.EquipmentHandler;
|
||||
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.utils.Position;
|
||||
import net.minestom.server.utils.Vector;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import net.minestom.server.utils.item.ItemStackUtils;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
@ -73,7 +73,7 @@ public class EntityArmorStand extends ObjectEntity implements EquipmentHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<PacketWriter> getMetadataConsumer() {
|
||||
public Consumer<BinaryWriter> getMetadataConsumer() {
|
||||
return packet -> {
|
||||
super.getMetadataConsumer().accept(packet);
|
||||
fillMetadataIndex(packet, 14);
|
||||
@ -87,7 +87,7 @@ public class EntityArmorStand extends ObjectEntity implements EquipmentHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillMetadataIndex(PacketWriter packet, int index) {
|
||||
protected void fillMetadataIndex(BinaryWriter packet, int index) {
|
||||
super.fillMetadataIndex(packet, index);
|
||||
if (index == 14) {
|
||||
packet.writeByte((byte) 14);
|
||||
|
@ -3,9 +3,9 @@ package net.minestom.server.entity.type.decoration;
|
||||
import net.minestom.server.entity.EntityType;
|
||||
import net.minestom.server.entity.ObjectEntity;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import net.minestom.server.network.packet.PacketWriter;
|
||||
import net.minestom.server.utils.Position;
|
||||
import net.minestom.server.utils.Rotation;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import net.minestom.server.utils.item.ItemStackUtils;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
@ -27,7 +27,7 @@ public class EntityItemFrame extends ObjectEntity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<PacketWriter> getMetadataConsumer() {
|
||||
public Consumer<BinaryWriter> getMetadataConsumer() {
|
||||
return packet -> {
|
||||
super.getMetadataConsumer().accept(packet);
|
||||
fillMetadataIndex(packet, 7);
|
||||
@ -36,7 +36,7 @@ public class EntityItemFrame extends ObjectEntity {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillMetadataIndex(PacketWriter packet, int index) {
|
||||
protected void fillMetadataIndex(BinaryWriter packet, int index) {
|
||||
super.fillMetadataIndex(packet, index);
|
||||
if (index == 7) {
|
||||
packet.writeByte((byte) 7);
|
||||
|
@ -3,8 +3,8 @@ package net.minestom.server.entity.type.monster;
|
||||
import net.minestom.server.entity.EntityCreature;
|
||||
import net.minestom.server.entity.EntityType;
|
||||
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.binary.BinaryWriter;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@ -16,7 +16,7 @@ public class EntityBlaze extends EntityCreature implements Monster {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<PacketWriter> getMetadataConsumer() {
|
||||
public Consumer<BinaryWriter> getMetadataConsumer() {
|
||||
return packet -> {
|
||||
super.getMetadataConsumer().accept(packet);
|
||||
fillMetadataIndex(packet, 15);
|
||||
@ -24,7 +24,7 @@ public class EntityBlaze extends EntityCreature implements Monster {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillMetadataIndex(PacketWriter packet, int index) {
|
||||
protected void fillMetadataIndex(BinaryWriter packet, int index) {
|
||||
super.fillMetadataIndex(packet, index);
|
||||
if (index == 15) {
|
||||
packet.writeByte((byte) 15);
|
||||
|
@ -3,8 +3,8 @@ package net.minestom.server.entity.type.monster;
|
||||
import net.minestom.server.entity.EntityCreature;
|
||||
import net.minestom.server.entity.EntityType;
|
||||
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.binary.BinaryWriter;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@ -20,7 +20,7 @@ public class EntityCreeper extends EntityCreature implements Monster {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<PacketWriter> getMetadataConsumer() {
|
||||
public Consumer<BinaryWriter> getMetadataConsumer() {
|
||||
return packet -> {
|
||||
super.getMetadataConsumer().accept(packet);
|
||||
fillMetadataIndex(packet, 15);
|
||||
@ -28,7 +28,7 @@ public class EntityCreeper extends EntityCreature implements Monster {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillMetadataIndex(PacketWriter packet, int index) {
|
||||
protected void fillMetadataIndex(BinaryWriter packet, int index) {
|
||||
super.fillMetadataIndex(packet, index);
|
||||
if (index == 15) {
|
||||
packet.writeByte((byte) 15);
|
||||
|
@ -3,8 +3,8 @@ package net.minestom.server.entity.type.monster;
|
||||
import net.minestom.server.entity.EntityCreature;
|
||||
import net.minestom.server.entity.EntityType;
|
||||
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.binary.BinaryWriter;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@ -19,7 +19,7 @@ public class EntityGhast extends EntityCreature implements Monster {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<PacketWriter> getMetadataConsumer() {
|
||||
public Consumer<BinaryWriter> getMetadataConsumer() {
|
||||
return packet -> {
|
||||
super.getMetadataConsumer().accept(packet);
|
||||
fillMetadataIndex(packet, 15);
|
||||
@ -27,7 +27,7 @@ public class EntityGhast extends EntityCreature implements Monster {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillMetadataIndex(PacketWriter packet, int index) {
|
||||
protected void fillMetadataIndex(BinaryWriter packet, int index) {
|
||||
super.fillMetadataIndex(packet, index);
|
||||
if (index == 15) {
|
||||
packet.writeByte((byte) 15);
|
||||
|
@ -4,8 +4,8 @@ import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.EntityCreature;
|
||||
import net.minestom.server.entity.EntityType;
|
||||
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.binary.BinaryWriter;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@ -20,7 +20,7 @@ public class EntityGuardian extends EntityCreature implements Monster {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<PacketWriter> getMetadataConsumer() {
|
||||
public Consumer<BinaryWriter> getMetadataConsumer() {
|
||||
return packet -> {
|
||||
super.getMetadataConsumer().accept(packet);
|
||||
fillMetadataIndex(packet, 15);
|
||||
@ -29,7 +29,7 @@ public class EntityGuardian extends EntityCreature implements Monster {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillMetadataIndex(PacketWriter packet, int index) {
|
||||
protected void fillMetadataIndex(BinaryWriter packet, int index) {
|
||||
super.fillMetadataIndex(packet, index);
|
||||
if (index == 15) {
|
||||
packet.writeByte((byte) 15);
|
||||
|
@ -3,8 +3,8 @@ package net.minestom.server.entity.type.monster;
|
||||
import net.minestom.server.entity.EntityCreature;
|
||||
import net.minestom.server.entity.EntityType;
|
||||
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.binary.BinaryWriter;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@ -18,7 +18,7 @@ public class EntityPhantom extends EntityCreature implements Monster {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<PacketWriter> getMetadataConsumer() {
|
||||
public Consumer<BinaryWriter> getMetadataConsumer() {
|
||||
return packet -> {
|
||||
super.getMetadataConsumer().accept(packet);
|
||||
fillMetadataIndex(packet, 15);
|
||||
@ -26,7 +26,7 @@ public class EntityPhantom extends EntityCreature implements Monster {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillMetadataIndex(PacketWriter packet, int index) {
|
||||
protected void fillMetadataIndex(BinaryWriter packet, int index) {
|
||||
super.fillMetadataIndex(packet, index);
|
||||
if (index == 15) {
|
||||
packet.writeByte((byte) 15);
|
||||
|
@ -3,8 +3,8 @@ package net.minestom.server.entity.type.monster;
|
||||
import net.minestom.server.entity.EntityCreature;
|
||||
import net.minestom.server.entity.EntityType;
|
||||
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.binary.BinaryWriter;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@ -18,7 +18,7 @@ public class EntitySlime extends EntityCreature implements Monster {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<PacketWriter> getMetadataConsumer() {
|
||||
public Consumer<BinaryWriter> getMetadataConsumer() {
|
||||
return packet -> {
|
||||
super.getMetadataConsumer().accept(packet);
|
||||
fillMetadataIndex(packet, 15);
|
||||
@ -26,7 +26,7 @@ public class EntitySlime extends EntityCreature implements Monster {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillMetadataIndex(PacketWriter packet, int index) {
|
||||
protected void fillMetadataIndex(BinaryWriter packet, int index) {
|
||||
super.fillMetadataIndex(packet, index);
|
||||
if (index == 15) {
|
||||
packet.writeByte((byte) 15);
|
||||
|
@ -3,8 +3,8 @@ package net.minestom.server.entity.type.monster;
|
||||
import net.minestom.server.entity.EntityCreature;
|
||||
import net.minestom.server.entity.EntityType;
|
||||
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.binary.BinaryWriter;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@ -19,7 +19,7 @@ public class EntitySpider extends EntityCreature implements Monster {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<PacketWriter> getMetadataConsumer() {
|
||||
public Consumer<BinaryWriter> getMetadataConsumer() {
|
||||
return packet -> {
|
||||
super.getMetadataConsumer().accept(packet);
|
||||
fillMetadataIndex(packet, 15);
|
||||
@ -27,7 +27,7 @@ public class EntitySpider extends EntityCreature implements Monster {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillMetadataIndex(PacketWriter packet, int index) {
|
||||
protected void fillMetadataIndex(BinaryWriter packet, int index) {
|
||||
super.fillMetadataIndex(packet, index);
|
||||
if (index == 15) {
|
||||
packet.writeByte((byte) 15);
|
||||
|
@ -3,8 +3,8 @@ package net.minestom.server.entity.type.monster;
|
||||
import net.minestom.server.entity.EntityCreature;
|
||||
import net.minestom.server.entity.EntityType;
|
||||
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.binary.BinaryWriter;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@ -19,7 +19,7 @@ public class EntityWitch extends EntityCreature implements Monster {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<PacketWriter> getMetadataConsumer() {
|
||||
public Consumer<BinaryWriter> getMetadataConsumer() {
|
||||
return packet -> {
|
||||
super.getMetadataConsumer().accept(packet);
|
||||
fillMetadataIndex(packet, 16);
|
||||
@ -27,7 +27,7 @@ public class EntityWitch extends EntityCreature implements Monster {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillMetadataIndex(PacketWriter packet, int index) {
|
||||
protected void fillMetadataIndex(BinaryWriter packet, int index) {
|
||||
super.fillMetadataIndex(packet, index);
|
||||
if (index == 16) {
|
||||
packet.writeByte((byte) 16);
|
||||
|
@ -3,8 +3,8 @@ package net.minestom.server.entity.type.monster;
|
||||
import net.minestom.server.entity.EntityCreature;
|
||||
import net.minestom.server.entity.EntityType;
|
||||
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.binary.BinaryWriter;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@ -19,7 +19,7 @@ public class EntityZombie extends EntityCreature implements Monster {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<PacketWriter> getMetadataConsumer() {
|
||||
public Consumer<BinaryWriter> getMetadataConsumer() {
|
||||
return packet -> {
|
||||
super.getMetadataConsumer().accept(packet);
|
||||
fillMetadataIndex(packet, 15);
|
||||
@ -28,7 +28,7 @@ public class EntityZombie extends EntityCreature implements Monster {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillMetadataIndex(PacketWriter packet, int index) {
|
||||
protected void fillMetadataIndex(BinaryWriter packet, int index) {
|
||||
super.fillMetadataIndex(packet, index);
|
||||
if (index == 15) {
|
||||
packet.writeByte((byte) 15);
|
||||
|
@ -3,8 +3,8 @@ package net.minestom.server.entity.type.monster;
|
||||
import net.minestom.server.entity.EntityCreature;
|
||||
import net.minestom.server.entity.EntityType;
|
||||
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.binary.BinaryWriter;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@ -19,7 +19,7 @@ public class EntityZombifiedPiglin extends EntityCreature implements Monster {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<PacketWriter> getMetadataConsumer() {
|
||||
public Consumer<BinaryWriter> getMetadataConsumer() {
|
||||
return packet -> {
|
||||
super.getMetadataConsumer().accept(packet);
|
||||
fillMetadataIndex(packet, 15);
|
||||
@ -28,7 +28,7 @@ public class EntityZombifiedPiglin extends EntityCreature implements Monster {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillMetadataIndex(PacketWriter packet, int index) {
|
||||
protected void fillMetadataIndex(BinaryWriter packet, int index) {
|
||||
super.fillMetadataIndex(packet, index);
|
||||
if (index == 15) {
|
||||
packet.writeByte((byte) 15);
|
||||
|
@ -2,15 +2,15 @@ package net.minestom.server.entity.type.other;
|
||||
|
||||
import net.minestom.server.entity.EntityType;
|
||||
import net.minestom.server.entity.ObjectEntity;
|
||||
import net.minestom.server.network.packet.PacketWriter;
|
||||
import net.minestom.server.particle.Particle;
|
||||
import net.minestom.server.utils.Position;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class EntityAreaEffectCloud extends ObjectEntity {
|
||||
|
||||
public Consumer<PacketWriter> particleDataConsumer;
|
||||
public Consumer<BinaryWriter> particleDataConsumer;
|
||||
private float radius;
|
||||
private int color;
|
||||
private boolean ignoreRadius;
|
||||
@ -27,7 +27,7 @@ public class EntityAreaEffectCloud extends ObjectEntity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<PacketWriter> getMetadataConsumer() {
|
||||
public Consumer<BinaryWriter> getMetadataConsumer() {
|
||||
return packet -> {
|
||||
super.getMetadataConsumer().accept(packet);
|
||||
fillMetadataIndex(packet, 7);
|
||||
@ -38,7 +38,7 @@ public class EntityAreaEffectCloud extends ObjectEntity {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillMetadataIndex(PacketWriter packet, int index) {
|
||||
protected void fillMetadataIndex(BinaryWriter packet, int index) {
|
||||
super.fillMetadataIndex(packet, index);
|
||||
if (index == 7) {
|
||||
packet.writeByte((byte) 7);
|
||||
@ -102,7 +102,7 @@ public class EntityAreaEffectCloud extends ObjectEntity {
|
||||
sendMetadataIndex(10);
|
||||
}
|
||||
|
||||
public Consumer<PacketWriter> getParticleDataConsumer() {
|
||||
public Consumer<BinaryWriter> getParticleDataConsumer() {
|
||||
return particleDataConsumer;
|
||||
}
|
||||
|
||||
@ -112,7 +112,7 @@ public class EntityAreaEffectCloud extends ObjectEntity {
|
||||
* @param particleDataConsumer the particle data consumer
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
|
@ -3,8 +3,8 @@ package net.minestom.server.entity.type.other;
|
||||
import net.minestom.server.entity.EntityCreature;
|
||||
import net.minestom.server.entity.EntityType;
|
||||
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.binary.BinaryWriter;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@ -18,7 +18,7 @@ public class EntityIronGolem extends EntityCreature implements Constructable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<PacketWriter> getMetadataConsumer() {
|
||||
public Consumer<BinaryWriter> getMetadataConsumer() {
|
||||
return packet -> {
|
||||
super.getMetadataConsumer().accept(packet);
|
||||
fillMetadataIndex(packet, 15);
|
||||
@ -26,7 +26,7 @@ public class EntityIronGolem extends EntityCreature implements Constructable {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillMetadataIndex(PacketWriter packet, int index) {
|
||||
protected void fillMetadataIndex(BinaryWriter packet, int index) {
|
||||
super.fillMetadataIndex(packet, index);
|
||||
if (index == 15) {
|
||||
packet.writeByte((byte) 15);
|
||||
|
@ -3,8 +3,8 @@ package net.minestom.server.entity.type.other;
|
||||
import net.minestom.server.entity.EntityCreature;
|
||||
import net.minestom.server.entity.EntityType;
|
||||
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.binary.BinaryWriter;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@ -18,7 +18,7 @@ public class EntitySnowman extends EntityCreature implements Constructable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<PacketWriter> getMetadataConsumer() {
|
||||
public Consumer<BinaryWriter> getMetadataConsumer() {
|
||||
return packet -> {
|
||||
super.getMetadataConsumer().accept(packet);
|
||||
fillMetadataIndex(packet, 15);
|
||||
@ -26,7 +26,7 @@ public class EntitySnowman extends EntityCreature implements Constructable {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillMetadataIndex(PacketWriter packet, int index) {
|
||||
protected void fillMetadataIndex(BinaryWriter packet, int index) {
|
||||
super.fillMetadataIndex(packet, index);
|
||||
if (index == 15) {
|
||||
packet.writeByte((byte) 15);
|
||||
|
@ -5,8 +5,8 @@ import net.minestom.server.entity.ObjectEntity;
|
||||
import net.minestom.server.entity.type.Projectile;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import net.minestom.server.item.Material;
|
||||
import net.minestom.server.network.packet.PacketWriter;
|
||||
import net.minestom.server.utils.Position;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@ -19,7 +19,7 @@ public class EntityEyeOfEnder extends ObjectEntity implements Projectile {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<PacketWriter> getMetadataConsumer() {
|
||||
public Consumer<BinaryWriter> getMetadataConsumer() {
|
||||
return packet -> {
|
||||
super.getMetadataConsumer().accept(packet);
|
||||
fillMetadataIndex(packet, 7);
|
||||
@ -27,7 +27,7 @@ public class EntityEyeOfEnder extends ObjectEntity implements Projectile {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillMetadataIndex(PacketWriter packet, int index) {
|
||||
protected void fillMetadataIndex(BinaryWriter packet, int index) {
|
||||
super.fillMetadataIndex(packet, index);
|
||||
if (index == 7) {
|
||||
packet.writeByte((byte) 7);
|
||||
|
@ -4,8 +4,8 @@ import net.minestom.server.entity.EntityType;
|
||||
import net.minestom.server.entity.ObjectEntity;
|
||||
import net.minestom.server.entity.type.Projectile;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import net.minestom.server.network.packet.PacketWriter;
|
||||
import net.minestom.server.utils.Position;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@ -20,7 +20,7 @@ public class EntityPotion extends ObjectEntity implements Projectile {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<PacketWriter> getMetadataConsumer() {
|
||||
public Consumer<BinaryWriter> getMetadataConsumer() {
|
||||
return packet -> {
|
||||
super.getMetadataConsumer().accept(packet);
|
||||
fillMetadataIndex(packet, 7);
|
||||
@ -28,7 +28,7 @@ public class EntityPotion extends ObjectEntity implements Projectile {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillMetadataIndex(PacketWriter packet, int index) {
|
||||
protected void fillMetadataIndex(BinaryWriter packet, int index) {
|
||||
super.fillMetadataIndex(packet, index);
|
||||
if (index == 7) {
|
||||
packet.writeByte((byte) 7);
|
||||
|
@ -3,8 +3,8 @@ package net.minestom.server.entity.type.vehicle;
|
||||
import net.minestom.server.entity.EntityType;
|
||||
import net.minestom.server.entity.ObjectEntity;
|
||||
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.binary.BinaryWriter;
|
||||
import net.minestom.server.utils.validate.Check;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
@ -27,7 +27,7 @@ public class EntityBoat extends ObjectEntity implements Vehicle {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<PacketWriter> getMetadataConsumer() {
|
||||
public Consumer<BinaryWriter> getMetadataConsumer() {
|
||||
return packet -> {
|
||||
super.getMetadataConsumer().accept(packet);
|
||||
fillMetadataIndex(packet, 10);
|
||||
@ -39,7 +39,7 @@ public class EntityBoat extends ObjectEntity implements Vehicle {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillMetadataIndex(PacketWriter packet, int index) {
|
||||
protected void fillMetadataIndex(BinaryWriter packet, int index) {
|
||||
super.fillMetadataIndex(packet, index);
|
||||
if (index == 10) {
|
||||
packet.writeByte((byte) 10);
|
||||
|
@ -26,7 +26,6 @@ import net.minestom.server.utils.time.UpdateOption;
|
||||
import net.minestom.server.utils.validate.Check;
|
||||
import net.minestom.server.world.biomes.Biome;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
import java.util.function.Consumer;
|
||||
@ -229,9 +228,8 @@ public abstract class Chunk implements Viewable {
|
||||
* Serialize the 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
|
||||
|
@ -9,11 +9,9 @@ import net.minestom.server.instance.block.CustomBlock;
|
||||
import net.minestom.server.instance.block.UpdateConsumer;
|
||||
import net.minestom.server.network.packet.server.play.ChunkDataPacket;
|
||||
import net.minestom.server.utils.MathUtils;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import net.minestom.server.world.biomes.Biome;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
|
||||
public class DynamicChunk extends Chunk {
|
||||
@ -146,12 +144,13 @@ public class DynamicChunk extends Chunk {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected byte[] getSerializedData() throws IOException {
|
||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||
DataOutputStream dos = new DataOutputStream(output);
|
||||
protected byte[] getSerializedData() {
|
||||
BinaryWriter binaryWriter = new BinaryWriter();
|
||||
|
||||
// Write the biomes id
|
||||
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++) {
|
||||
@ -162,33 +161,32 @@ public class DynamicChunk extends Chunk {
|
||||
final short blockStateId = blocksStateId[index];
|
||||
final short customBlockId = customBlocksId[index];
|
||||
|
||||
// No block at the position
|
||||
if (blockStateId == 0 && customBlockId == 0)
|
||||
continue;
|
||||
|
||||
final Data data = blocksData.get(index);
|
||||
|
||||
// Chunk coordinates
|
||||
dos.writeInt(x);
|
||||
dos.writeInt(y);
|
||||
dos.writeInt(z);
|
||||
binaryWriter.writeByte(x);
|
||||
binaryWriter.writeShort(y);
|
||||
binaryWriter.writeByte(z);
|
||||
|
||||
// Id
|
||||
dos.writeShort(blockStateId);
|
||||
dos.writeShort(customBlockId);
|
||||
// Block ids
|
||||
binaryWriter.writeShort(blockStateId);
|
||||
binaryWriter.writeShort(customBlockId);
|
||||
|
||||
// Data
|
||||
final Data data = blocksData.get(index);
|
||||
final boolean hasData = data instanceof SerializableData;
|
||||
dos.writeBoolean(hasData);
|
||||
binaryWriter.writeBoolean(hasData);
|
||||
if (hasData) {
|
||||
final byte[] d = ((SerializableData) data).getSerializedData();
|
||||
dos.writeInt(d.length);
|
||||
dos.write(d);
|
||||
final byte[] serializedData = ((SerializableData) data).getSerializedData();
|
||||
binaryWriter.writeBytes(serializedData);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return output.toByteArray();
|
||||
return binaryWriter.toByteArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,7 +5,6 @@ import net.minestom.server.storage.StorageFolder;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class MinestomBasicChunkLoader implements IChunkLoader {
|
||||
@ -27,7 +26,6 @@ public class MinestomBasicChunkLoader implements IChunkLoader {
|
||||
final int chunkX = chunk.getChunkX();
|
||||
final int chunkZ = chunk.getChunkZ();
|
||||
|
||||
try {
|
||||
final String key = getChunkKey(chunkX, chunkZ);
|
||||
final byte[] data = chunk.getSerializedData();
|
||||
if (data == null)
|
||||
@ -36,9 +34,6 @@ public class MinestomBasicChunkLoader implements IChunkLoader {
|
||||
|
||||
if (callback != null)
|
||||
callback.run();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,7 +5,6 @@ import io.netty.channel.socket.SocketChannel;
|
||||
import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.entity.Player;
|
||||
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.ClientPreplayPacket;
|
||||
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.player.NettyPlayerConnection;
|
||||
import net.minestom.server.network.player.PlayerConnection;
|
||||
import net.minestom.server.utils.binary.BinaryReader;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@ -55,13 +55,13 @@ public class PacketProcessor {
|
||||
//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) {
|
||||
// Should be handshake packet
|
||||
if (packet.packetId == 0) {
|
||||
HandshakePacket handshakePacket = new HandshakePacket();
|
||||
handshakePacket.read(packetReader);
|
||||
handshakePacket.read(binaryReader);
|
||||
handshakePacket.process(playerConnection, connectionManager);
|
||||
}
|
||||
return;
|
||||
@ -71,17 +71,17 @@ public class PacketProcessor {
|
||||
case PLAY:
|
||||
final Player player = playerConnection.getPlayer();
|
||||
ClientPlayPacket playPacket = (ClientPlayPacket) playPacketsHandler.getPacketInstance(packet.packetId);
|
||||
playPacket.read(packetReader);
|
||||
playPacket.read(binaryReader);
|
||||
player.addPacketToQueue(playPacket);
|
||||
break;
|
||||
case LOGIN:
|
||||
final ClientPreplayPacket loginPacket = (ClientPreplayPacket) loginPacketsHandler.getPacketInstance(packet.packetId);
|
||||
loginPacket.read(packetReader);
|
||||
loginPacket.read(binaryReader);
|
||||
loginPacket.process(playerConnection, connectionManager);
|
||||
break;
|
||||
case STATUS:
|
||||
final ClientPreplayPacket statusPacket = (ClientPreplayPacket) statusPacketsHandler.getPacketInstance(packet.packetId);
|
||||
statusPacket.read(packetReader);
|
||||
statusPacket.read(binaryReader);
|
||||
|
||||
statusPacket.process(playerConnection, connectionManager);
|
||||
break;
|
||||
|
@ -1,9 +1,9 @@
|
||||
package net.minestom.server.network.packet.client;
|
||||
|
||||
import net.minestom.server.network.packet.PacketReader;
|
||||
import net.minestom.server.utils.binary.BinaryReader;
|
||||
|
||||
public interface ClientPacket {
|
||||
|
||||
void read(PacketReader reader);
|
||||
void read(BinaryReader reader);
|
||||
|
||||
}
|
||||
|
@ -5,10 +5,10 @@ import net.minestom.server.chat.ChatColor;
|
||||
import net.minestom.server.chat.ColoredText;
|
||||
import net.minestom.server.network.ConnectionManager;
|
||||
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.server.login.LoginDisconnect;
|
||||
import net.minestom.server.network.player.PlayerConnection;
|
||||
import net.minestom.server.utils.binary.BinaryReader;
|
||||
|
||||
public class HandshakePacket implements ClientPreplayPacket {
|
||||
|
||||
@ -18,7 +18,7 @@ public class HandshakePacket implements ClientPreplayPacket {
|
||||
private int nextState;
|
||||
|
||||
@Override
|
||||
public void read(PacketReader reader) {
|
||||
public void read(BinaryReader reader) {
|
||||
this.protocolVersion = reader.readVarInt();
|
||||
this.serverAddress = reader.readSizedString();
|
||||
this.serverPort = reader.readUnsignedShort();
|
||||
|
@ -7,11 +7,11 @@ import net.minestom.server.data.type.array.ByteArrayData;
|
||||
import net.minestom.server.extras.mojangAuth.MojangCrypt;
|
||||
import net.minestom.server.network.ConnectionManager;
|
||||
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.server.login.LoginSuccessPacket;
|
||||
import net.minestom.server.network.player.NettyPlayerConnection;
|
||||
import net.minestom.server.network.player.PlayerConnection;
|
||||
import net.minestom.server.utils.binary.BinaryReader;
|
||||
|
||||
import javax.crypto.SecretKey;
|
||||
import java.math.BigInteger;
|
||||
@ -58,7 +58,7 @@ public class EncryptionResponsePacket implements ClientPreplayPacket {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(PacketReader reader) {
|
||||
public void read(BinaryReader reader) {
|
||||
sharedSecret = ByteArrayData.decodeByteArray(reader);
|
||||
verifyToken = ByteArrayData.decodeByteArray(reader);
|
||||
}
|
||||
|
@ -6,12 +6,12 @@ import net.minestom.server.chat.ColoredText;
|
||||
import net.minestom.server.extras.MojangAuth;
|
||||
import net.minestom.server.network.ConnectionManager;
|
||||
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.server.login.EncryptionRequestPacket;
|
||||
import net.minestom.server.network.packet.server.login.LoginDisconnect;
|
||||
import net.minestom.server.network.packet.server.login.LoginSuccessPacket;
|
||||
import net.minestom.server.network.player.PlayerConnection;
|
||||
import net.minestom.server.utils.binary.BinaryReader;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -53,7 +53,7 @@ public class LoginStartPacket implements ClientPreplayPacket {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(PacketReader reader) {
|
||||
public void read(BinaryReader reader) {
|
||||
this.username = reader.readSizedString();
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
package net.minestom.server.network.packet.client.play;
|
||||
|
||||
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.utils.binary.BinaryReader;
|
||||
|
||||
public class ClientAdvancementTabPacket extends ClientPlayPacket {
|
||||
|
||||
@ -10,7 +10,7 @@ public class ClientAdvancementTabPacket extends ClientPlayPacket {
|
||||
public String tabIdentifier;
|
||||
|
||||
@Override
|
||||
public void read(PacketReader reader) {
|
||||
public void read(BinaryReader reader) {
|
||||
this.action = AdvancementAction.values()[reader.readVarInt()];
|
||||
|
||||
if (action == AdvancementAction.OPENED_TAB) {
|
||||
|
@ -1,15 +1,15 @@
|
||||
package net.minestom.server.network.packet.client.play;
|
||||
|
||||
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.utils.binary.BinaryReader;
|
||||
|
||||
public class ClientAnimationPacket extends ClientPlayPacket {
|
||||
|
||||
public Player.Hand hand;
|
||||
|
||||
@Override
|
||||
public void read(PacketReader reader) {
|
||||
public void read(BinaryReader reader) {
|
||||
this.hand = Player.Hand.values()[reader.readVarInt()];
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
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.utils.binary.BinaryReader;
|
||||
|
||||
public class ClientChatMessagePacket extends ClientPlayPacket {
|
||||
|
||||
public String message;
|
||||
|
||||
@Override
|
||||
public void read(PacketReader reader) {
|
||||
public void read(BinaryReader reader) {
|
||||
this.message = reader.readSizedString();
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
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.utils.binary.BinaryReader;
|
||||
|
||||
public class ClientClickWindowButtonPacket extends ClientPlayPacket {
|
||||
|
||||
@ -9,7 +9,7 @@ public class ClientClickWindowButtonPacket extends ClientPlayPacket {
|
||||
public byte buttonId;
|
||||
|
||||
@Override
|
||||
public void read(PacketReader reader) {
|
||||
public void read(BinaryReader reader) {
|
||||
this.windowId = reader.readByte();
|
||||
this.buttonId = reader.readByte();
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package net.minestom.server.network.packet.client.play;
|
||||
|
||||
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.utils.binary.BinaryReader;
|
||||
|
||||
public class ClientClickWindowPacket extends ClientPlayPacket {
|
||||
|
||||
@ -14,7 +14,7 @@ public class ClientClickWindowPacket extends ClientPlayPacket {
|
||||
public ItemStack item;
|
||||
|
||||
@Override
|
||||
public void read(PacketReader reader) {
|
||||
public void read(BinaryReader reader) {
|
||||
this.windowId = reader.readByte();
|
||||
this.slot = reader.readShort();
|
||||
this.button = reader.readByte();
|
||||
|
@ -1,14 +1,14 @@
|
||||
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.utils.binary.BinaryReader;
|
||||
|
||||
public class ClientCloseWindow extends ClientPlayPacket {
|
||||
|
||||
public int windowId;
|
||||
|
||||
@Override
|
||||
public void read(PacketReader reader) {
|
||||
public void read(BinaryReader reader) {
|
||||
this.windowId = reader.readVarInt();
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
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.utils.binary.BinaryReader;
|
||||
|
||||
public class ClientCraftRecipeRequest extends ClientPlayPacket {
|
||||
|
||||
@ -10,7 +10,7 @@ public class ClientCraftRecipeRequest extends ClientPlayPacket {
|
||||
public boolean makeAll;
|
||||
|
||||
@Override
|
||||
public void read(PacketReader reader) {
|
||||
public void read(BinaryReader reader) {
|
||||
this.windowId = reader.readByte();
|
||||
this.recipe = reader.readSizedString();
|
||||
this.makeAll = reader.readBoolean();
|
||||
|
@ -1,8 +1,8 @@
|
||||
package net.minestom.server.network.packet.client.play;
|
||||
|
||||
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.utils.binary.BinaryReader;
|
||||
|
||||
public class ClientCreativeInventoryActionPacket extends ClientPlayPacket {
|
||||
|
||||
@ -10,7 +10,7 @@ public class ClientCreativeInventoryActionPacket extends ClientPlayPacket {
|
||||
public ItemStack item;
|
||||
|
||||
@Override
|
||||
public void read(PacketReader reader) {
|
||||
public void read(BinaryReader reader) {
|
||||
this.slot = reader.readShort();
|
||||
this.item = reader.readSlot();
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
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.utils.binary.BinaryReader;
|
||||
|
||||
public class ClientEntityActionPacket extends ClientPlayPacket {
|
||||
|
||||
@ -10,7 +10,7 @@ public class ClientEntityActionPacket extends ClientPlayPacket {
|
||||
public int horseJumpBoost;
|
||||
|
||||
@Override
|
||||
public void read(PacketReader reader) {
|
||||
public void read(BinaryReader reader) {
|
||||
this.playerId = reader.readVarInt();
|
||||
this.action = Action.values()[reader.readVarInt()];
|
||||
this.horseJumpBoost = reader.readVarInt();
|
||||
|
@ -1,14 +1,14 @@
|
||||
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.utils.binary.BinaryReader;
|
||||
|
||||
public class ClientHeldItemChangePacket extends ClientPlayPacket {
|
||||
|
||||
public short slot;
|
||||
|
||||
@Override
|
||||
public void read(PacketReader reader) {
|
||||
public void read(BinaryReader reader) {
|
||||
this.slot = reader.readShort();
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package net.minestom.server.network.packet.client.play;
|
||||
|
||||
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.utils.binary.BinaryReader;
|
||||
|
||||
public class ClientInteractEntityPacket extends ClientPlayPacket {
|
||||
|
||||
@ -15,7 +15,7 @@ public class ClientInteractEntityPacket extends ClientPlayPacket {
|
||||
public boolean sneaking;
|
||||
|
||||
@Override
|
||||
public void read(PacketReader reader) {
|
||||
public void read(BinaryReader reader) {
|
||||
this.targetId = reader.readVarInt();
|
||||
this.type = Type.values()[reader.readVarInt()];
|
||||
|
||||
|
@ -1,14 +1,14 @@
|
||||
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.utils.binary.BinaryReader;
|
||||
|
||||
public class ClientKeepAlivePacket extends ClientPlayPacket {
|
||||
|
||||
public long id;
|
||||
|
||||
@Override
|
||||
public void read(PacketReader reader) {
|
||||
public void read(BinaryReader reader) {
|
||||
this.id = reader.readLong();
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
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.utils.binary.BinaryReader;
|
||||
|
||||
public class ClientNameItemPacket extends ClientPlayPacket {
|
||||
|
||||
public String itemName;
|
||||
|
||||
@Override
|
||||
public void read(PacketReader reader) {
|
||||
public void read(BinaryReader reader) {
|
||||
this.itemName = reader.readSizedString();
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
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.utils.binary.BinaryReader;
|
||||
|
||||
public class ClientPickItemPacket extends ClientPlayPacket {
|
||||
|
||||
public int slotToUse;
|
||||
|
||||
@Override
|
||||
public void read(PacketReader reader) {
|
||||
public void read(BinaryReader reader) {
|
||||
this.slotToUse = reader.readVarInt();
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
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.utils.binary.BinaryReader;
|
||||
|
||||
public class ClientPlayerAbilitiesPacket extends ClientPlayPacket {
|
||||
|
||||
public byte flags;
|
||||
|
||||
@Override
|
||||
public void read(PacketReader reader) {
|
||||
public void read(BinaryReader reader) {
|
||||
this.flags = reader.readByte();
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,9 @@ package net.minestom.server.network.packet.client.play;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
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.utils.BlockPosition;
|
||||
import net.minestom.server.utils.binary.BinaryReader;
|
||||
|
||||
public class ClientPlayerBlockPlacementPacket extends ClientPlayPacket {
|
||||
|
||||
@ -15,7 +15,7 @@ public class ClientPlayerBlockPlacementPacket extends ClientPlayPacket {
|
||||
public boolean insideBlock;
|
||||
|
||||
@Override
|
||||
public void read(PacketReader reader) {
|
||||
public void read(BinaryReader reader) {
|
||||
this.hand = Player.Hand.values()[reader.readVarInt()];
|
||||
this.blockPosition = reader.readBlockPosition();
|
||||
this.blockFace = BlockFace.values()[reader.readVarInt()];
|
||||
|
@ -1,9 +1,9 @@
|
||||
package net.minestom.server.network.packet.client.play;
|
||||
|
||||
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.utils.BlockPosition;
|
||||
import net.minestom.server.utils.binary.BinaryReader;
|
||||
|
||||
public class ClientPlayerDiggingPacket extends ClientPlayPacket {
|
||||
|
||||
@ -12,7 +12,7 @@ public class ClientPlayerDiggingPacket extends ClientPlayPacket {
|
||||
public BlockFace blockFace;
|
||||
|
||||
@Override
|
||||
public void read(PacketReader reader) {
|
||||
public void read(BinaryReader reader) {
|
||||
this.status = Status.values()[reader.readVarInt()];
|
||||
this.blockPosition = reader.readBlockPosition();
|
||||
this.blockFace = BlockFace.values()[reader.readVarInt()];
|
||||
|
@ -1,14 +1,14 @@
|
||||
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.utils.binary.BinaryReader;
|
||||
|
||||
public class ClientPlayerPacket extends ClientPlayPacket {
|
||||
|
||||
public boolean onGround;
|
||||
|
||||
@Override
|
||||
public void read(PacketReader reader) {
|
||||
public void read(BinaryReader reader) {
|
||||
this.onGround = reader.readBoolean();
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
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.utils.binary.BinaryReader;
|
||||
|
||||
public class ClientPlayerPositionAndRotationPacket extends ClientPlayPacket {
|
||||
|
||||
@ -10,7 +10,7 @@ public class ClientPlayerPositionAndRotationPacket extends ClientPlayPacket {
|
||||
public boolean onGround;
|
||||
|
||||
@Override
|
||||
public void read(PacketReader reader) {
|
||||
public void read(BinaryReader reader) {
|
||||
this.x = reader.readDouble();
|
||||
this.y = reader.readDouble();
|
||||
this.z = reader.readDouble();
|
||||
|
@ -1,7 +1,7 @@
|
||||
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.utils.binary.BinaryReader;
|
||||
|
||||
public class ClientPlayerPositionPacket extends ClientPlayPacket {
|
||||
|
||||
@ -9,7 +9,7 @@ public class ClientPlayerPositionPacket extends ClientPlayPacket {
|
||||
public boolean onGround;
|
||||
|
||||
@Override
|
||||
public void read(PacketReader reader) {
|
||||
public void read(BinaryReader reader) {
|
||||
this.x = reader.readDouble();
|
||||
this.y = reader.readDouble();
|
||||
this.z = reader.readDouble();
|
||||
|
@ -1,7 +1,7 @@
|
||||
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.utils.binary.BinaryReader;
|
||||
|
||||
public class ClientPlayerRotationPacket extends ClientPlayPacket {
|
||||
|
||||
@ -9,7 +9,7 @@ public class ClientPlayerRotationPacket extends ClientPlayPacket {
|
||||
public boolean onGround;
|
||||
|
||||
@Override
|
||||
public void read(PacketReader reader) {
|
||||
public void read(BinaryReader reader) {
|
||||
this.yaw = reader.readFloat();
|
||||
this.pitch = reader.readFloat();
|
||||
this.onGround = reader.readBoolean();
|
||||
|
@ -1,7 +1,7 @@
|
||||
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.utils.binary.BinaryReader;
|
||||
|
||||
public class ClientPluginMessagePacket extends ClientPlayPacket {
|
||||
|
||||
@ -9,7 +9,7 @@ public class ClientPluginMessagePacket extends ClientPlayPacket {
|
||||
public byte[] data;
|
||||
|
||||
@Override
|
||||
public void read(PacketReader reader) {
|
||||
public void read(BinaryReader reader) {
|
||||
this.channel = reader.readSizedString();
|
||||
this.data = reader.getRemainingBytes();
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
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.utils.binary.BinaryReader;
|
||||
|
||||
public class ClientRecipeBookData extends ClientPlayPacket {
|
||||
|
||||
@ -19,7 +19,7 @@ public class ClientRecipeBookData extends ClientPlayPacket {
|
||||
public boolean smokingRecipeFilterActive;
|
||||
|
||||
@Override
|
||||
public void read(PacketReader reader) {
|
||||
public void read(BinaryReader reader) {
|
||||
this.type = reader.readVarInt();
|
||||
|
||||
switch (type) {
|
||||
|
@ -1,15 +1,15 @@
|
||||
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.resourcepack.ResourcePackStatus;
|
||||
import net.minestom.server.utils.binary.BinaryReader;
|
||||
|
||||
public class ClientResourcePackStatusPacket extends ClientPlayPacket {
|
||||
|
||||
public ResourcePackStatus result;
|
||||
|
||||
@Override
|
||||
public void read(PacketReader reader) {
|
||||
public void read(BinaryReader reader) {
|
||||
this.result = ResourcePackStatus.values()[reader.readVarInt()];
|
||||
}
|
||||
|
||||
|
@ -1,14 +1,14 @@
|
||||
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.utils.binary.BinaryReader;
|
||||
|
||||
public class ClientSelectTradePacket extends ClientPlayPacket {
|
||||
|
||||
public int selectedSlot;
|
||||
|
||||
@Override
|
||||
public void read(PacketReader reader) {
|
||||
public void read(BinaryReader reader) {
|
||||
this.selectedSlot = reader.readVarInt();
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package net.minestom.server.network.packet.client.play;
|
||||
|
||||
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.utils.binary.BinaryReader;
|
||||
|
||||
public class ClientSettingsPacket extends ClientPlayPacket {
|
||||
|
||||
@ -14,7 +14,7 @@ public class ClientSettingsPacket extends ClientPlayPacket {
|
||||
public Player.MainHand mainHand;
|
||||
|
||||
@Override
|
||||
public void read(PacketReader reader) {
|
||||
public void read(BinaryReader reader) {
|
||||
this.locale = reader.readSizedString();
|
||||
this.viewDistance = reader.readByte();
|
||||
this.chatMode = Player.ChatMode.values()[reader.readVarInt()];
|
||||
|
@ -1,7 +1,7 @@
|
||||
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.utils.binary.BinaryReader;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -10,7 +10,7 @@ public class ClientSpectatePacket extends ClientPlayPacket {
|
||||
public UUID targetUuid;
|
||||
|
||||
@Override
|
||||
public void read(PacketReader reader) {
|
||||
public void read(BinaryReader reader) {
|
||||
// TODO reader uuid
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
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.utils.binary.BinaryReader;
|
||||
|
||||
public class ClientStatusPacket extends ClientPlayPacket {
|
||||
|
||||
public Action action;
|
||||
|
||||
@Override
|
||||
public void read(PacketReader reader) {
|
||||
public void read(BinaryReader reader) {
|
||||
this.action = Action.values()[reader.readVarInt()];
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
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.utils.binary.BinaryReader;
|
||||
|
||||
public class ClientSteerBoatPacket extends ClientPlayPacket {
|
||||
|
||||
@ -9,7 +9,7 @@ public class ClientSteerBoatPacket extends ClientPlayPacket {
|
||||
public boolean rightPaddleTurning;
|
||||
|
||||
@Override
|
||||
public void read(PacketReader reader) {
|
||||
public void read(BinaryReader reader) {
|
||||
this.leftPaddleTurning = reader.readBoolean();
|
||||
this.rightPaddleTurning = reader.readBoolean();
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
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.utils.binary.BinaryReader;
|
||||
|
||||
public class ClientSteerVehiclePacket extends ClientPlayPacket {
|
||||
|
||||
@ -10,7 +10,7 @@ public class ClientSteerVehiclePacket extends ClientPlayPacket {
|
||||
public byte flags;
|
||||
|
||||
@Override
|
||||
public void read(PacketReader reader) {
|
||||
public void read(BinaryReader reader) {
|
||||
this.sideways = reader.readFloat();
|
||||
this.forward = reader.readFloat();
|
||||
this.flags = reader.readByte();
|
||||
|
@ -1,7 +1,7 @@
|
||||
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.utils.binary.BinaryReader;
|
||||
|
||||
public class ClientTabCompletePacket extends ClientPlayPacket {
|
||||
|
||||
@ -9,7 +9,7 @@ public class ClientTabCompletePacket extends ClientPlayPacket {
|
||||
public String text;
|
||||
|
||||
@Override
|
||||
public void read(PacketReader reader) {
|
||||
public void read(BinaryReader reader) {
|
||||
this.transactionId = reader.readVarInt();
|
||||
this.text = reader.readSizedString();
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
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.utils.binary.BinaryReader;
|
||||
|
||||
public class ClientTeleportConfirmPacket extends ClientPlayPacket {
|
||||
|
||||
public int teleportId;
|
||||
|
||||
@Override
|
||||
public void read(PacketReader reader) {
|
||||
public void read(BinaryReader reader) {
|
||||
this.teleportId = reader.readVarInt();
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
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.utils.binary.BinaryReader;
|
||||
|
||||
public class ClientUpdateCommandBlockMinecartPacket extends ClientPlayPacket {
|
||||
|
||||
@ -10,7 +10,7 @@ public class ClientUpdateCommandBlockMinecartPacket extends ClientPlayPacket {
|
||||
public boolean trackOutput;
|
||||
|
||||
@Override
|
||||
public void read(PacketReader reader) {
|
||||
public void read(BinaryReader reader) {
|
||||
this.entityId = reader.readVarInt();
|
||||
this.command = reader.readSizedString();
|
||||
this.trackOutput = reader.readBoolean();
|
||||
|
@ -1,8 +1,8 @@
|
||||
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.utils.BlockPosition;
|
||||
import net.minestom.server.utils.binary.BinaryReader;
|
||||
|
||||
public class ClientUpdateCommandBlockPacket extends ClientPlayPacket {
|
||||
|
||||
@ -12,7 +12,7 @@ public class ClientUpdateCommandBlockPacket extends ClientPlayPacket {
|
||||
public byte flags;
|
||||
|
||||
@Override
|
||||
public void read(PacketReader reader) {
|
||||
public void read(BinaryReader reader) {
|
||||
this.blockPosition = reader.readBlockPosition();
|
||||
this.command = reader.readSizedString();
|
||||
this.mode = Mode.values()[reader.readVarInt()];
|
||||
|
@ -1,8 +1,8 @@
|
||||
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.utils.BlockPosition;
|
||||
import net.minestom.server.utils.binary.BinaryReader;
|
||||
|
||||
public class ClientUpdateSignPacket extends ClientPlayPacket {
|
||||
|
||||
@ -13,7 +13,7 @@ public class ClientUpdateSignPacket extends ClientPlayPacket {
|
||||
public String line4;
|
||||
|
||||
@Override
|
||||
public void read(PacketReader reader) {
|
||||
public void read(BinaryReader reader) {
|
||||
this.blockPosition = reader.readBlockPosition();
|
||||
this.line1 = reader.readSizedString();
|
||||
this.line2 = reader.readSizedString();
|
||||
|
@ -1,15 +1,15 @@
|
||||
package net.minestom.server.network.packet.client.play;
|
||||
|
||||
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.utils.binary.BinaryReader;
|
||||
|
||||
public class ClientUseItemPacket extends ClientPlayPacket {
|
||||
|
||||
public Player.Hand hand;
|
||||
|
||||
@Override
|
||||
public void read(PacketReader reader) {
|
||||
public void read(BinaryReader reader) {
|
||||
this.hand = Player.Hand.values()[reader.readVarInt()];
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user