From c3fc8b5f18463a0497d2ec7b4ddae35eb44e0f84 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Sat, 19 Mar 2022 15:56:22 +0100 Subject: [PATCH] Actually fix particles Fixes #2850 --- .../packets/InventoryPackets.java | 2 +- .../viaversion/rewriter/ItemRewriter.java | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/packets/InventoryPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/packets/InventoryPackets.java index f39f695a2..6d434d334 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/packets/InventoryPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/packets/InventoryPackets.java @@ -54,7 +54,7 @@ public final class InventoryPackets extends ItemRewriter { map(Type.FLOAT); // 7 - Offset Z map(Type.FLOAT); // 8 - Particle Data map(Type.INT); // 9 - Particle Count - handler(getSpawnParticleHandler(Type.FLAT_VAR_INT_ITEM)); + handler(getSpawnParticleHandler(Type.VAR_INT, Type.FLAT_VAR_INT_ITEM)); } }); diff --git a/common/src/main/java/com/viaversion/viaversion/rewriter/ItemRewriter.java b/common/src/main/java/com/viaversion/viaversion/rewriter/ItemRewriter.java index 3af935c6c..54c3e24d1 100644 --- a/common/src/main/java/com/viaversion/viaversion/rewriter/ItemRewriter.java +++ b/common/src/main/java/com/viaversion/viaversion/rewriter/ItemRewriter.java @@ -313,27 +313,31 @@ public abstract class ItemRewriter extends RewriterBase i map(Type.FLOAT); // 7 - Offset Z map(Type.FLOAT); // 8 - Particle Data map(Type.INT); // 9 - Particle Count - handler(getSpawnParticleHandler(itemType)); + handler(getSpawnParticleHandler(Type.VAR_INT, itemType)); } }); } public PacketHandler getSpawnParticleHandler(Type itemType) { + return getSpawnParticleHandler(Type.INT, itemType); + } + + public PacketHandler getSpawnParticleHandler(Type idType, Type itemType) { return wrapper -> { - int id = wrapper.get(Type.INT, 0); + int id = wrapper.get(idType, 0); if (id == -1) return; ParticleMappings mappings = protocol.getMappingData().getParticleMappings(); if (mappings.isBlockParticle(id)) { - int data = wrapper.passthrough(Type.VAR_INT); - wrapper.set(Type.VAR_INT, 0, protocol.getMappingData().getNewBlockStateId(data)); + int data = wrapper.read(Type.VAR_INT); + wrapper.write(Type.VAR_INT, protocol.getMappingData().getNewBlockStateId(data)); } else if (mappings.isItemParticle(id)) { handleItemToClient(wrapper.passthrough(itemType)); } int newId = protocol.getMappingData().getNewParticleId(id); if (newId != id) { - wrapper.set(Type.INT, 0, newId); + wrapper.set(idType, 0, newId); } }; }