From a35408d14fc4f4c27b8df4c3297b35d4ac42bf4a Mon Sep 17 00:00:00 2001 From: Myles Date: Thu, 15 Dec 2016 15:32:54 +0000 Subject: [PATCH] New config option for disabling piston animation for 1.11 clients #570 --- .../bukkit/platform/BukkitConfigAPI.java | 5 ++++ .../bungee/platform/BungeeConfigAPI.java | 5 ++++ .../ViaVersion/api/ViaVersionConfig.java | 7 ++++++ .../Protocol1_11To1_10.java | 24 +++++++++++++++++++ common/src/main/resources/config.yml | 3 +++ .../sponge/platform/SpongeConfigAPI.java | 5 ++++ 6 files changed, 49 insertions(+) diff --git a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/platform/BukkitConfigAPI.java b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/platform/BukkitConfigAPI.java index 54820614e..e04157d64 100644 --- a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/platform/BukkitConfigAPI.java +++ b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/platform/BukkitConfigAPI.java @@ -52,6 +52,11 @@ public class BukkitConfigAPI extends Config implements ViaVersionConfig { return getBoolean("hologram-patch", false); } + @Override + public boolean isPistonAnimationPatch() { + return getBoolean("piston-animation-patch", false); + } + @Override public boolean isBossbarPatch() { return getBoolean("bossbar-patch", true); diff --git a/bungee/src/main/java/us/myles/ViaVersion/bungee/platform/BungeeConfigAPI.java b/bungee/src/main/java/us/myles/ViaVersion/bungee/platform/BungeeConfigAPI.java index fba410c80..fef66fe0b 100644 --- a/bungee/src/main/java/us/myles/ViaVersion/bungee/platform/BungeeConfigAPI.java +++ b/bungee/src/main/java/us/myles/ViaVersion/bungee/platform/BungeeConfigAPI.java @@ -86,6 +86,11 @@ public class BungeeConfigAPI extends Config implements ViaVersionConfig { return getBoolean("hologram-patch", false); } + @Override + public boolean isPistonAnimationPatch() { + return getBoolean("piston-animation-patch", false); + } + @Override public boolean isBossbarPatch() { return getBoolean("bossbar-patch", true); diff --git a/common/src/main/java/us/myles/ViaVersion/api/ViaVersionConfig.java b/common/src/main/java/us/myles/ViaVersion/api/ViaVersionConfig.java index 0c0313b7a..dafdc62e0 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/ViaVersionConfig.java +++ b/common/src/main/java/us/myles/ViaVersion/api/ViaVersionConfig.java @@ -53,6 +53,13 @@ public interface ViaVersionConfig { */ boolean isHologramPatch(); + /** + * Get if the 1.11 piston animation patch is enabled + * + * @return true if the piston patch is enabled. + */ + boolean isPistonAnimationPatch(); + /** * Get if boss bars are fixed for 1.9 & 1.10 clients * diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_11to1_10/Protocol1_11To1_10.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_11to1_10/Protocol1_11To1_10.java index e74936c07..d28981ca6 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_11to1_10/Protocol1_11To1_10.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_11to1_10/Protocol1_11To1_10.java @@ -219,6 +219,30 @@ public class Protocol1_11To1_10 extends Protocol { } }); + // Block action packet + registerOutgoing(State.PLAY, 0x0A, 0x0A, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.POSITION); // 0 - Position + map(Type.UNSIGNED_BYTE); // 1 - Action ID + map(Type.UNSIGNED_BYTE); // 2 - Action Param + map(Type.VAR_INT); // 3 - Block Type + + // Cheap hack to ensure it's always right block + handler(new PacketHandler() { + @Override + public void handle(final PacketWrapper actionWrapper) throws Exception { + if (Via.getConfig().isPistonAnimationPatch()) { + int id = actionWrapper.get(Type.VAR_INT, 0); + if (id == 33 || id == 29) { + actionWrapper.cancel(); + } + } + } + }); + } + }); + /* INCOMING PACKETS */ diff --git a/common/src/main/resources/config.yml b/common/src/main/resources/config.yml index ff47962aa..fe7d749e5 100644 --- a/common/src/main/resources/config.yml +++ b/common/src/main/resources/config.yml @@ -79,6 +79,9 @@ tracking-max-kick-msg: "You are sending too many packets, :(" hologram-patch: false # This is the offset, should work as default when enabled. hologram-y: -0.96 +# Should we disable piston animation for 1.11/1.11.1 clients? +# In some cases when firing lots of pistons it crashes them. +piston-animation-patch: false # #----------------------------------------------------------# # 1.9 & 1.10 CLIENTS ON 1.8 SERVERS OPTIONS # diff --git a/sponge/src/main/java/us/myles/ViaVersion/sponge/platform/SpongeConfigAPI.java b/sponge/src/main/java/us/myles/ViaVersion/sponge/platform/SpongeConfigAPI.java index b7e4df980..b9e24bc2d 100644 --- a/sponge/src/main/java/us/myles/ViaVersion/sponge/platform/SpongeConfigAPI.java +++ b/sponge/src/main/java/us/myles/ViaVersion/sponge/platform/SpongeConfigAPI.java @@ -59,6 +59,11 @@ public class SpongeConfigAPI extends Config implements ViaVersionConfig { return getBoolean("hologram-patch", false); } + @Override + public boolean isPistonAnimationPatch() { + return getBoolean("piston-animation-patch", false); + } + @Override public boolean isBossbarPatch() { return getBoolean("bossbar-patch", true);