From 27fc4dd6848e94328cfd7fc0e424a189ec265e02 Mon Sep 17 00:00:00 2001 From: Matsv Date: Tue, 4 Oct 2016 19:35:20 +0200 Subject: [PATCH] Rewrite sounds, thanks @Pokechu22 for open-sourcing your forks of Hamburglar & Burger Vitrine :) --- .../ProtocolSnapshotTo1_10.java | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_10/ProtocolSnapshotTo1_10.java b/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_10/ProtocolSnapshotTo1_10.java index d12fe33d0..750127ed7 100644 --- a/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_10/ProtocolSnapshotTo1_10.java +++ b/src/main/java/us/myles/ViaVersion/protocols/protocolsnapshotto1_10/ProtocolSnapshotTo1_10.java @@ -58,6 +58,32 @@ public class ProtocolSnapshotTo1_10 extends Protocol { } }); + // Sound effect + registerOutgoing(State.PLAY, 0x46, 0x46, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT); // 0 - Sound name + map(Type.VAR_INT); // 1 - Sound Category + map(Type.INT); // 2 - x + map(Type.INT); // 3 - y + map(Type.INT); // 4 - z + map(Type.FLOAT); // 5 - Volume + map(Type.FLOAT); // 6 - Pitch + + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + int id = wrapper.get(Type.VAR_INT, 0); + id = getNewSoundId(id); + + if (id == -1) // Removed + wrapper.cancel(); + wrapper.set(Type.VAR_INT, 0, id); + } + }); + } + }); + // Collect item packet registerOutgoing(State.PLAY, 0x48, 0x48, new PacketRemapper() { @Override @@ -129,6 +155,31 @@ public class ProtocolSnapshotTo1_10 extends Protocol { }); } + private int getNewSoundId(int id) { //TODO Make it better, suggestions are welcome. It's ugly and hardcoded now. + if (id == 196) // Experience orb sound got removed + return -1; + + int newId = id; + if (id >= 85) // Hello shulker boxes + newId += 2; + if (id >= 194) // Hello evocation things + newId += 8; + if (id >= 196) // Rip the Experience orb touch sound :'( + newId -= 1; + if (id >= 269) // Hello Liama's + newId += 8; + if (id >= 370) // Hello Vex + newId += 4; + if (id >= 376) // Hello vindication + newId += 3; + if (id >= 427) // Hello empty bottle + newId += 1; + if (id > 441) // Hello item totem use + newId += 1; + return newId; + } + + @Override public void init(UserConnection userConnection) { userConnection.put(new EntityTracker(userConnection));