From df3be302af972f6af2679b5ad052a17d90f4431f Mon Sep 17 00:00:00 2001 From: Matsv Date: Wed, 16 Nov 2016 17:15:36 +0100 Subject: [PATCH] Send the chunkbulk packets immediately. Fixes #535 --- .../us/myles/ViaVersion/api/PacketWrapper.java | 16 +++++++++++++++- .../protocol1_9to1_8/packets/WorldPackets.java | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/us/myles/ViaVersion/api/PacketWrapper.java b/common/src/main/java/us/myles/ViaVersion/api/PacketWrapper.java index 0932b1007..6182d5d92 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/PacketWrapper.java +++ b/common/src/main/java/us/myles/ViaVersion/api/PacketWrapper.java @@ -283,9 +283,23 @@ public class PacketWrapper { * @throws Exception if it fails to write */ public void send(Class packetProtocol, boolean skipCurrentPipeline) throws Exception { + send(packetProtocol, skipCurrentPipeline, false); + } + + /** + * Send this packet to the associated user. + * Be careful not to send packets twice. + * (Sends it after current) + * + * @param packetProtocol - The protocol version of the packet. + * @param skipCurrentPipeline - Skip the current pipeline + * @param currentThread - Run in the same thread + * @throws Exception if it fails to write + */ + public void send(Class packetProtocol, boolean skipCurrentPipeline, boolean currentThread) throws Exception { if (!isCancelled()) { ByteBuf output = constructPacket(packetProtocol, skipCurrentPipeline); - user().sendRawPacket(output); + user().sendRawPacket(output, currentThread); } } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/WorldPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/WorldPackets.java index ef510dc8f..95b18584e 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/WorldPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/WorldPackets.java @@ -162,7 +162,7 @@ public class WorldPackets { output.setId(-1); // -1 for no writing of id output.writeToBuffer(buffer); PacketWrapper chunkPacket = new PacketWrapper(0x21, buffer, wrapper.user()); - chunkPacket.send(Protocol1_9TO1_8.class, false); + chunkPacket.send(Protocol1_9TO1_8.class, false, true); } } });