From 210504462cefc104ce606377d4e6cc3ddf033aab Mon Sep 17 00:00:00 2001 From: David Vierra Date: Sun, 22 Jan 2017 19:42:17 -1000 Subject: [PATCH] Make GT packets process on the server/client thread instead of netty --- .../java/gregtech/api/net/GT_PacketHandler.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/gregtech/api/net/GT_PacketHandler.java b/src/main/java/gregtech/api/net/GT_PacketHandler.java index 4976411d..c17a1127 100644 --- a/src/main/java/gregtech/api/net/GT_PacketHandler.java +++ b/src/main/java/gregtech/api/net/GT_PacketHandler.java @@ -1,6 +1,8 @@ package gregtech.api.net; import gregtech.GT_Mod; +import net.minecraft.client.Minecraft; +import net.minecraft.util.IThreadListener; import net.minecraft.world.World; import net.minecraftforge.fml.common.network.NetworkRegistry; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; @@ -33,11 +35,19 @@ public class GT_PacketHandler extends SimpleNetworkWrapper { @Override public GT_Packet onMessage(GT_Packet message, MessageContext ctx) { + IThreadListener listener; + World world; if(ctx.side == Side.SERVER) { - message.process(ctx.getServerHandler().playerEntity.worldObj); + world = ctx.getServerHandler().playerEntity.worldObj; + listener = world.getMinecraftServer(); } else { - message.process(GT_Mod.gregtechproxy.getThePlayer().worldObj); + world = GT_Mod.gregtechproxy.getThePlayer().worldObj; + listener = Minecraft.getMinecraft(); } + listener.addScheduledTask(() -> { + message.process(world); + }); + return null; } }