From 1fb88d12548e11fc3fea05f1fc3b280683fdd8a7 Mon Sep 17 00:00:00 2001 From: Connor Linfoot Date: Sun, 16 Jun 2024 19:05:54 +0100 Subject: fix: Handle incoming packets on the main thread (#3) --- src/main/java/net/hypixel/modapi/forge/ForgeModAPI.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/hypixel/modapi/forge/ForgeModAPI.java b/src/main/java/net/hypixel/modapi/forge/ForgeModAPI.java index 16a75ef..1a15da3 100644 --- a/src/main/java/net/hypixel/modapi/forge/ForgeModAPI.java +++ b/src/main/java/net/hypixel/modapi/forge/ForgeModAPI.java @@ -86,11 +86,13 @@ public class ForgeModAPI { return; } - try { - HypixelModAPI.getInstance().handle(identifier, new PacketSerializer(packet.getBufferData())); - } catch (Exception e) { - LOGGER.log(Level.WARNING, "Failed to handle packet " + identifier, e); - } + Minecraft.getMinecraft().addScheduledTask(() -> { + try { + HypixelModAPI.getInstance().handle(identifier, new PacketSerializer(packet.getBufferData())); + } catch (Exception e) { + LOGGER.log(Level.WARNING, "Failed to handle packet " + identifier, e); + } + }); } } } -- cgit