mirror of
https://github.com/GTNewHorizons/BloodMagic.git
synced 2026-10-25 20:22:32 +00:00
fix net handler leak (#130)
This commit is contained in:
1 parent
306aa90a28
commit
22d703da79
4 files changed
+26
-37
No files matched your search
@@ -65,6 +65,7 @@ import WayofTime.alchemicalWizardry.common.CommonProxy;
|
|||||||
import WayofTime.alchemicalWizardry.common.LifeBucketHandler;
|
import WayofTime.alchemicalWizardry.common.LifeBucketHandler;
|
||||||
import WayofTime.alchemicalWizardry.common.LifeEssence;
|
import WayofTime.alchemicalWizardry.common.LifeEssence;
|
||||||
import WayofTime.alchemicalWizardry.common.ModLivingDropsEvent;
|
import WayofTime.alchemicalWizardry.common.ModLivingDropsEvent;
|
||||||
|
import WayofTime.alchemicalWizardry.common.NewPacketHandler;
|
||||||
import WayofTime.alchemicalWizardry.common.achievements.ModAchievements;
|
import WayofTime.alchemicalWizardry.common.achievements.ModAchievements;
|
||||||
import WayofTime.alchemicalWizardry.common.alchemy.CombinedPotionRegistry;
|
import WayofTime.alchemicalWizardry.common.alchemy.CombinedPotionRegistry;
|
||||||
import WayofTime.alchemicalWizardry.common.block.ArmourForge;
|
import WayofTime.alchemicalWizardry.common.block.ArmourForge;
|
||||||
@@ -689,6 +690,7 @@ public class AlchemicalWizardry {
|
|||||||
HoldingPacketHandler.init();
|
HoldingPacketHandler.init();
|
||||||
ClientToServerPacketHandler.init();
|
ClientToServerPacketHandler.init();
|
||||||
ModAchievements.init();
|
ModAchievements.init();
|
||||||
|
NewPacketHandler.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -250,7 +250,6 @@ public class ClientProxy extends CommonProxy {
|
|||||||
Object ob = new ClientEventHandler();
|
Object ob = new ClientEventHandler();
|
||||||
FMLCommonHandler.instance().bus().register(ob);
|
FMLCommonHandler.instance().bus().register(ob);
|
||||||
MinecraftForge.EVENT_BUS.register(ob);
|
MinecraftForge.EVENT_BUS.register(ob);
|
||||||
KeyBindings.init();
|
|
||||||
MinecraftForge.EVENT_BUS.register(new ScrollHelper());
|
MinecraftForge.EVENT_BUS.register(new ScrollHelper());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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)
|
@SideOnly(Side.CLIENT)
|
||||||
private void addClientHandler() {
|
private void addClientHandler() {
|
||||||
FMLEmbeddedChannel clientChannel = this.channels.get(Side.CLIENT);
|
FMLEmbeddedChannel clientChannel = this.channels.get(Side.CLIENT);
|
||||||
|
// spotless:off
|
||||||
String tileAltarCodec = clientChannel.findChannelHandlerNameForType(TEAltarCodec.class);
|
String tileAltarCodec = clientChannel.findChannelHandlerNameForType(TEAltarCodec.class);
|
||||||
clientChannel.pipeline().addAfter(tileAltarCodec, "TEAltarHandler", new TEAltarMessageHandler());
|
clientChannel.pipeline().addAfter(tileAltarCodec, "TEAltarHandler", new TEAltarMessageHandler());
|
||||||
clientChannel.pipeline().addAfter(tileAltarCodec, "TEOrientableHandler", new TEOrientableMessageHandler());
|
clientChannel.pipeline().addAfter(tileAltarCodec, "TEOrientableHandler", new TEOrientableMessageHandler());
|
||||||
@@ -75,15 +81,12 @@ public enum NewPacketHandler {
|
|||||||
clientChannel.pipeline().addAfter(tileAltarCodec, "ParticleHandler", new ParticleMessageHandler());
|
clientChannel.pipeline().addAfter(tileAltarCodec, "ParticleHandler", new ParticleMessageHandler());
|
||||||
clientChannel.pipeline().addAfter(tileAltarCodec, "VelocityHandler", new VelocityMessageHandler());
|
clientChannel.pipeline().addAfter(tileAltarCodec, "VelocityHandler", new VelocityMessageHandler());
|
||||||
clientChannel.pipeline().addAfter(tileAltarCodec, "TEMasterStoneHandler", new TEMasterStoneMessageHandler());
|
clientChannel.pipeline().addAfter(tileAltarCodec, "TEMasterStoneHandler", new TEMasterStoneMessageHandler());
|
||||||
clientChannel.pipeline()
|
clientChannel.pipeline().addAfter(tileAltarCodec, "TEReagentConduitHandler", new TEReagentConduitMessageHandler());
|
||||||
.addAfter(tileAltarCodec, "TEReagentConduitHandler", new TEReagentConduitMessageHandler());
|
|
||||||
clientChannel.pipeline().addAfter(tileAltarCodec, "CurrentLPMessageHandler", new CurrentLPMessageHandler());
|
clientChannel.pipeline().addAfter(tileAltarCodec, "CurrentLPMessageHandler", new CurrentLPMessageHandler());
|
||||||
clientChannel.pipeline()
|
clientChannel.pipeline().addAfter(tileAltarCodec, "CurrentReagentBarMessageHandler", new CurrentReagentBarMessageHandler());
|
||||||
.addAfter(tileAltarCodec, "CurrentReagentBarMessageHandler", new CurrentReagentBarMessageHandler());
|
clientChannel.pipeline().addAfter(tileAltarCodec, "CurrentAddedHPMessageHandler", new CurrentAddedHPMessageHandler());
|
||||||
clientChannel.pipeline()
|
clientChannel.pipeline().addAfter(tileAltarCodec, "GaiaBiomeChangeHandler", new GaiaBiomeChangeMessageHandler());
|
||||||
.addAfter(tileAltarCodec, "CurrentAddedHPMessageHandler", new CurrentAddedHPMessageHandler());
|
// spotless:on
|
||||||
clientChannel.pipeline()
|
|
||||||
.addAfter(tileAltarCodec, "GaiaBiomeChangeHandler", new GaiaBiomeChangeMessageHandler());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SideOnly(Side.SERVER)
|
@SideOnly(Side.SERVER)
|
||||||
@@ -997,37 +1000,33 @@ public enum NewPacketHandler {
|
|||||||
return INSTANCE.channels.get(Side.SERVER).generatePacketFrom(msg);
|
return INSTANCE.channels.get(Side.SERVER).generatePacketFrom(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// spotless:off
|
||||||
public void sendTo(Packet message, EntityPlayerMP player) {
|
public void sendTo(Packet message, EntityPlayerMP player) {
|
||||||
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET)
|
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.PLAYER);
|
||||||
.set(FMLOutboundHandler.OutboundTarget.PLAYER);
|
|
||||||
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(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) {
|
public void sendToAll(Packet message) {
|
||||||
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET)
|
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALL);
|
||||||
.set(FMLOutboundHandler.OutboundTarget.ALL);
|
this.channels.get(Side.SERVER).writeAndFlush(message).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
|
||||||
this.channels.get(Side.SERVER).writeAndFlush(message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendToAllAround(Packet message, NetworkRegistry.TargetPoint point) {
|
public void sendToAllAround(Packet message, NetworkRegistry.TargetPoint point) {
|
||||||
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET)
|
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALLAROUNDPOINT);
|
||||||
.set(FMLOutboundHandler.OutboundTarget.ALLAROUNDPOINT);
|
|
||||||
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(point);
|
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) {
|
public void sendToDimension(Packet message, Integer dimensionId) {
|
||||||
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET)
|
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.DIMENSION);
|
||||||
.set(FMLOutboundHandler.OutboundTarget.DIMENSION);
|
|
||||||
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(dimensionId);
|
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) {
|
public void sendToServer(Packet message) {
|
||||||
this.channels.get(Side.CLIENT).attr(FMLOutboundHandler.FML_MESSAGETARGET)
|
this.channels.get(Side.CLIENT).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.TOSERVER);
|
||||||
.set(FMLOutboundHandler.OutboundTarget.TOSERVER);
|
this.channels.get(Side.CLIENT).writeAndFlush(message).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
|
||||||
this.channels.get(Side.CLIENT).writeAndFlush(message)
|
|
||||||
.addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
|
|
||||||
}
|
}
|
||||||
|
// spotless:on
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user