From 650f89e1ce87dc6f539d9384e51f9df3ebcd7afe Mon Sep 17 00:00:00 2001 From: KennyTV Date: Thu, 9 Jul 2020 17:10:31 +0200 Subject: [PATCH] Don't send air block break particles to sub 1.12 players Fixes #227 --- .../protocol1_12_2to1_13/data/ParticleMapping.java | 12 ++++++++++-- .../packets/EntityPackets1_13.java | 5 +++++ .../packets/PlayerPacket1_13.java | 9 ++++++++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/data/ParticleMapping.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/data/ParticleMapping.java index 680cdf7c..9daca4ba 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/data/ParticleMapping.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/data/ParticleMapping.java @@ -39,9 +39,13 @@ public class ParticleMapping { int type = blockType >> 4; int meta = blockType & 15; - return new int[]{type + (meta << 12)}; } + + @Override + public boolean isBlockHandler() { + return true; + } }; particles = new ParticleData[]{ @@ -148,11 +152,15 @@ public class ParticleMapping { return new ParticleData(replacementId, handler); } - interface ParticleHandler { + public interface ParticleHandler { int[] rewrite(Protocol1_12_2To1_13 protocol, PacketWrapper wrapper) throws Exception; int[] rewrite(Protocol1_12_2To1_13 protocol, List data); + + default boolean isBlockHandler() { + return false; + } } public static final class ParticleData { diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/EntityPackets1_13.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/EntityPackets1_13.java index 6c9e36b5..7c61d492 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/EntityPackets1_13.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/EntityPackets1_13.java @@ -382,6 +382,11 @@ public class EntityPackets1_13 extends LegacyEntityRewriter glass pane + particleArgs[0] = 102; + } + firstArg = particleArgs[0]; secondArg = particleArgs.length == 2 ? particleArgs[1] : 0; } diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/PlayerPacket1_13.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/PlayerPacket1_13.java index 310cfc4b..c3767c19 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/PlayerPacket1_13.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/PlayerPacket1_13.java @@ -139,8 +139,15 @@ public class PlayerPacket1_13 extends Rewriter { int[] data = old.rewriteData(protocol, wrapper); if (data != null) { - for (int i : data) + if (old.getHandler().isBlockHandler() && data[0] == 0) { + // Cancel air block particles + wrapper.cancel(); + return; + } + + for (int i : data) { wrapper.write(Type.VAR_INT, i); + } } } });