From e4346611c9c74d203447ae1702133b6963c07c61 Mon Sep 17 00:00:00 2001 From: HugoDaBosss Date: Thu, 3 Mar 2016 01:40:24 +0100 Subject: [PATCH 1/3] Small optimization --- src/main/java/us/myles/ViaVersion/packets/PacketType.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/us/myles/ViaVersion/packets/PacketType.java b/src/main/java/us/myles/ViaVersion/packets/PacketType.java index e0dbd4066..fcd44c65b 100644 --- a/src/main/java/us/myles/ViaVersion/packets/PacketType.java +++ b/src/main/java/us/myles/ViaVersion/packets/PacketType.java @@ -170,7 +170,7 @@ public enum PacketType { if(id == -1) return null; for (PacketType pt : values()) { - if (pt.getNewPacketID() == id && id != -1 + if (pt.getNewPacketID() == id && pt.getState() == state && pt.getDirection() == direction) return pt; @@ -182,7 +182,7 @@ public enum PacketType { if(id == -1) return null; for (PacketType pt : values()) { - if (pt.getPacketID() == id && id != -1 + if (pt.getPacketID() == id && pt.getState() == state && pt.getDirection() == direction) return pt; From afb96c4878b5a471e4ddbb335e29c5a977528282 Mon Sep 17 00:00:00 2001 From: HugoDaBosss Date: Thu, 3 Mar 2016 10:06:24 +0100 Subject: [PATCH 2/3] Fixed double break sound --- src/main/java/us/myles/ViaVersion/sounds/SoundEffect.java | 7 +++++++ .../myles/ViaVersion/transformers/OutgoingTransformer.java | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/src/main/java/us/myles/ViaVersion/sounds/SoundEffect.java b/src/main/java/us/myles/ViaVersion/sounds/SoundEffect.java index a78b2e8a8..d2f93b084 100644 --- a/src/main/java/us/myles/ViaVersion/sounds/SoundEffect.java +++ b/src/main/java/us/myles/ViaVersion/sounds/SoundEffect.java @@ -252,11 +252,13 @@ public enum SoundEffect { private String name; private String newname; private SoundCategory cat; + private boolean breaksound; SoundEffect(String name, String newname, SoundCategory cat) { this.cat = cat; this.newname = newname; this.name = name; + this.breaksound = name.startsWith("dig."); } public static SoundEffect getByName(String name) { @@ -279,5 +281,10 @@ public enum SoundEffect { public SoundCategory getCategory() { return cat; } + + public boolean isBreakPlaceSound() + { + return breaksound; + } } diff --git a/src/main/java/us/myles/ViaVersion/transformers/OutgoingTransformer.java b/src/main/java/us/myles/ViaVersion/transformers/OutgoingTransformer.java index ceda3a0f8..6fc6583d9 100644 --- a/src/main/java/us/myles/ViaVersion/transformers/OutgoingTransformer.java +++ b/src/main/java/us/myles/ViaVersion/transformers/OutgoingTransformer.java @@ -59,6 +59,12 @@ public class OutgoingTransformer { int catid = 0; String newname = name; if (effect != null) { + if(effect.isBreakPlaceSound()) + { + input.readBytes(input.readableBytes()); + output.clear(); + return; + } catid = effect.getCategory().getId(); newname = effect.getNewName(); } From 29d2334ef07eac6472e8d8d2c267e21c33a8b032 Mon Sep 17 00:00:00 2001 From: HugoDaBosss Date: Thu, 3 Mar 2016 10:09:38 +0100 Subject: [PATCH 3/3] Fixed bracket markup ;) --- src/main/java/us/myles/ViaVersion/sounds/SoundEffect.java | 3 +-- .../us/myles/ViaVersion/transformers/OutgoingTransformer.java | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/us/myles/ViaVersion/sounds/SoundEffect.java b/src/main/java/us/myles/ViaVersion/sounds/SoundEffect.java index d2f93b084..8c1c8b840 100644 --- a/src/main/java/us/myles/ViaVersion/sounds/SoundEffect.java +++ b/src/main/java/us/myles/ViaVersion/sounds/SoundEffect.java @@ -282,8 +282,7 @@ public enum SoundEffect { return cat; } - public boolean isBreakPlaceSound() - { + public boolean isBreakPlaceSound() { return breaksound; } diff --git a/src/main/java/us/myles/ViaVersion/transformers/OutgoingTransformer.java b/src/main/java/us/myles/ViaVersion/transformers/OutgoingTransformer.java index 6fc6583d9..13679fc26 100644 --- a/src/main/java/us/myles/ViaVersion/transformers/OutgoingTransformer.java +++ b/src/main/java/us/myles/ViaVersion/transformers/OutgoingTransformer.java @@ -59,8 +59,7 @@ public class OutgoingTransformer { int catid = 0; String newname = name; if (effect != null) { - if(effect.isBreakPlaceSound()) - { + if(effect.isBreakPlaceSound()) { input.readBytes(input.readableBytes()); output.clear(); return;