From fd5bb94cb5f07f7ca7e7ab146d3c29485e3d6fb6 Mon Sep 17 00:00:00 2001 From: Marco Neuhaus Date: Wed, 8 Aug 2018 22:32:29 +0200 Subject: [PATCH] code cleanup --- .../Protocol18w32aTO1_13.java | 275 +----------------- .../packets/EntityPackets.java | 154 ++++++++++ .../packets/InventoryPackets.java | 2 - .../packets/WorldPackets.java | 155 ++++++++++ 4 files changed, 314 insertions(+), 272 deletions(-) create mode 100644 common/src/main/java/us/myles/ViaVersion/protocols/protocol18w32ato1_13/packets/EntityPackets.java create mode 100644 common/src/main/java/us/myles/ViaVersion/protocols/protocol18w32ato1_13/packets/WorldPackets.java diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol18w32ato1_13/Protocol18w32aTO1_13.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol18w32ato1_13/Protocol18w32aTO1_13.java index 1665499f5..1c98516a2 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol18w32ato1_13/Protocol18w32aTO1_13.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol18w32ato1_13/Protocol18w32aTO1_13.java @@ -1,29 +1,26 @@ package us.myles.ViaVersion.protocols.protocol18w32ato1_13; -import com.google.common.base.Optional; import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.data.UserConnection; -import us.myles.ViaVersion.api.entities.Entity1_13Types; -import us.myles.ViaVersion.api.entities.Entity1_13Types.EntityType; -import us.myles.ViaVersion.api.minecraft.BlockChangeRecord; -import us.myles.ViaVersion.api.minecraft.chunks.Chunk; -import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection; import us.myles.ViaVersion.api.protocol.Protocol; import us.myles.ViaVersion.api.remapper.PacketHandler; import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.api.type.Type; -import us.myles.ViaVersion.api.type.types.version.Types1_13; import us.myles.ViaVersion.packets.State; +import us.myles.ViaVersion.protocols.protocol18w32ato1_13.packets.EntityPackets; import us.myles.ViaVersion.protocols.protocol18w32ato1_13.packets.InventoryPackets; +import us.myles.ViaVersion.protocols.protocol18w32ato1_13.packets.WorldPackets; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.EntityTracker; -import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.types.Chunk1_13Type; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; public class Protocol18w32aTO1_13 extends Protocol { @Override protected void registerPackets() { + EntityPackets.register(this); InventoryPackets.register(this); + WorldPackets.register(this); + //Tab complete registerIncoming(State.PLAY, 0x05, 0x05, new PacketRemapper() { @Override @@ -59,111 +56,6 @@ public class Protocol18w32aTO1_13 extends Protocol { } }); - //Chunk - registerOutgoing(State.PLAY, 0x22, 0x22, new PacketRemapper() { - @Override - public void registerMap() { - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - ClientWorld clientWorld = wrapper.user().get(ClientWorld.class); - Chunk chunk = wrapper.passthrough(new Chunk1_13Type(clientWorld)); - - for (int i = 0; i < chunk.getSections().length; i++) { - ChunkSection section = chunk.getSections()[i]; - if (section == null) - continue; - - // TODO improve performance - for (int x = 0; x < 16; x++) { - for (int y = 0; y < 16; y++) { - for (int z = 0; z < 16; z++) { - int block = section.getBlock(x, y, z); - - section.setFlatBlock(x, y, z, getMapBlockId(block)); - } - } - } - } - - } - }); - } - }); - - // Block Change - registerOutgoing(State.PLAY, 0xB, 0xB, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.POSITION); - map(Type.VAR_INT); - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - int id = wrapper.get(Type.VAR_INT, 0); - - wrapper.set(Type.VAR_INT, 0, getMapBlockId(id)); - } - }); - } - }); - - // Multi Block Change - registerOutgoing(State.PLAY, 0xF, 0xF, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.INT); // 0 - Chunk X - map(Type.INT); // 1 - Chunk Z - map(Type.BLOCK_CHANGE_RECORD_ARRAY); // 2 - Records - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - // Convert ids - for (BlockChangeRecord record : wrapper.get(Type.BLOCK_CHANGE_RECORD_ARRAY, 0)) { - int id = record.getBlockId(); - record.setBlockId(getMapBlockId(id)); - } - } - }); - } - }); - - //join game - registerOutgoing(State.PLAY, 0x25, 0x25, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.INT); // 0 - Entity ID - map(Type.UNSIGNED_BYTE); // 1 - Gamemode - map(Type.INT); // 2 - Dimension - - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - // Store the player - ClientWorld clientChunks = wrapper.user().get(ClientWorld.class); - int dimensionId = wrapper.get(Type.INT, 1); - clientChunks.setEnvironment(dimensionId); - } - }); - } - }); - - //respawn - registerOutgoing(State.PLAY, 0x38, 0x38, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.INT); // 0 - Dimension ID - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - ClientWorld clientWorld = wrapper.user().get(ClientWorld.class); - int dimensionId = wrapper.get(Type.INT, 0); - clientWorld.setEnvironment(dimensionId); - } - }); - } - }); - //boss bar registerOutgoing(State.PLAY, 0x0C, 0x0C, new PacketRemapper() { @Override @@ -186,163 +78,6 @@ public class Protocol18w32aTO1_13 extends Protocol { }); } }); - - //spawn particle - registerOutgoing(State.PLAY, 0x24, 0x24, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.INT); // 0 - Particle ID - map(Type.BOOLEAN); // 1 - Long Distance - map(Type.FLOAT); // 2 - X - map(Type.FLOAT); // 3 - Y - map(Type.FLOAT); // 4 - Z - map(Type.FLOAT); // 5 - Offset X - map(Type.FLOAT); // 6 - Offset Y - map(Type.FLOAT); // 7 - Offset Z - map(Type.FLOAT); // 8 - Particle Data - map(Type.INT); // 9 - Particle Count - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - int id = wrapper.get(Type.INT, 0); - if(id == 3 || id == 20){ - int data = wrapper.passthrough(Type.VAR_INT); - wrapper.set(Type.VAR_INT, 0, getMapBlockId(data)); - } - } - }); - } - }); - - //spawn entity - registerOutgoing(State.PLAY, 0x0, 0x0, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.VAR_INT); // 0 - Entity id - map(Type.UUID); // 1 - UUID - map(Type.BYTE); // 2 - Type - map(Type.DOUBLE); // 3 - X - map(Type.DOUBLE); // 4 - Y - map(Type.DOUBLE); // 5 - Z - map(Type.BYTE); // 6 - Pitch - map(Type.BYTE); // 7 - Yaw - map(Type.INT); // 8 - Data - - // Track Entity - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - int entityId = wrapper.get(Type.VAR_INT, 0); - byte type = wrapper.get(Type.BYTE, 0); - Entity1_13Types.EntityType entType = Entity1_13Types.getTypeFromId(type, true); - - if (entType != null) { - if (entType.is(Entity1_13Types.EntityType.FALLING_BLOCK)) { - int data = wrapper.get(Type.INT, 0); - wrapper.set(Type.INT, 0, getMapBlockId(data)); - } - } - // Register Type ID - wrapper.user().get(EntityTracker.class).addEntity(entityId, entType); - } - }); - } - }); - // Spawn mob packet - registerOutgoing(State.PLAY, 0x3, 0x3, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.VAR_INT); // 0 - Entity ID - map(Type.UUID); // 1 - Entity UUID - map(Type.VAR_INT); // 2 - Entity Type - map(Type.DOUBLE); // 3 - X - map(Type.DOUBLE); // 4 - Y - map(Type.DOUBLE); // 5 - Z - map(Type.BYTE); // 6 - Yaw - map(Type.BYTE); // 7 - Pitch - map(Type.BYTE); // 8 - Head Pitch - map(Type.SHORT); // 9 - Velocity X - map(Type.SHORT); // 10 - Velocity Y - map(Type.SHORT); // 11 - Velocity Z - map(Types1_13.METADATA_LIST); // 12 - Metadata - - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - int entityId = wrapper.get(Type.VAR_INT, 0); - int type = wrapper.get(Type.VAR_INT, 1); - - Entity1_13Types.EntityType entType = Entity1_13Types.getTypeFromId(type, false); - - // Register Type ID - wrapper.user().get(EntityTracker.class).addEntity(entityId, entType); - - MetadataRewriter.handleMetadata(entityId, entType, wrapper.get(Types1_13.METADATA_LIST, 0), wrapper.user()); - } - }); - } - }); - - // Spawn player packet - registerOutgoing(State.PLAY, 0x05, 0x05, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.VAR_INT); // 0 - Entity ID - map(Type.UUID); // 1 - Player UUID - map(Type.DOUBLE); // 2 - X - map(Type.DOUBLE); // 3 - Y - map(Type.DOUBLE); // 4 - Z - map(Type.BYTE); // 5 - Yaw - map(Type.BYTE); // 6 - Pitch - map(Types1_13.METADATA_LIST); // 7 - Metadata - - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - int entityId = wrapper.get(Type.VAR_INT, 0); - - Entity1_13Types.EntityType entType = Entity1_13Types.EntityType.PLAYER; - // Register Type ID - wrapper.user().get(EntityTracker.class).addEntity(entityId, entType); - MetadataRewriter.handleMetadata(entityId, entType, wrapper.get(Types1_13.METADATA_LIST, 0), wrapper.user()); - } - }); - } - }); - // Destroy entities - registerOutgoing(State.PLAY, 0x35, 0x35, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.VAR_INT_ARRAY); // 0 - Entity IDS - - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - for (int entity : wrapper.get(Type.VAR_INT_ARRAY, 0)) - wrapper.user().get(EntityTracker.class).removeEntity(entity); - } - }); - } - }); - - - // Metadata packet - registerOutgoing(State.PLAY, 0x3F, 0x3F, new PacketRemapper() { - @Override - public void registerMap() { - map(Type.VAR_INT); // 0 - Entity ID - map(Types1_13.METADATA_LIST); // 1 - Metadata list - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - int entityId = wrapper.get(Type.VAR_INT, 0); - - Optional type = wrapper.user().get(EntityTracker.class).get(entityId); - MetadataRewriter.handleMetadata(entityId, type.orNull(), wrapper.get(Types1_13.METADATA_LIST, 0), wrapper.user()); - } - }); - } - }); } @Override diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol18w32ato1_13/packets/EntityPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol18w32ato1_13/packets/EntityPackets.java new file mode 100644 index 000000000..d8366968f --- /dev/null +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol18w32ato1_13/packets/EntityPackets.java @@ -0,0 +1,154 @@ +package us.myles.ViaVersion.protocols.protocol18w32ato1_13.packets; + +import com.google.common.base.Optional; +import us.myles.ViaVersion.api.PacketWrapper; +import us.myles.ViaVersion.api.entities.Entity1_13Types; +import us.myles.ViaVersion.api.entities.Entity1_13Types.EntityType; +import us.myles.ViaVersion.api.protocol.Protocol; +import us.myles.ViaVersion.api.remapper.PacketHandler; +import us.myles.ViaVersion.api.remapper.PacketRemapper; +import us.myles.ViaVersion.api.type.Type; +import us.myles.ViaVersion.api.type.types.version.Types1_13; +import us.myles.ViaVersion.packets.State; +import us.myles.ViaVersion.protocols.protocol18w32ato1_13.MetadataRewriter; +import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.EntityTracker; +import us.myles.ViaVersion.protocols.protocol18w32ato1_13.Protocol18w32aTO1_13; +/** + * Created by Marco Neuhaus on 08.08.2018 for the Project ViaVersion2. + */ +public class EntityPackets { + + public static void register(Protocol protocol) { + + //spawn entity + protocol.registerOutgoing(State.PLAY, 0x0, 0x0, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT); // 0 - Entity id + map(Type.UUID); // 1 - UUID + map(Type.BYTE); // 2 - Type + map(Type.DOUBLE); // 3 - X + map(Type.DOUBLE); // 4 - Y + map(Type.DOUBLE); // 5 - Z + map(Type.BYTE); // 6 - Pitch + map(Type.BYTE); // 7 - Yaw + map(Type.INT); // 8 - Data + + // Track Entity + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + int entityId = wrapper.get(Type.VAR_INT, 0); + byte type = wrapper.get(Type.BYTE, 0); + Entity1_13Types.EntityType entType = Entity1_13Types.getTypeFromId(type, true); + + if (entType != null) { + if (entType.is(Entity1_13Types.EntityType.FALLING_BLOCK)) { + int data = wrapper.get(Type.INT, 0); + wrapper.set(Type.INT, 0, Protocol18w32aTO1_13.getMapBlockId(data)); + } + } + // Register Type ID + wrapper.user().get(EntityTracker.class).addEntity(entityId, entType); + } + }); + } + }); + // Spawn mob packet + protocol.registerOutgoing(State.PLAY, 0x3, 0x3, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT); // 0 - Entity ID + map(Type.UUID); // 1 - Entity UUID + map(Type.VAR_INT); // 2 - Entity Type + map(Type.DOUBLE); // 3 - X + map(Type.DOUBLE); // 4 - Y + map(Type.DOUBLE); // 5 - Z + map(Type.BYTE); // 6 - Yaw + map(Type.BYTE); // 7 - Pitch + map(Type.BYTE); // 8 - Head Pitch + map(Type.SHORT); // 9 - Velocity X + map(Type.SHORT); // 10 - Velocity Y + map(Type.SHORT); // 11 - Velocity Z + map(Types1_13.METADATA_LIST); // 12 - Metadata + + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + int entityId = wrapper.get(Type.VAR_INT, 0); + int type = wrapper.get(Type.VAR_INT, 1); + + Entity1_13Types.EntityType entType = Entity1_13Types.getTypeFromId(type, false); + + // Register Type ID + wrapper.user().get(EntityTracker.class).addEntity(entityId, entType); + + MetadataRewriter.handleMetadata(entityId, entType, wrapper.get(Types1_13.METADATA_LIST, 0), wrapper.user()); + } + }); + } + }); + + // Spawn player packet + protocol.registerOutgoing(State.PLAY, 0x05, 0x05, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT); // 0 - Entity ID + map(Type.UUID); // 1 - Player UUID + map(Type.DOUBLE); // 2 - X + map(Type.DOUBLE); // 3 - Y + map(Type.DOUBLE); // 4 - Z + map(Type.BYTE); // 5 - Yaw + map(Type.BYTE); // 6 - Pitch + map(Types1_13.METADATA_LIST); // 7 - Metadata + + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + int entityId = wrapper.get(Type.VAR_INT, 0); + + Entity1_13Types.EntityType entType = Entity1_13Types.EntityType.PLAYER; + // Register Type ID + wrapper.user().get(EntityTracker.class).addEntity(entityId, entType); + MetadataRewriter.handleMetadata(entityId, entType, wrapper.get(Types1_13.METADATA_LIST, 0), wrapper.user()); + } + }); + } + }); + // Destroy entities + protocol.registerOutgoing(State.PLAY, 0x35, 0x35, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT_ARRAY); // 0 - Entity IDS + + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + for (int entity : wrapper.get(Type.VAR_INT_ARRAY, 0)) + wrapper.user().get(EntityTracker.class).removeEntity(entity); + } + }); + } + }); + + + // Metadata packet + protocol.registerOutgoing(State.PLAY, 0x3F, 0x3F, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT); // 0 - Entity ID + map(Types1_13.METADATA_LIST); // 1 - Metadata list + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + int entityId = wrapper.get(Type.VAR_INT, 0); + + Optional type = wrapper.user().get(EntityTracker.class).get(entityId); + MetadataRewriter.handleMetadata(entityId, type.orNull(), wrapper.get(Types1_13.METADATA_LIST, 0), wrapper.user()); + } + }); + } + }); + } + +} diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol18w32ato1_13/packets/InventoryPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol18w32ato1_13/packets/InventoryPackets.java index 132c4ef9a..825df9fdb 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol18w32ato1_13/packets/InventoryPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol18w32ato1_13/packets/InventoryPackets.java @@ -119,8 +119,6 @@ public class InventoryPackets { ); } - // TODO CLEANUP / SMARTER REWRITE SYSTEM - // TODO Rewrite identifiers public static void toClient(Item item) { if (item == null) return; if(item.getId() >= 443){ diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol18w32ato1_13/packets/WorldPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol18w32ato1_13/packets/WorldPackets.java new file mode 100644 index 000000000..c28aa4834 --- /dev/null +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol18w32ato1_13/packets/WorldPackets.java @@ -0,0 +1,155 @@ +package us.myles.ViaVersion.protocols.protocol18w32ato1_13.packets; + +import us.myles.ViaVersion.api.PacketWrapper; +import us.myles.ViaVersion.api.minecraft.BlockChangeRecord; +import us.myles.ViaVersion.api.minecraft.chunks.Chunk; +import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection; +import us.myles.ViaVersion.api.protocol.Protocol; +import us.myles.ViaVersion.api.remapper.PacketHandler; +import us.myles.ViaVersion.api.remapper.PacketRemapper; +import us.myles.ViaVersion.api.type.Type; +import us.myles.ViaVersion.packets.State; +import us.myles.ViaVersion.protocols.protocol18w32ato1_13.Protocol18w32aTO1_13; +import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.types.Chunk1_13Type; +import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; + +/** + * Created by Marco Neuhaus on 08.08.2018 for the Project ViaVersion2. + */ +public class WorldPackets { + + public static void register(Protocol protocol) { + //Chunk + protocol.registerOutgoing(State.PLAY, 0x22, 0x22, new PacketRemapper() { + @Override + public void registerMap() { + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + ClientWorld clientWorld = wrapper.user().get(ClientWorld.class); + Chunk chunk = wrapper.passthrough(new Chunk1_13Type(clientWorld)); + + for (int i = 0; i < chunk.getSections().length; i++) { + ChunkSection section = chunk.getSections()[i]; + if (section == null) + continue; + + // TODO improve performance + for (int x = 0; x < 16; x++) { + for (int y = 0; y < 16; y++) { + for (int z = 0; z < 16; z++) { + int block = section.getBlock(x, y, z); + + section.setFlatBlock(x, y, z, Protocol18w32aTO1_13.getMapBlockId(block)); + } + } + } + } + + } + }); + } + }); + + // Block Change + protocol.registerOutgoing(State.PLAY, 0xB, 0xB, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.POSITION); + map(Type.VAR_INT); + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + int id = wrapper.get(Type.VAR_INT, 0); + + wrapper.set(Type.VAR_INT, 0, Protocol18w32aTO1_13.getMapBlockId(id)); + } + }); + } + }); + + // Multi Block Change + protocol.registerOutgoing(State.PLAY, 0xF, 0xF, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.INT); // 0 - Chunk X + map(Type.INT); // 1 - Chunk Z + map(Type.BLOCK_CHANGE_RECORD_ARRAY); // 2 - Records + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + // Convert ids + for (BlockChangeRecord record : wrapper.get(Type.BLOCK_CHANGE_RECORD_ARRAY, 0)) { + int id = record.getBlockId(); + record.setBlockId(Protocol18w32aTO1_13.getMapBlockId(id)); + } + } + }); + } + }); + + //join game + protocol.registerOutgoing(State.PLAY, 0x25, 0x25, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.INT); // 0 - Entity ID + map(Type.UNSIGNED_BYTE); // 1 - Gamemode + map(Type.INT); // 2 - Dimension + + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + // Store the player + ClientWorld clientChunks = wrapper.user().get(ClientWorld.class); + int dimensionId = wrapper.get(Type.INT, 1); + clientChunks.setEnvironment(dimensionId); + } + }); + } + }); + + //respawn + protocol.registerOutgoing(State.PLAY, 0x38, 0x38, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.INT); // 0 - Dimension ID + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + ClientWorld clientWorld = wrapper.user().get(ClientWorld.class); + int dimensionId = wrapper.get(Type.INT, 0); + clientWorld.setEnvironment(dimensionId); + } + }); + } + }); + + //spawn particle + protocol.registerOutgoing(State.PLAY, 0x24, 0x24, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.INT); // 0 - Particle ID + map(Type.BOOLEAN); // 1 - Long Distance + map(Type.FLOAT); // 2 - X + map(Type.FLOAT); // 3 - Y + map(Type.FLOAT); // 4 - Z + map(Type.FLOAT); // 5 - Offset X + map(Type.FLOAT); // 6 - Offset Y + map(Type.FLOAT); // 7 - Offset Z + map(Type.FLOAT); // 8 - Particle Data + map(Type.INT); // 9 - Particle Count + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + int id = wrapper.get(Type.INT, 0); + if(id == 3 || id == 20){ + int data = wrapper.passthrough(Type.VAR_INT); + wrapper.set(Type.VAR_INT, 0, Protocol18w32aTO1_13.getMapBlockId(data)); + } + } + }); + } + }); + } + +}