tentative fix for packet leaks, #1855

This commit is contained in:
SpaceToad 2014-05-31 15:26:43 +02:00
parent 7b6f66db02
commit d946f8d936
12 changed files with 93 additions and 43 deletions

View file

@ -65,9 +65,11 @@ import buildcraft.core.InterModComms;
import buildcraft.core.Version; import buildcraft.core.Version;
import buildcraft.core.blueprints.BptPlayerIndex; import buildcraft.core.blueprints.BptPlayerIndex;
import buildcraft.core.blueprints.BptRootIndex; import buildcraft.core.blueprints.BptRootIndex;
import buildcraft.core.network.BuildCraftChannelHandler;
import buildcraft.core.network.PacketHandler; import buildcraft.core.network.PacketHandler;
import buildcraft.core.proxy.CoreProxy; import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.utils.BCLog; import buildcraft.core.utils.BCLog;
import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.Mod.Instance;
@ -92,6 +94,7 @@ import net.minecraft.init.Items;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
@ -123,7 +126,7 @@ public class BuildCraftBuilders extends BuildCraftMod {
@EventHandler @EventHandler
public void init(FMLInitializationEvent evt) { public void init(FMLInitializationEvent evt) {
channels = NetworkRegistry.INSTANCE.newChannel channels = NetworkRegistry.INSTANCE.newChannel
(DefaultProps.NET_CHANNEL_NAME + "-BUILDERS", new PacketHandlerBuilders()); (DefaultProps.NET_CHANNEL_NAME + "-BUILDERS", new BuildCraftChannelHandler(), new PacketHandlerBuilders());
// Register gui handler // Register gui handler
NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler()); NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());

View file

@ -26,6 +26,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.network.Packet; import net.minecraft.network.Packet;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.IPlantable; import net.minecraftforge.common.IPlantable;
@ -34,6 +35,7 @@ import net.minecraftforge.common.config.Property;
import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.fluids.BlockFluidBase; import net.minecraftforge.fluids.BlockFluidBase;
import net.minecraftforge.fluids.IFluidBlock; import net.minecraftforge.fluids.IFluidBlock;
import buildcraft.api.core.BuildCraftAPI; import buildcraft.api.core.BuildCraftAPI;
import buildcraft.api.core.IIconProvider; import buildcraft.api.core.IIconProvider;
import buildcraft.api.gates.ActionManager; import buildcraft.api.gates.ActionManager;
@ -56,6 +58,7 @@ import buildcraft.core.SpringPopulate;
import buildcraft.core.TickHandlerCoreClient; import buildcraft.core.TickHandlerCoreClient;
import buildcraft.core.Version; import buildcraft.core.Version;
import buildcraft.core.blueprints.BptItem; import buildcraft.core.blueprints.BptItem;
import buildcraft.core.network.BuildCraftChannelHandler;
import buildcraft.core.network.BuildCraftPacket; import buildcraft.core.network.BuildCraftPacket;
import buildcraft.core.network.EntityIds; import buildcraft.core.network.EntityIds;
import buildcraft.core.network.PacketHandler; import buildcraft.core.network.PacketHandler;
@ -78,6 +81,7 @@ import buildcraft.core.utils.BCLog;
import buildcraft.core.recipes.AssemblyRecipeManager; import buildcraft.core.recipes.AssemblyRecipeManager;
import buildcraft.core.recipes.IntegrationRecipeManager; import buildcraft.core.recipes.IntegrationRecipeManager;
import buildcraft.core.triggers.TriggerRedstoneInput; import buildcraft.core.triggers.TriggerRedstoneInput;
import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.EventHandler;
@ -270,7 +274,7 @@ public class BuildCraftCore extends BuildCraftMod {
@EventHandler @EventHandler
public void initialize(FMLInitializationEvent evt) { public void initialize(FMLInitializationEvent evt) {
channels = NetworkRegistry.INSTANCE.newChannel channels = NetworkRegistry.INSTANCE.newChannel
(DefaultProps.NET_CHANNEL_NAME + "-CORE", new PacketHandler()); (DefaultProps.NET_CHANNEL_NAME + "-CORE", new BuildCraftChannelHandler(), new PacketHandler());
ActionManager.registerTriggerProvider(new DefaultTriggerProvider()); ActionManager.registerTriggerProvider(new DefaultTriggerProvider());
ActionManager.registerActionProvider(new DefaultActionProvider()); ActionManager.registerActionProvider(new DefaultActionProvider());

View file

@ -20,6 +20,7 @@ import net.minecraft.init.Items;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.common.BiomeDictionary; import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
@ -28,6 +29,7 @@ import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import buildcraft.api.fuels.IronEngineCoolant; import buildcraft.api.fuels.IronEngineCoolant;
import buildcraft.api.fuels.IronEngineFuel; import buildcraft.api.fuels.IronEngineFuel;
import buildcraft.api.recipes.BuildcraftRecipes; import buildcraft.api.recipes.BuildcraftRecipes;
@ -36,6 +38,7 @@ import buildcraft.core.BlockSpring;
import buildcraft.core.DefaultProps; import buildcraft.core.DefaultProps;
import buildcraft.core.InterModComms; import buildcraft.core.InterModComms;
import buildcraft.core.Version; import buildcraft.core.Version;
import buildcraft.core.network.BuildCraftChannelHandler;
import buildcraft.core.proxy.CoreProxy; import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.triggers.BCTrigger; import buildcraft.core.triggers.BCTrigger;
import buildcraft.core.utils.BCLog; import buildcraft.core.utils.BCLog;
@ -53,6 +56,7 @@ import buildcraft.energy.worldgen.BiomeGenOilOcean;
import buildcraft.energy.worldgen.BiomeInitializer; import buildcraft.energy.worldgen.BiomeInitializer;
import buildcraft.energy.worldgen.OilPopulate; import buildcraft.energy.worldgen.OilPopulate;
import buildcraft.transport.network.PacketHandlerTransport; import buildcraft.transport.network.PacketHandlerTransport;
import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.Mod.Instance;
@ -258,7 +262,7 @@ public class BuildCraftEnergy extends BuildCraftMod {
@EventHandler @EventHandler
public void init(FMLInitializationEvent evt) { public void init(FMLInitializationEvent evt) {
channels = NetworkRegistry.INSTANCE.newChannel channels = NetworkRegistry.INSTANCE.newChannel
(DefaultProps.NET_CHANNEL_NAME + "-ENERGY", new PacketHandlerTransport()); (DefaultProps.NET_CHANNEL_NAME + "-ENERGY", new BuildCraftChannelHandler(), new PacketHandlerTransport());
NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler()); NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());

View file

@ -11,6 +11,7 @@ package buildcraft;
import buildcraft.core.DefaultProps; import buildcraft.core.DefaultProps;
import buildcraft.core.InterModComms; import buildcraft.core.InterModComms;
import buildcraft.core.Version; import buildcraft.core.Version;
import buildcraft.core.network.BuildCraftChannelHandler;
import buildcraft.core.network.PacketHandler; import buildcraft.core.network.PacketHandler;
import buildcraft.core.proxy.CoreProxy; import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.utils.ConfigUtils; import buildcraft.core.utils.ConfigUtils;
@ -65,6 +66,7 @@ import net.minecraft.init.Items;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.ForgeChunkManager; import net.minecraftforge.common.ForgeChunkManager;
@ -161,7 +163,7 @@ public class BuildCraftFactory extends BuildCraftMod {
@EventHandler @EventHandler
public void initialize(FMLPreInitializationEvent evt) { public void initialize(FMLPreInitializationEvent evt) {
channels = NetworkRegistry.INSTANCE.newChannel channels = NetworkRegistry.INSTANCE.newChannel
(DefaultProps.NET_CHANNEL_NAME + "-FACTORY", new PacketHandlerFactory()); (DefaultProps.NET_CHANNEL_NAME + "-FACTORY", new BuildCraftChannelHandler(), new PacketHandlerFactory());
ConfigUtils genCat = new ConfigUtils(BuildCraftCore.mainConfiguration, Configuration.CATEGORY_GENERAL); ConfigUtils genCat = new ConfigUtils(BuildCraftCore.mainConfiguration, Configuration.CATEGORY_GENERAL);

View file

@ -17,6 +17,7 @@ import buildcraft.core.InterModComms;
import buildcraft.silicon.ItemRedstoneChipset; import buildcraft.silicon.ItemRedstoneChipset;
import buildcraft.silicon.ItemRedstoneChipset.Chipset; import buildcraft.silicon.ItemRedstoneChipset.Chipset;
import buildcraft.core.Version; import buildcraft.core.Version;
import buildcraft.core.network.BuildCraftChannelHandler;
import buildcraft.core.network.PacketHandler; import buildcraft.core.network.PacketHandler;
import buildcraft.core.proxy.CoreProxy; import buildcraft.core.proxy.CoreProxy;
import buildcraft.silicon.BlockLaser; import buildcraft.silicon.BlockLaser;
@ -37,6 +38,7 @@ import buildcraft.transport.gates.GateDefinition.GateLogic;
import buildcraft.transport.gates.GateExpansionRedstoneFader; import buildcraft.transport.gates.GateExpansionRedstoneFader;
import buildcraft.transport.gates.GateExpansionTimer; import buildcraft.transport.gates.GateExpansionTimer;
import buildcraft.transport.gates.ItemGate; import buildcraft.transport.gates.ItemGate;
import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.Mod.Instance;
@ -55,6 +57,7 @@ import net.minecraft.init.Blocks;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.common.config.Property; import net.minecraftforge.common.config.Property;
@Mod(name = "BuildCraft Silicon", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Silicon", dependencies = DefaultProps.DEPENDENCY_TRANSPORT) @Mod(name = "BuildCraft Silicon", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Silicon", dependencies = DefaultProps.DEPENDENCY_TRANSPORT)
@ -90,7 +93,7 @@ public class BuildCraftSilicon extends BuildCraftMod {
@EventHandler @EventHandler
public void init(FMLInitializationEvent evt) { public void init(FMLInitializationEvent evt) {
channels = NetworkRegistry.INSTANCE.newChannel channels = NetworkRegistry.INSTANCE.newChannel
(DefaultProps.NET_CHANNEL_NAME + "-SILICON", new PacketHandlerSilicon()); (DefaultProps.NET_CHANNEL_NAME + "-SILICON", new BuildCraftChannelHandler(), new PacketHandlerSilicon());
NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler()); NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
CoreProxy.proxy.registerTileEntity(TileLaser.class, "net.minecraft.src.buildcraft.factory.TileLaser"); CoreProxy.proxy.registerTileEntity(TileLaser.class, "net.minecraft.src.buildcraft.factory.TileLaser");

View file

@ -18,6 +18,7 @@ import buildcraft.core.BuildCraftConfiguration;
import buildcraft.core.InterModComms; import buildcraft.core.InterModComms;
import buildcraft.core.ItemBuildCraft; import buildcraft.core.ItemBuildCraft;
import buildcraft.core.Version; import buildcraft.core.Version;
import buildcraft.core.network.BuildCraftChannelHandler;
import buildcraft.core.proxy.CoreProxy; import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.triggers.BCAction; import buildcraft.core.triggers.BCAction;
import buildcraft.core.triggers.BCTrigger; import buildcraft.core.triggers.BCTrigger;
@ -86,6 +87,7 @@ import buildcraft.transport.triggers.TriggerPipeContents.PipeContents;
import buildcraft.transport.triggers.TriggerPipeSignal; import buildcraft.transport.triggers.TriggerPipeSignal;
import buildcraft.transport.triggers.TriggerRedstoneFaderInput; import buildcraft.transport.triggers.TriggerRedstoneFaderInput;
import buildcraft.transport.triggers.ActionRedstoneFaderOutput; import buildcraft.transport.triggers.ActionRedstoneFaderOutput;
import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.Mod.Instance;
@ -106,6 +108,7 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.common.config.Property; import net.minecraftforge.common.config.Property;
@ -399,7 +402,7 @@ public class BuildCraftTransport extends BuildCraftMod {
@EventHandler @EventHandler
public void init(FMLInitializationEvent evt) { public void init(FMLInitializationEvent evt) {
channels = NetworkRegistry.INSTANCE.newChannel channels = NetworkRegistry.INSTANCE.newChannel
(DefaultProps.NET_CHANNEL_NAME + "-TRANSPORT", new PacketHandlerTransport()); (DefaultProps.NET_CHANNEL_NAME + "-TRANSPORT", new BuildCraftChannelHandler(), new PacketHandlerTransport());
// Register connection handler // Register connection handler
// MinecraftForge.registerConnectionHandler(new ConnectionHandler()); // MinecraftForge.registerConnectionHandler(new ConnectionHandler());

View file

@ -10,9 +10,13 @@ package buildcraft.builders.network;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.channel.ChannelHandler.Sharable;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.network.INetHandler; import net.minecraft.network.INetHandler;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import buildcraft.builders.TileArchitect; import buildcraft.builders.TileArchitect;
import buildcraft.builders.TileBlueprintLibrary; import buildcraft.builders.TileBlueprintLibrary;
import buildcraft.core.network.BuildCraftChannelHandler; import buildcraft.core.network.BuildCraftChannelHandler;
@ -21,14 +25,14 @@ import buildcraft.core.network.PacketIds;
import buildcraft.core.network.PacketPayloadArrays; import buildcraft.core.network.PacketPayloadArrays;
import buildcraft.core.network.PacketUpdate; import buildcraft.core.network.PacketUpdate;
import buildcraft.core.proxy.CoreProxy; import buildcraft.core.proxy.CoreProxy;
import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.network.NetworkRegistry;
public class PacketHandlerBuilders extends BuildCraftChannelHandler { @Sharable
public class PacketHandlerBuilders extends SimpleChannelInboundHandler<BuildCraftPacket> {
@Override @Override
public void decodeInto(ChannelHandlerContext ctx, ByteBuf data, BuildCraftPacket packet) { protected void channelRead0(ChannelHandlerContext ctx, BuildCraftPacket packet) {
super.decodeInto(ctx, data, packet);
try { try {
INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get(); INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
EntityPlayer player = CoreProxy.proxy.getPlayerFromNetHandler(netHandler); EntityPlayer player = CoreProxy.proxy.getPlayerFromNetHandler(netHandler);

View file

@ -10,6 +10,8 @@ package buildcraft.core.network;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.channel.ChannelHandler.Sharable;
import java.io.IOException; import java.io.IOException;
@ -17,10 +19,13 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.network.INetHandler; import net.minecraft.network.INetHandler;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import buildcraft.core.proxy.CoreProxy; import buildcraft.core.proxy.CoreProxy;
import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.network.NetworkRegistry;
public class PacketHandler extends BuildCraftChannelHandler { @Sharable
public class PacketHandler extends SimpleChannelInboundHandler<BuildCraftPacket> {
private void onTileUpdate(EntityPlayer player, PacketTileUpdate packet) throws IOException { private void onTileUpdate(EntityPlayer player, PacketTileUpdate packet) throws IOException {
World world = player.worldObj; World world = player.worldObj;
@ -41,9 +46,7 @@ public class PacketHandler extends BuildCraftChannelHandler {
} }
@Override @Override
public void decodeInto(ChannelHandlerContext ctx, ByteBuf data, BuildCraftPacket packet) { protected void channelRead0(ChannelHandlerContext ctx, BuildCraftPacket packet) {
super.decodeInto(ctx, data, packet);
try { try {
INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get(); INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
EntityPlayer player = CoreProxy.proxy.getPlayerFromNetHandler(netHandler); EntityPlayer player = CoreProxy.proxy.getPlayerFromNetHandler(netHandler);
@ -63,7 +66,7 @@ public class PacketHandler extends BuildCraftChannelHandler {
TileEntity tile = world.getTileEntity(pkt.posX, pkt.posY, pkt.posZ); TileEntity tile = world.getTileEntity(pkt.posX, pkt.posY, pkt.posZ);
if (tile instanceof ISyncedTile) { if (tile instanceof ISyncedTile) {
pkt.applyStates(data, (ISyncedTile) tile); pkt.applyStates((ISyncedTile) tile);
} }
break; break;

View file

@ -8,16 +8,17 @@
*/ */
package buildcraft.core.network; package buildcraft.core.network;
import io.netty.buffer.ByteBuf;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
public class PacketTileState extends PacketCoordinates { public class PacketTileState extends PacketCoordinates {
private ByteBuf state;
private class StateWithId { private class StateWithId {
public byte stateId; public byte stateId;
public IClientState state; public IClientState state;
@ -52,16 +53,11 @@ public class PacketTileState extends PacketCoordinates {
return PacketIds.STATE_UPDATE; return PacketIds.STATE_UPDATE;
} }
@Override public void applyStates(ISyncedTile tile) throws IOException {
public void readData(ByteBuf data) { byte stateCount = state.readByte();
super.readData(data);
}
public void applyStates(ByteBuf data, ISyncedTile tile) throws IOException {
byte stateCount = data.readByte();
for (int i = 0; i < stateCount; i++) { for (int i = 0; i < stateCount; i++) {
byte stateId = data.readByte(); byte stateId = state.readByte();
tile.getStateInstance(stateId).readData(data); tile.getStateInstance(stateId).readData(state);
tile.afterStateUpdated(stateId); tile.afterStateUpdated(stateId);
} }
} }
@ -73,10 +69,25 @@ public class PacketTileState extends PacketCoordinates {
@Override @Override
public void writeData(ByteBuf data) { public void writeData(ByteBuf data) {
super.writeData(data); super.writeData(data);
data.writeByte(stateList.size());
ByteBuf tmpState = Unpooled.buffer();
tmpState.writeByte(stateList.size());
for (StateWithId stateWithId : stateList) { for (StateWithId stateWithId : stateList) {
data.writeByte(stateWithId.stateId); tmpState.writeByte(stateWithId.stateId);
stateWithId.state.writeData(data); stateWithId.state.writeData(tmpState);
} }
data.writeInt(tmpState.readableBytes());
data.writeBytes(tmpState.readBytes(tmpState.readableBytes()));
}
@Override
public void readData(ByteBuf data) {
super.readData(data);
state = Unpooled.buffer();
int length = data.readInt();
state.writeBytes(data.readBytes(length));
} }
} }

View file

@ -10,6 +10,8 @@ package buildcraft.factory.network;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.channel.ChannelHandler.Sharable;
import java.io.IOException; import java.io.IOException;
@ -17,7 +19,9 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.network.INetHandler; import net.minecraft.network.INetHandler;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidRegistry;
import buildcraft.core.network.BuildCraftChannelHandler; import buildcraft.core.network.BuildCraftChannelHandler;
import buildcraft.core.network.BuildCraftPacket; import buildcraft.core.network.BuildCraftPacket;
import buildcraft.core.network.PacketIds; import buildcraft.core.network.PacketIds;
@ -25,14 +29,14 @@ import buildcraft.core.network.PacketPayloadStream;
import buildcraft.core.network.PacketUpdate; import buildcraft.core.network.PacketUpdate;
import buildcraft.core.proxy.CoreProxy; import buildcraft.core.proxy.CoreProxy;
import buildcraft.factory.TileRefinery; import buildcraft.factory.TileRefinery;
import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.network.NetworkRegistry;
public class PacketHandlerFactory extends BuildCraftChannelHandler { @Sharable
public class PacketHandlerFactory extends SimpleChannelInboundHandler<BuildCraftPacket> {
@Override @Override
public void decodeInto(ChannelHandlerContext ctx, ByteBuf data, BuildCraftPacket packet) { protected void channelRead0(ChannelHandlerContext ctx, BuildCraftPacket packet) {
super.decodeInto(ctx, data, packet);
try { try {
INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get(); INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
EntityPlayer player = CoreProxy.proxy.getPlayerFromNetHandler(netHandler); EntityPlayer player = CoreProxy.proxy.getPlayerFromNetHandler(netHandler);

View file

@ -10,11 +10,15 @@ package buildcraft.silicon.network;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.channel.ChannelHandler.Sharable;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container; import net.minecraft.inventory.Container;
import net.minecraft.network.INetHandler; import net.minecraft.network.INetHandler;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import buildcraft.core.network.BuildCraftChannelHandler; import buildcraft.core.network.BuildCraftChannelHandler;
import buildcraft.core.network.BuildCraftPacket; import buildcraft.core.network.BuildCraftPacket;
import buildcraft.core.network.PacketCoordinates; import buildcraft.core.network.PacketCoordinates;
@ -26,14 +30,14 @@ import buildcraft.silicon.TileAdvancedCraftingTable;
import buildcraft.silicon.TileAssemblyTable; import buildcraft.silicon.TileAssemblyTable;
import buildcraft.silicon.TileAssemblyTable.SelectionMessage; import buildcraft.silicon.TileAssemblyTable.SelectionMessage;
import buildcraft.silicon.gui.ContainerAssemblyTable; import buildcraft.silicon.gui.ContainerAssemblyTable;
import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.network.NetworkRegistry;
public class PacketHandlerSilicon extends BuildCraftChannelHandler { @Sharable
public class PacketHandlerSilicon extends SimpleChannelInboundHandler<BuildCraftPacket> {
@Override @Override
public void decodeInto(ChannelHandlerContext ctx, ByteBuf data, BuildCraftPacket packet) { protected void channelRead0(ChannelHandlerContext ctx, BuildCraftPacket packet) {
super.decodeInto(ctx, data, packet);
try { try {
INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get(); INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();

View file

@ -10,11 +10,15 @@ package buildcraft.transport.network;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.channel.ChannelHandler.Sharable;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container; import net.minecraft.inventory.Container;
import net.minecraft.network.INetHandler; import net.minecraft.network.INetHandler;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import buildcraft.core.network.BuildCraftChannelHandler; import buildcraft.core.network.BuildCraftChannelHandler;
import buildcraft.core.network.BuildCraftPacket; import buildcraft.core.network.BuildCraftPacket;
import buildcraft.core.network.PacketCoordinates; import buildcraft.core.network.PacketCoordinates;
@ -28,9 +32,11 @@ import buildcraft.transport.TileGenericPipe;
import buildcraft.transport.gui.ContainerGateInterface; import buildcraft.transport.gui.ContainerGateInterface;
import buildcraft.transport.pipes.PipeItemsDiamond; import buildcraft.transport.pipes.PipeItemsDiamond;
import buildcraft.transport.pipes.PipeItemsEmerald; import buildcraft.transport.pipes.PipeItemsEmerald;
import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.network.NetworkRegistry;
public class PacketHandlerTransport extends BuildCraftChannelHandler { @Sharable
public class PacketHandlerTransport extends SimpleChannelInboundHandler<BuildCraftPacket> {
/** /**
* TODO: A lot of this is based on the player to retrieve the world. * TODO: A lot of this is based on the player to retrieve the world.
@ -39,8 +45,7 @@ public class PacketHandlerTransport extends BuildCraftChannelHandler {
* RPCs. * RPCs.
*/ */
@Override @Override
public void decodeInto(ChannelHandlerContext ctx, ByteBuf data, BuildCraftPacket packet) { protected void channelRead0(ChannelHandlerContext ctx, BuildCraftPacket packet) {
super.decodeInto(ctx, data, packet);
try { try {
INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get(); INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
EntityPlayer player = CoreProxy.proxy.getPlayerFromNetHandler(netHandler); EntityPlayer player = CoreProxy.proxy.getPlayerFromNetHandler(netHandler);