From b225afe6ef2f0c8d55637b14178b788956e7245a Mon Sep 17 00:00:00 2001 From: Hugo Kerstens Date: Tue, 22 Mar 2016 15:28:00 +0100 Subject: [PATCH 1/2] Fix armorstands moving incorrectly when using relative movement packets --- .../myles/ViaVersion/transformers/OutgoingTransformer.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/main/java/us/myles/ViaVersion/transformers/OutgoingTransformer.java b/src/main/java/us/myles/ViaVersion/transformers/OutgoingTransformer.java index cee828de3..162c644dc 100644 --- a/src/main/java/us/myles/ViaVersion/transformers/OutgoingTransformer.java +++ b/src/main/java/us/myles/ViaVersion/transformers/OutgoingTransformer.java @@ -252,9 +252,6 @@ public class OutgoingTransformer { int x = input.readByte(); output.writeShort(x * 128); int y = input.readByte(); - if (plugin.isHologramPatch() & knownHolograms.contains(id)) { - y = (int) ((y) + plugin.getHologramYOffset()); - } output.writeShort(y * 128); int z = input.readByte(); output.writeShort(z * 128); @@ -275,9 +272,6 @@ public class OutgoingTransformer { short x = (short) (input.readByte()); output.writeShort(x * 128); short y = (short) (input.readByte()); - if (plugin.isHologramPatch() & knownHolograms.contains(id)) { - y = (short) (y - 1); - } output.writeShort(y * 128); short z = (short) (input.readByte()); output.writeShort(z * 128); From 9adf6040facf5d4a707f1eb6672a0613f75952e6 Mon Sep 17 00:00:00 2001 From: Myles Date: Wed, 23 Mar 2016 12:35:38 +0000 Subject: [PATCH 2/2] Optimise ViaIdleThread, use 1 object for all packets. (Quite a big speed up) --- .../us/myles/ViaVersion/ViaIdleThread.java | 27 +++++++------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/src/main/java/us/myles/ViaVersion/ViaIdleThread.java b/src/main/java/us/myles/ViaVersion/ViaIdleThread.java index 31ce146db..2be8c1592 100644 --- a/src/main/java/us/myles/ViaVersion/ViaIdleThread.java +++ b/src/main/java/us/myles/ViaVersion/ViaIdleThread.java @@ -1,7 +1,6 @@ package us.myles.ViaVersion; import org.bukkit.scheduler.BukkitRunnable; -import us.myles.ViaVersion.api.ViaVersion; import us.myles.ViaVersion.util.ReflectionUtil; import java.util.Map; @@ -9,33 +8,25 @@ import java.util.UUID; public class ViaIdleThread extends BukkitRunnable { private final Map portedPlayers; - private final Class idlePacketClass; + private final Object idlePacket; public ViaIdleThread(Map portedPlayers) { this.portedPlayers = portedPlayers; try { - this.idlePacketClass = ReflectionUtil.nms("PacketPlayInFlying"); - } catch(ClassNotFoundException e) { - throw new RuntimeException("Couldn't find player idle packet, help!", e); + Class idlePacketClass = ReflectionUtil.nms("PacketPlayInFlying"); + idlePacket = idlePacketClass.newInstance(); + } catch (InstantiationException | IllegalArgumentException | IllegalAccessException | ClassNotFoundException e) { + throw new RuntimeException("Couldn't find/make player idle packet, help!", e); } } @Override public void run() { - for(ConnectionInfo info : portedPlayers.values()) { + for (ConnectionInfo info : portedPlayers.values()) { long nextIdleUpdate = info.getNextIdlePacket(); - if(nextIdleUpdate <= System.currentTimeMillis()) { - try { - Object packet = idlePacketClass.newInstance(); - info.getChannel().pipeline().fireChannelRead(packet); - } catch(InstantiationException | IllegalAccessException e) { - System.out.println("Failed to create idle packet."); - if(ViaVersion.getInstance().isDebug()) { - e.printStackTrace(); - } - } finally { - info.incrementIdlePacket(); - } + if (nextIdleUpdate <= System.currentTimeMillis()) { + info.getChannel().pipeline().fireChannelRead(idlePacket); + info.incrementIdlePacket(); } } }