From ec69f49d47836884440c39ba14052fd34338ad11 Mon Sep 17 00:00:00 2001 From: Alexdoru <57050655+Alexdoru@users.noreply.github.com> Date: Thu, 14 May 2026 19:45:05 +0200 Subject: [PATCH 1/2] del empty keybind handler --- .../alchemicalWizardry/client/ClientProxy.java | 1 - .../alchemicalWizardry/client/KeyBindings.java | 11 ----------- 2 files changed, 12 deletions(-) delete mode 100644 src/main/java/WayofTime/alchemicalWizardry/client/KeyBindings.java diff --git a/src/main/java/WayofTime/alchemicalWizardry/client/ClientProxy.java b/src/main/java/WayofTime/alchemicalWizardry/client/ClientProxy.java index f412036367..cdfcf2bc8e 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/client/ClientProxy.java +++ b/src/main/java/WayofTime/alchemicalWizardry/client/ClientProxy.java @@ -250,7 +250,6 @@ public void registerEvents() { Object ob = new ClientEventHandler(); FMLCommonHandler.instance().bus().register(ob); MinecraftForge.EVENT_BUS.register(ob); - KeyBindings.init(); MinecraftForge.EVENT_BUS.register(new ScrollHelper()); } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/client/KeyBindings.java b/src/main/java/WayofTime/alchemicalWizardry/client/KeyBindings.java deleted file mode 100644 index acdac02d1a..0000000000 --- a/src/main/java/WayofTime/alchemicalWizardry/client/KeyBindings.java +++ /dev/null @@ -1,11 +0,0 @@ -package WayofTime.alchemicalWizardry.client; - -public class KeyBindings { - // public static KeyBinding omegaTest; - - public static void init() { - // omegaTest = new KeyBinding("key.ping", Keyboard.KEY_O, "key.categories.alchemicalwizardry"); - // - // ClientRegistry.registerKeyBinding(omegaTest); - } -} From 7e552c16e63222ba2767aef927b5a2b08cf82031 Mon Sep 17 00:00:00 2001 From: Alexdoru <57050655+Alexdoru@users.noreply.github.com> Date: Thu, 14 May 2026 20:07:00 +0200 Subject: [PATCH 2/2] init network channel on client thread --- .../AlchemicalWizardry.java | 2 + .../common/NewPacketHandler.java | 49 +++++++++---------- 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/src/main/java/WayofTime/alchemicalWizardry/AlchemicalWizardry.java b/src/main/java/WayofTime/alchemicalWizardry/AlchemicalWizardry.java index 00b1959654..0a16c17895 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/AlchemicalWizardry.java +++ b/src/main/java/WayofTime/alchemicalWizardry/AlchemicalWizardry.java @@ -65,6 +65,7 @@ import WayofTime.alchemicalWizardry.common.LifeBucketHandler; import WayofTime.alchemicalWizardry.common.LifeEssence; import WayofTime.alchemicalWizardry.common.ModLivingDropsEvent; +import WayofTime.alchemicalWizardry.common.NewPacketHandler; import WayofTime.alchemicalWizardry.common.achievements.ModAchievements; import WayofTime.alchemicalWizardry.common.alchemy.CombinedPotionRegistry; import WayofTime.alchemicalWizardry.common.block.ArmourForge; @@ -689,6 +690,7 @@ public void preInit(FMLPreInitializationEvent event) { HoldingPacketHandler.init(); ClientToServerPacketHandler.init(); ModAchievements.init(); + NewPacketHandler.init(); } /** diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/NewPacketHandler.java b/src/main/java/WayofTime/alchemicalWizardry/common/NewPacketHandler.java index de84b3917f..d7b8dd97bc 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/NewPacketHandler.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/NewPacketHandler.java @@ -60,10 +60,16 @@ public enum NewPacketHandler { } } + public static void init() { + // called on the client thread + // to avoid leaking the server thread + // if initialized on the server thread + } + @SideOnly(Side.CLIENT) private void addClientHandler() { FMLEmbeddedChannel clientChannel = this.channels.get(Side.CLIENT); - + // spotless:off String tileAltarCodec = clientChannel.findChannelHandlerNameForType(TEAltarCodec.class); clientChannel.pipeline().addAfter(tileAltarCodec, "TEAltarHandler", new TEAltarMessageHandler()); clientChannel.pipeline().addAfter(tileAltarCodec, "TEOrientableHandler", new TEOrientableMessageHandler()); @@ -75,15 +81,12 @@ private void addClientHandler() { clientChannel.pipeline().addAfter(tileAltarCodec, "ParticleHandler", new ParticleMessageHandler()); clientChannel.pipeline().addAfter(tileAltarCodec, "VelocityHandler", new VelocityMessageHandler()); clientChannel.pipeline().addAfter(tileAltarCodec, "TEMasterStoneHandler", new TEMasterStoneMessageHandler()); - clientChannel.pipeline() - .addAfter(tileAltarCodec, "TEReagentConduitHandler", new TEReagentConduitMessageHandler()); + clientChannel.pipeline().addAfter(tileAltarCodec, "TEReagentConduitHandler", new TEReagentConduitMessageHandler()); clientChannel.pipeline().addAfter(tileAltarCodec, "CurrentLPMessageHandler", new CurrentLPMessageHandler()); - clientChannel.pipeline() - .addAfter(tileAltarCodec, "CurrentReagentBarMessageHandler", new CurrentReagentBarMessageHandler()); - clientChannel.pipeline() - .addAfter(tileAltarCodec, "CurrentAddedHPMessageHandler", new CurrentAddedHPMessageHandler()); - clientChannel.pipeline() - .addAfter(tileAltarCodec, "GaiaBiomeChangeHandler", new GaiaBiomeChangeMessageHandler()); + clientChannel.pipeline().addAfter(tileAltarCodec, "CurrentReagentBarMessageHandler", new CurrentReagentBarMessageHandler()); + clientChannel.pipeline().addAfter(tileAltarCodec, "CurrentAddedHPMessageHandler", new CurrentAddedHPMessageHandler()); + clientChannel.pipeline().addAfter(tileAltarCodec, "GaiaBiomeChangeHandler", new GaiaBiomeChangeMessageHandler()); + // spotless:on } @SideOnly(Side.SERVER) @@ -997,37 +1000,33 @@ public static Packet getGaiaBiomeChangePacket(int x, int z, byte biome, BitSet m return INSTANCE.channels.get(Side.SERVER).generatePacketFrom(msg); } + // spotless:off public void sendTo(Packet message, EntityPlayerMP player) { - this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET) - .set(FMLOutboundHandler.OutboundTarget.PLAYER); + this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.PLAYER); this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(player); - this.channels.get(Side.SERVER).writeAndFlush(message); + this.channels.get(Side.SERVER).writeAndFlush(message).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); } public void sendToAll(Packet message) { - this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET) - .set(FMLOutboundHandler.OutboundTarget.ALL); - this.channels.get(Side.SERVER).writeAndFlush(message); + this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALL); + this.channels.get(Side.SERVER).writeAndFlush(message).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); } public void sendToAllAround(Packet message, NetworkRegistry.TargetPoint point) { - this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET) - .set(FMLOutboundHandler.OutboundTarget.ALLAROUNDPOINT); + this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALLAROUNDPOINT); this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(point); - this.channels.get(Side.SERVER).writeAndFlush(message); + this.channels.get(Side.SERVER).writeAndFlush(message).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); } public void sendToDimension(Packet message, Integer dimensionId) { - this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET) - .set(FMLOutboundHandler.OutboundTarget.DIMENSION); + this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.DIMENSION); this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(dimensionId); - this.channels.get(Side.SERVER).writeAndFlush(message); + this.channels.get(Side.SERVER).writeAndFlush(message).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); } public void sendToServer(Packet message) { - this.channels.get(Side.CLIENT).attr(FMLOutboundHandler.FML_MESSAGETARGET) - .set(FMLOutboundHandler.OutboundTarget.TOSERVER); - this.channels.get(Side.CLIENT).writeAndFlush(message) - .addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); + this.channels.get(Side.CLIENT).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.TOSERVER); + this.channels.get(Side.CLIENT).writeAndFlush(message).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); } + // spotless:on }