From 2b29d27b0d2f06e358b38f0c740fac744db6215f Mon Sep 17 00:00:00 2001 From: Mats Date: Mon, 7 Mar 2016 23:04:24 +0100 Subject: [PATCH 1/3] Fix jukebox --- .../myles/ViaVersion/transformers/OutgoingTransformer.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/us/myles/ViaVersion/transformers/OutgoingTransformer.java b/src/main/java/us/myles/ViaVersion/transformers/OutgoingTransformer.java index e3dd9e96e..3000a628b 100644 --- a/src/main/java/us/myles/ViaVersion/transformers/OutgoingTransformer.java +++ b/src/main/java/us/myles/ViaVersion/transformers/OutgoingTransformer.java @@ -3,6 +3,7 @@ package us.myles.ViaVersion.transformers; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufInputStream; import io.netty.buffer.ByteBufOutputStream; +import org.bukkit.Bukkit; import org.bukkit.entity.EntityType; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; @@ -106,8 +107,11 @@ public class OutgoingTransformer { } if (packet == PacketType.PLAY_EFFECT) { int effectid = input.readInt(); - if (effectid >= 1000 && effectid < 2000) //Sound effect + + if (effectid >= 1000 && effectid < 2000 && effectid != 1005) //Sound effect throw new CancelException(); + if (effectid == 1005) + effectid = 1010; output.writeInt(effectid); } if (packet == PacketType.PLAY_ATTACH_ENTITY) { From cc354db4649462316bbc4e2a6e8c88cfe62359b0 Mon Sep 17 00:00:00 2001 From: Mats Date: Mon, 7 Mar 2016 23:07:17 +0100 Subject: [PATCH 2/3] Formatting --- .../ViaVersion/transformers/OutgoingTransformer.java | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/main/java/us/myles/ViaVersion/transformers/OutgoingTransformer.java b/src/main/java/us/myles/ViaVersion/transformers/OutgoingTransformer.java index 3000a628b..d05155afe 100644 --- a/src/main/java/us/myles/ViaVersion/transformers/OutgoingTransformer.java +++ b/src/main/java/us/myles/ViaVersion/transformers/OutgoingTransformer.java @@ -1,16 +1,12 @@ package us.myles.ViaVersion.transformers; import io.netty.buffer.ByteBuf; -import io.netty.buffer.ByteBufInputStream; -import io.netty.buffer.ByteBufOutputStream; -import org.bukkit.Bukkit; import org.bukkit.entity.EntityType; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; import org.spacehq.mc.protocol.data.game.chunk.Column; import org.spacehq.mc.protocol.util.NetUtil; -import org.spacehq.opennbt.NBTIO; import org.spacehq.opennbt.tag.builtin.ByteTag; import org.spacehq.opennbt.tag.builtin.CompoundTag; import org.spacehq.opennbt.tag.builtin.StringTag; @@ -27,8 +23,6 @@ import us.myles.ViaVersion.util.EntityUtil; import us.myles.ViaVersion.util.PacketUtil; import us.myles.ViaVersion.util.ReflectionUtil; -import java.io.DataInputStream; -import java.io.DataOutputStream; import java.io.IOException; import java.util.*; @@ -107,7 +101,6 @@ public class OutgoingTransformer { } if (packet == PacketType.PLAY_EFFECT) { int effectid = input.readInt(); - if (effectid >= 1000 && effectid < 2000 && effectid != 1005) //Sound effect throw new CancelException(); if (effectid == 1005) @@ -687,12 +680,12 @@ public class OutgoingTransformer { CompoundTag spawn = new CompoundTag("SpawnData"); spawn.put(new StringTag("id", entity)); tag.put(spawn); - PacketUtil.writeNBT(output,tag); + PacketUtil.writeNBT(output, tag); } else if (tag != null) { // EntityID does not exist CompoundTag spawn = new CompoundTag("SpawnData"); spawn.put(new StringTag("id", "AreaEffectCloud")); //Make spawners show up as empty when no EntityId is given. tag.put(spawn); - PacketUtil.writeNBT(output,spawn); + PacketUtil.writeNBT(output, spawn); } else { //There doesn't exist any NBT tag input.readerIndex(index); output.writeBytes(input, input.readableBytes()); From ee9d8d63654dca3e50e1413c8a8c320081323b31 Mon Sep 17 00:00:00 2001 From: Mats Date: Mon, 7 Mar 2016 23:08:34 +0100 Subject: [PATCH 3/3] Add comment for other people --- .../us/myles/ViaVersion/transformers/OutgoingTransformer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/us/myles/ViaVersion/transformers/OutgoingTransformer.java b/src/main/java/us/myles/ViaVersion/transformers/OutgoingTransformer.java index d05155afe..fb0803b96 100644 --- a/src/main/java/us/myles/ViaVersion/transformers/OutgoingTransformer.java +++ b/src/main/java/us/myles/ViaVersion/transformers/OutgoingTransformer.java @@ -103,7 +103,7 @@ public class OutgoingTransformer { int effectid = input.readInt(); if (effectid >= 1000 && effectid < 2000 && effectid != 1005) //Sound effect throw new CancelException(); - if (effectid == 1005) + if (effectid == 1005) //Fix jukebox effectid = 1010; output.writeInt(effectid); }