Merge branch '5.0.x' into 6.0.x

Conflicts:
	common/buildcraft/BuildCraftBuilders.java
	common/buildcraft/BuildCraftCore.java
	common/buildcraft/BuildCraftEnergy.java
	common/buildcraft/BuildCraftFactory.java
	common/buildcraft/BuildCraftSilicon.java
	common/buildcraft/BuildCraftTransport.java
	common/buildcraft/builders/network/PacketHandlerBuilders.java
	common/buildcraft/core/network/PacketHandler.java
	common/buildcraft/core/network/PacketTileState.java
	common/buildcraft/factory/network/PacketHandlerFactory.java
	common/buildcraft/silicon/network/PacketHandlerSilicon.java
	common/buildcraft/transport/network/PacketHandlerTransport.java
This commit is contained in:
SpaceToad 2014-05-31 18:09:23 +02:00
commit 8bff372360
11 changed files with 83 additions and 74 deletions

View file

@ -77,6 +77,7 @@ import buildcraft.core.ItemWrench;
import buildcraft.core.SpringPopulate;
import buildcraft.core.TickHandlerCoreClient;
import buildcraft.core.Version;
import buildcraft.core.network.BuildCraftChannelHandler;
import buildcraft.core.network.EntityIds;
import buildcraft.core.network.PacketHandler;
import buildcraft.core.network.PacketUpdate;
@ -320,7 +321,7 @@ public class BuildCraftCore extends BuildCraftMod {
BuildCraftAPI.proxy = CoreProxy.proxy;
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.registerActionProvider(new DefaultActionProvider());

View file

@ -52,6 +52,7 @@ import buildcraft.core.BlockSpring;
import buildcraft.core.DefaultProps;
import buildcraft.core.InterModComms;
import buildcraft.core.Version;
import buildcraft.core.network.BuildCraftChannelHandler;
import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.triggers.BCTrigger;
import buildcraft.energy.BlockBuildcraftFluid;
@ -328,7 +329,7 @@ public class BuildCraftEnergy extends BuildCraftMod {
@Mod.EventHandler
public void init(FMLInitializationEvent evt) {
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());

View file

@ -41,6 +41,7 @@ import buildcraft.builders.schematics.SchematicIgnoreMeta;
import buildcraft.core.DefaultProps;
import buildcraft.core.InterModComms;
import buildcraft.core.Version;
import buildcraft.core.network.BuildCraftChannelHandler;
import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.utils.ConfigUtils;
import buildcraft.factory.BlockAutoWorkbench;
@ -161,7 +162,7 @@ public class BuildCraftFactory extends BuildCraftMod {
@Mod.EventHandler
public void initialize(FMLPreInitializationEvent evt) {
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);

View file

@ -29,6 +29,7 @@ import buildcraft.builders.schematics.SchematicRotateMeta;
import buildcraft.core.DefaultProps;
import buildcraft.core.InterModComms;
import buildcraft.core.Version;
import buildcraft.core.network.BuildCraftChannelHandler;
import buildcraft.core.proxy.CoreProxy;
import buildcraft.silicon.BlockLaser;
import buildcraft.silicon.BlockLaserTable;
@ -83,7 +84,7 @@ public class BuildCraftSilicon extends BuildCraftMod {
@Mod.EventHandler
public void init(FMLInitializationEvent evt) {
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());
CoreProxy.proxy.registerTileEntity(TileLaser.class, "net.minecraft.src.buildcraft.factory.TileLaser");

View file

@ -46,6 +46,7 @@ import buildcraft.core.DefaultProps;
import buildcraft.core.InterModComms;
import buildcraft.core.ItemBuildCraft;
import buildcraft.core.Version;
import buildcraft.core.network.BuildCraftChannelHandler;
import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.triggers.BCAction;
import buildcraft.core.triggers.BCTrigger;
@ -425,7 +426,7 @@ public class BuildCraftTransport extends BuildCraftMod {
@Mod.EventHandler
public void init(FMLInitializationEvent evt) {
channels = NetworkRegistry.INSTANCE.newChannel
(DefaultProps.NET_CHANNEL_NAME + "-TRANSPORT", new PacketHandlerTransport());
(DefaultProps.NET_CHANNEL_NAME + "-TRANSPORT", new BuildCraftChannelHandler(), new PacketHandlerTransport());
// Register connection handler
// MinecraftForge.registerConnectionHandler(new ConnectionHandler());

View file

@ -10,8 +10,9 @@ package buildcraft.core.network;
import java.io.IOException;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.network.INetHandler;
@ -20,13 +21,10 @@ import net.minecraft.world.World;
import cpw.mods.fml.common.network.NetworkRegistry;
import net.minecraftforge.common.DimensionManager;
import buildcraft.core.proxy.CoreProxy;
import buildcraft.transport.TileGenericPipe;
public class PacketHandler extends BuildCraftChannelHandler {
@Sharable
public class PacketHandler extends SimpleChannelInboundHandler<BuildCraftPacket> {
private void onTileUpdate(EntityPlayer player, PacketTileUpdate packet) throws IOException {
World world = player.worldObj;
@ -46,10 +44,7 @@ public class PacketHandler extends BuildCraftChannelHandler {
}
@Override
public void decodeInto(ChannelHandlerContext ctx, ByteBuf data, BuildCraftPacket packet) {
super.decodeInto(ctx, data, packet);
protected void channelRead0(ChannelHandlerContext ctx, BuildCraftPacket packet) {
try {
INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
EntityPlayer player = CoreProxy.proxy.getPlayerFromNetHandler(netHandler);
@ -69,7 +64,7 @@ public class PacketHandler extends BuildCraftChannelHandler {
TileEntity tile = world.getTileEntity(pkt.posX, pkt.posY, pkt.posZ);
if (tile instanceof ISyncedTile) {
pkt.applyStates(data, (ISyncedTile) tile);
pkt.applyStates((ISyncedTile) tile);
}
break;
@ -92,36 +87,32 @@ public class PacketHandler extends BuildCraftChannelHandler {
}
case PacketIds.RPC_PIPE: {
PacketRPCPipe rpc = new PacketRPCPipe();
rpc.sender = player;
int dimId = data.readShort();
World world = null;
if (!rpc.sender.worldObj.isRemote) {
// if this is a server, then get the world
world = DimensionManager.getProvider(dimId).worldObj;
} else if (rpc.sender.worldObj.provider.dimensionId == dimId) {
// if the player is on this world, then synchronize things
world = rpc.sender.worldObj;
}
if (world != null) {
int x = data.readInt();
int y = data.readInt();
int z = data.readInt();
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TileGenericPipe) {
rpc.setPipe (((TileGenericPipe) tile).pipe);
rpc.readData(data);
}
}
// TODO: RPC pipes are not used right now. Ressurect this
// code if needed later.
/*
* PacketRPCPipe rpc = new PacketRPCPipe(); rpc.sender = player;
*
* int dimId = data.readShort(); World world = null;
*
* if (!rpc.sender.worldObj.isRemote) { // if this is a server,
* then get the world
*
* world = DimensionManager.getProvider(dimId).worldObj; } else
* if (rpc.sender.worldObj.provider.dimensionId == dimId) { //
* if the player is on this world, then synchronize things
*
* world = rpc.sender.worldObj; }
*
* if (world != null) { int x = data.readInt(); int y =
* data.readInt(); int z = data.readInt();
*
* TileEntity tile = world.getTileEntity(x, y, z);
*
* if (tile instanceof TileGenericPipe) { rpc.setPipe
* (((TileGenericPipe) tile).pipe); rpc.readData(data); } }
*/
break;
}
}
} catch (Exception ex) {

View file

@ -14,6 +14,7 @@ import net.minecraft.entity.player.EntityPlayer;
import buildcraft.transport.Pipe;
// TODO: This is not yet used
public class PacketRPCPipe extends BuildCraftPacket {
public Pipe pipe;

View file

@ -13,9 +13,12 @@ import java.util.LinkedList;
import java.util.List;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
public class PacketTileState extends PacketCoordinates {
private ByteBuf state;
private class StateWithId {
public byte stateId;
public IClientState state;
@ -50,16 +53,11 @@ public class PacketTileState extends PacketCoordinates {
return PacketIds.STATE_UPDATE;
}
@Override
public void readData(ByteBuf data) {
super.readData(data);
}
public void applyStates(ByteBuf data, ISyncedTile tile) throws IOException {
byte stateCount = data.readByte();
public void applyStates(ISyncedTile tile) throws IOException {
byte stateCount = state.readByte();
for (int i = 0; i < stateCount; i++) {
byte stateId = data.readByte();
tile.getStateInstance(stateId).readData(data);
byte stateId = state.readByte();
tile.getStateInstance(stateId).readData(state);
tile.afterStateUpdated(stateId);
}
}
@ -71,10 +69,25 @@ public class PacketTileState extends PacketCoordinates {
@Override
public void writeData(ByteBuf data) {
super.writeData(data);
data.writeByte(stateList.size());
ByteBuf tmpState = Unpooled.buffer();
tmpState.writeByte(stateList.size());
for (StateWithId stateWithId : stateList) {
data.writeByte(stateWithId.stateId);
stateWithId.state.writeData(data);
}
tmpState.writeByte(stateWithId.stateId);
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

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

View file

@ -8,8 +8,9 @@
*/
package buildcraft.silicon.network;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
@ -19,7 +20,6 @@ import net.minecraft.world.World;
import cpw.mods.fml.common.network.NetworkRegistry;
import buildcraft.core.network.BuildCraftChannelHandler;
import buildcraft.core.network.BuildCraftPacket;
import buildcraft.core.network.PacketCoordinates;
import buildcraft.core.network.PacketIds;
@ -31,12 +31,11 @@ import buildcraft.silicon.TileAssemblyTable;
import buildcraft.silicon.TileAssemblyTable.SelectionMessage;
import buildcraft.silicon.gui.ContainerAssemblyTable;
public class PacketHandlerSilicon extends BuildCraftChannelHandler {
@Sharable
public class PacketHandlerSilicon extends SimpleChannelInboundHandler<BuildCraftPacket> {
@Override
public void decodeInto(ChannelHandlerContext ctx, ByteBuf data, BuildCraftPacket packet) {
super.decodeInto(ctx, data, packet);
protected void channelRead0(ChannelHandlerContext ctx, BuildCraftPacket packet) {
try {
INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();

View file

@ -8,8 +8,9 @@
*/
package buildcraft.transport.network;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
@ -19,7 +20,6 @@ import net.minecraft.world.World;
import cpw.mods.fml.common.network.NetworkRegistry;
import buildcraft.core.network.BuildCraftChannelHandler;
import buildcraft.core.network.BuildCraftPacket;
import buildcraft.core.network.PacketCoordinates;
import buildcraft.core.network.PacketIds;
@ -33,7 +33,8 @@ import buildcraft.transport.gui.ContainerGateInterface;
import buildcraft.transport.pipes.PipeItemsDiamond;
import buildcraft.transport.pipes.PipeItemsEmerald;
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.
@ -42,8 +43,7 @@ public class PacketHandlerTransport extends BuildCraftChannelHandler {
* RPCs.
*/
@Override
public void decodeInto(ChannelHandlerContext ctx, ByteBuf data, BuildCraftPacket packet) {
super.decodeInto(ctx, data, packet);
protected void channelRead0(ChannelHandlerContext ctx, BuildCraftPacket packet) {
try {
INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
EntityPlayer player = CoreProxy.proxy.getPlayerFromNetHandler(netHandler);