diff --git a/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/WorldPackets.java b/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/WorldPackets.java index 8c6a0523f..ef5464a53 100644 --- a/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/WorldPackets.java +++ b/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/WorldPackets.java @@ -17,6 +17,7 @@ import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.protocols.protocol1_9to1_8.ArmorType; import us.myles.ViaVersion.protocols.protocol1_9to1_8.ItemRewriter; import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8; +import us.myles.ViaVersion.protocols.protocol1_9to1_8.sounds.Effect; import us.myles.ViaVersion.protocols.protocol1_9to1_8.sounds.SoundEffect; import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.ClientChunks; import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.EntityTracker; @@ -49,12 +50,8 @@ public class WorldPackets { @Override public void handle(PacketWrapper wrapper) throws Exception { int id = wrapper.get(Type.INT, 0); - if (id >= 1000 && id < 2000 && id != 1005) { // Sound Effect - wrapper.cancel(); - } - if (id == 1005) { // Fix jukebox - id = 1010; - } + + id = Effect.getNewId(id); wrapper.set(Type.INT, 0, id); } }); diff --git a/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/sounds/Effect.java b/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/sounds/Effect.java new file mode 100644 index 000000000..50cdc2a26 --- /dev/null +++ b/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/sounds/Effect.java @@ -0,0 +1,47 @@ +package us.myles.ViaVersion.protocols.protocol1_9to1_8.sounds; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +import java.util.HashMap; + +public class Effect { + + private static HashMap effects; + + static { + effects = new HashMap<>(); + addRewrite(1005, 1010); //Play music disc + addRewrite(1003, 1005); //Iron door open + addRewrite(1006, 1011); //Iron door close + addRewrite(1004, 1009); //Fizz / Fire extinguished + addRewrite(1007, 1015); //Ghast charge / warns + addRewrite(1008, 1016); //Ghast shoot + addRewrite(1009, 1016); //Ghast shoot (Lower volume according to wiki.vg) + addRewrite(1010, 1019); //Zombie attacks wood door + addRewrite(1011, 1020); //Zombie attacks metal door + addRewrite(1012, 1021); //Zombie breaks wood door + addRewrite(1014, 1024); //Wither shoot + addRewrite(1015, 1025); //Bat takeoff / aka herobrine + addRewrite(1016, 1026); //Zombie inject + addRewrite(1017, 1027); //Zombie villager converted + addRewrite(1020, 1029); //Anvil break + addRewrite(1021, 1030); //Anvil use + addRewrite(1022, 1031); //Anvil land + + } + + public static int getNewId(int id) { + if (!contains(id)) + return id; + return effects.get(id); + } + + public static boolean contains(int oldId){ + return effects.containsKey(oldId); + } + + private static void addRewrite(int oldId, int newId){ + effects.put(oldId, newId); + } +}