diff --git a/common/buildcraft/builders/gui/GuiBlueprintLibrary.java b/common/buildcraft/builders/gui/GuiBlueprintLibrary.java index 11f9be53..822e25ae 100644 --- a/common/buildcraft/builders/gui/GuiBlueprintLibrary.java +++ b/common/buildcraft/builders/gui/GuiBlueprintLibrary.java @@ -140,7 +140,7 @@ public class GuiBlueprintLibrary extends GuiBuildCraft { } else if (deleteButton != null && button == deleteButton) { packet.actionId = TileBlueprintLibrary.COMMAND_DELETE; } - CoreProxy.proxy.sendToServer(packet.getPacket()); + BuildCraftBuilders.instance.sendToServer(packet); } @Override @@ -162,7 +162,7 @@ public class GuiBlueprintLibrary extends GuiBuildCraft { payload.intPayload = new int[]{ySlot}; PacketLibraryAction packet = new PacketLibraryAction(PacketIds.LIBRARY_SELECT, library.xCoord, library.yCoord, library.zCoord); packet.actionId = ySlot; - CoreProxy.proxy.sendToServer(packet.getPacket()); + BuildCraftBuilders.instance.sendToServer(packet); } } } diff --git a/common/buildcraft/builders/gui/GuiTemplate.java b/common/buildcraft/builders/gui/GuiTemplate.java index a54f8f1b..d105b0c0 100644 --- a/common/buildcraft/builders/gui/GuiTemplate.java +++ b/common/buildcraft/builders/gui/GuiTemplate.java @@ -7,6 +7,7 @@ */ package buildcraft.builders.gui; +import buildcraft.BuildCraftBuilders; import buildcraft.builders.TileArchitect; import buildcraft.core.DefaultProps; import buildcraft.core.gui.GuiBuildCraft; @@ -16,9 +17,12 @@ import buildcraft.core.network.PacketPayloadArrays; import buildcraft.core.network.PacketUpdate; import buildcraft.core.proxy.CoreProxy; import buildcraft.core.utils.StringUtils; + import java.util.Date; + import net.minecraft.inventory.IInventory; import net.minecraft.util.ResourceLocation; + import org.lwjgl.opengl.GL11; public class GuiTemplate extends GuiBuildCraft { @@ -87,7 +91,7 @@ public class GuiTemplate extends GuiBuildCraft { PacketPayloadArrays payload = new PacketPayloadArrays(); payload.intPayload = new int[]{c}; PacketUpdate packet = new PacketUpdate(PacketIds.ARCHITECT_NAME, template.xCoord, template.yCoord, template.zCoord, payload); - CoreProxy.proxy.sendToServer(packet.getPacket()); + BuildCraftBuilders.instance.sendToServer(packet); } else { super.keyTyped(c, i); } diff --git a/common/buildcraft/core/TileBuildCraft.java b/common/buildcraft/core/TileBuildCraft.java index aece4119..5fc46dd7 100644 --- a/common/buildcraft/core/TileBuildCraft.java +++ b/common/buildcraft/core/TileBuildCraft.java @@ -7,6 +7,7 @@ */ package buildcraft.core; +import buildcraft.BuildCraftMod; import buildcraft.api.power.IPowerReceptor; import buildcraft.core.network.ISynchronizedTile; import buildcraft.core.network.PacketPayload; @@ -16,9 +17,11 @@ import buildcraft.core.network.PacketUpdate; import buildcraft.core.network.TilePacketWrapper; import buildcraft.core.proxy.CoreProxy; import buildcraft.core.utils.Utils; + import java.io.IOException; import java.util.HashMap; import java.util.Map; + import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -87,9 +90,9 @@ public abstract class TileBuildCraft extends TileEntity implements ISynchronized public void destroy() { } - public void sendNetworkUpdate() { + public void sendNetworkUpdate(BuildCraftMod mod) { if (CoreProxy.proxy.isSimulating(worldObj)) { - CoreProxy.proxy.sendToPlayers(getUpdatePacket(), worldObj, xCoord, yCoord, zCoord, DefaultProps.NETWORK_UPDATE_RANGE); + mod.sendToPlayers(getUpdatePacket(), worldObj, xCoord, yCoord, zCoord, DefaultProps.NETWORK_UPDATE_RANGE); } } diff --git a/common/buildcraft/factory/gui/ContainerRefinery.java b/common/buildcraft/factory/gui/ContainerRefinery.java index 52cc1af3..bfdd3945 100644 --- a/common/buildcraft/factory/gui/ContainerRefinery.java +++ b/common/buildcraft/factory/gui/ContainerRefinery.java @@ -7,14 +7,18 @@ */ package buildcraft.factory.gui; +import buildcraft.BuildCraftFactory; import buildcraft.core.gui.BuildCraftContainer; import buildcraft.core.network.PacketIds; import buildcraft.core.network.PacketPayloadStream; import buildcraft.core.network.PacketUpdate; import buildcraft.core.proxy.CoreProxy; import buildcraft.factory.TileRefinery; +import io.netty.buffer.ByteBuf; + import java.io.DataOutputStream; import java.io.IOException; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.ICrafting; @@ -54,13 +58,12 @@ public class ContainerRefinery extends BuildCraftContainer { if (CoreProxy.proxy.isRenderWorld(refinery.worldObj)) { PacketPayloadStream payload = new PacketPayloadStream(new PacketPayloadStream.StreamWriter() { @Override - public void writeData(DataOutputStream data) throws IOException { + public void writeData(ByteBuf data) { data.writeByte(slot); data.writeShort(filter != null ? filter.getID() : -1); } }); - CoreProxy.proxy.sendToServer(new PacketUpdate(PacketIds.REFINERY_FILTER_SET, refinery.xCoord, refinery.yCoord, refinery.zCoord, payload) - .getPacket()); + BuildCraftFactory.instance.sendToServer(new PacketUpdate(PacketIds.REFINERY_FILTER_SET, refinery.xCoord, refinery.yCoord, refinery.zCoord, payload)); } } diff --git a/common/buildcraft/silicon/TileAdvancedCraftingTable.java b/common/buildcraft/silicon/TileAdvancedCraftingTable.java index 2ffe3efd..18f814c6 100644 --- a/common/buildcraft/silicon/TileAdvancedCraftingTable.java +++ b/common/buildcraft/silicon/TileAdvancedCraftingTable.java @@ -2,6 +2,7 @@ package buildcraft.silicon; import buildcraft.api.power.ILaserTarget; import buildcraft.BuildCraftCore; +import buildcraft.BuildCraftSilicon; import buildcraft.api.gates.IAction; import buildcraft.api.gates.IActionReceptor; import buildcraft.core.IMachine; @@ -23,9 +24,12 @@ import buildcraft.core.triggers.ActionMachineControl; import buildcraft.core.utils.CraftingHelper; import buildcraft.core.utils.StringUtils; import buildcraft.core.utils.Utils; + import com.google.common.collect.Lists; + import java.util.EnumSet; import java.util.List; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; @@ -46,6 +50,7 @@ import static net.minecraftforge.common.ForgeDirection.NORTH; import static net.minecraftforge.common.ForgeDirection.SOUTH; import static net.minecraftforge.common.ForgeDirection.WEST; import net.minecraftforge.oredict.OreDictionary; + import org.bouncycastle.util.Arrays; public class TileAdvancedCraftingTable extends TileLaserTableBase implements IInventory, ILaserTarget, IMachine, IActionReceptor, ISidedInventory { @@ -366,7 +371,7 @@ public class TileAdvancedCraftingTable extends TileLaserTableBase implements IIn updateRecipe(); if (CoreProxy.proxy.isRenderWorld(worldObj)) { PacketSlotChange packet = new PacketSlotChange(PacketIds.ADVANCED_WORKBENCH_SETSLOT, xCoord, yCoord, zCoord, slot, stack); - CoreProxy.proxy.sendToServer(packet.getPacket()); + BuildCraftSilicon.instance.sendToServer(packet); } } diff --git a/common/buildcraft/silicon/TileAssemblyTable.java b/common/buildcraft/silicon/TileAssemblyTable.java index 40c991f2..5f9fb26b 100644 --- a/common/buildcraft/silicon/TileAssemblyTable.java +++ b/common/buildcraft/silicon/TileAssemblyTable.java @@ -1,5 +1,6 @@ package buildcraft.silicon; +import buildcraft.BuildCraftSilicon; import buildcraft.core.recipes.AssemblyRecipeManager; import buildcraft.api.gates.IAction; import buildcraft.core.DefaultProps; @@ -11,10 +12,12 @@ import buildcraft.core.utils.Utils; import buildcraft.core.recipes.AssemblyRecipeManager.AssemblyRecipe; import buildcraft.core.utils.StringUtils; import cpw.mods.fml.common.FMLCommonHandler; + import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; import java.util.Set; + import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; @@ -272,7 +275,7 @@ public class TileAssemblyTable extends TileLaserTableBase implements IMachine, I packet.posY = yCoord; packet.posZ = zCoord; // FIXME: This needs to be switched over to new synch system. - CoreProxy.proxy.sendToPlayers(packet.getPacket(), worldObj, (int) player.posX, (int) player.posY, (int) player.posZ, + BuildCraftSilicon.instance.sendToPlayers(packet, worldObj, (int) player.posX, (int) player.posY, (int) player.posZ, DefaultProps.NETWORK_UPDATE_RANGE); } } diff --git a/common/buildcraft/silicon/gui/GuiAssemblyTable.java b/common/buildcraft/silicon/gui/GuiAssemblyTable.java index a7af3c15..8a961c6a 100644 --- a/common/buildcraft/silicon/gui/GuiAssemblyTable.java +++ b/common/buildcraft/silicon/gui/GuiAssemblyTable.java @@ -8,6 +8,7 @@ package buildcraft.silicon.gui; import buildcraft.BuildCraftCore; +import buildcraft.BuildCraftSilicon; import buildcraft.core.CoreIconProvider; import buildcraft.core.DefaultProps; import buildcraft.core.gui.GuiAdvancedInterface; @@ -19,13 +20,16 @@ import buildcraft.core.utils.StringUtils; import buildcraft.core.recipes.AssemblyRecipeManager.AssemblyRecipe; import buildcraft.silicon.TileAssemblyTable; import buildcraft.silicon.TileAssemblyTable.SelectionMessage; + import java.util.Iterator; import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; + import org.lwjgl.opengl.GL11; public class GuiAssemblyTable extends GuiAdvancedInterface { @@ -112,8 +116,8 @@ public class GuiAssemblyTable extends GuiAdvancedInterface { // Request current selection from server if (CoreProxy.proxy.isRenderWorld(assemblyTable.worldObj)) { - CoreProxy.proxy.sendToServer(new PacketCoordinates(PacketIds.SELECTION_ASSEMBLY_GET, assemblyTable.xCoord, assemblyTable.yCoord, - assemblyTable.zCoord).getPacket()); + BuildCraftSilicon.instance.sendToServer(new PacketCoordinates(PacketIds.SELECTION_ASSEMBLY_GET, assemblyTable.xCoord, assemblyTable.yCoord, + assemblyTable.zCoord)); } } @@ -197,7 +201,7 @@ public class GuiAssemblyTable extends GuiAdvancedInterface { PacketNBT packet = new PacketNBT(PacketIds.SELECTION_ASSEMBLY, message.getNBT(), table.xCoord, table.yCoord, table.zCoord); - CoreProxy.proxy.sendToServer(packet.getPacket()); + BuildCraftSilicon.instance.sendToServer(packet); } } diff --git a/common/buildcraft/transport/PipeTransportFluids.java b/common/buildcraft/transport/PipeTransportFluids.java index 7f666a64..575f65ce 100644 --- a/common/buildcraft/transport/PipeTransportFluids.java +++ b/common/buildcraft/transport/PipeTransportFluids.java @@ -19,6 +19,7 @@ import net.minecraftforge.fluids.FluidTank; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; import buildcraft.BuildCraftCore; +import buildcraft.BuildCraftTransport; import buildcraft.api.core.SafeTimeTracker; import buildcraft.api.gates.ITrigger; import buildcraft.api.transport.IPipeTile.PipeType; @@ -201,7 +202,7 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler } PacketFluidUpdate packet = computeFluidUpdate(init, true); if (packet != null) { - CoreProxy.proxy.sendToPlayers(packet.getPacket(), container.worldObj, container.xCoord, container.yCoord, container.zCoord, DefaultProps.PIPE_CONTENTS_RENDER_DIST); + BuildCraftTransport.instance.sendToPlayers(packet, container.worldObj, container.xCoord, container.yCoord, container.zCoord, DefaultProps.PIPE_CONTENTS_RENDER_DIST); } } } diff --git a/common/buildcraft/transport/PipeTransportPower.java b/common/buildcraft/transport/PipeTransportPower.java index edc9b138..25714679 100644 --- a/common/buildcraft/transport/PipeTransportPower.java +++ b/common/buildcraft/transport/PipeTransportPower.java @@ -15,6 +15,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; import buildcraft.BuildCraftCore; +import buildcraft.BuildCraftTransport; import buildcraft.api.core.SafeTimeTracker; import buildcraft.api.gates.ITrigger; import buildcraft.api.power.IPowerEmitter; @@ -258,7 +259,7 @@ public class PipeTransportPower extends PipeTransport { packet.displayPower = clientDisplayPower; packet.overload = isOverloaded(); - CoreProxy.proxy.sendToPlayers(packet.getPacket(), container.worldObj, container.xCoord, container.yCoord, container.zCoord, DefaultProps.PIPE_CONTENTS_RENDER_DIST); + BuildCraftTransport.instance.sendToPlayers(packet, container.worldObj, container.xCoord, container.yCoord, container.zCoord, DefaultProps.PIPE_CONTENTS_RENDER_DIST); } } diff --git a/common/buildcraft/transport/gui/ContainerGateInterface.java b/common/buildcraft/transport/gui/ContainerGateInterface.java index 0f0f988e..e0a1a2cf 100644 --- a/common/buildcraft/transport/gui/ContainerGateInterface.java +++ b/common/buildcraft/transport/gui/ContainerGateInterface.java @@ -7,6 +7,7 @@ */ package buildcraft.transport.gui; +import buildcraft.BuildCraftTransport; import buildcraft.api.gates.ActionManager; import buildcraft.api.gates.IAction; import buildcraft.api.gates.IOverrideDefaultTriggers; @@ -215,7 +216,7 @@ public class ContainerGateInterface extends BuildCraftContainer { } public void sendSelectionChange(int position) { - CoreProxy.proxy.sendToServer(new PacketUpdate(PacketIds.GATE_SELECTION_CHANGE, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord, getSelectionPayload(position)).getPacket()); + BuildCraftTransport.instance.sendToServer(new PacketUpdate(PacketIds.GATE_SELECTION_CHANGE, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord, getSelectionPayload(position))); } /** @@ -226,12 +227,12 @@ public class ContainerGateInterface extends BuildCraftContainer { if (!isNetInitialized && CoreProxy.proxy.isRenderWorld(pipe.container.worldObj)) { isNetInitialized = true; - CoreProxy.proxy.sendToServer(new PacketCoordinates(PacketIds.GATE_REQUEST_INIT, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord).getPacket()); + BuildCraftTransport.instance.sendToServer(new PacketCoordinates(PacketIds.GATE_REQUEST_INIT, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord)); } if (!isSynchronized && CoreProxy.proxy.isRenderWorld(pipe.container.worldObj)) { isSynchronized = true; - CoreProxy.proxy.sendToServer(new PacketCoordinates(PacketIds.GATE_REQUEST_SELECTION, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord).getPacket()); + BuildCraftTransport.instance.sendToServer(new PacketCoordinates(PacketIds.GATE_REQUEST_SELECTION, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord)); } } @@ -301,7 +302,7 @@ public class ContainerGateInterface extends BuildCraftContainer { PacketUpdate packet = new PacketUpdate(PacketIds.GATE_ACTIONS, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord, payload); // Send to player - CoreProxy.proxy.sendToPlayer(player, packet); + BuildCraftTransport.instance.sendToPlayer(player, packet); } /** @@ -324,7 +325,7 @@ public class ContainerGateInterface extends BuildCraftContainer { PacketUpdate packet = new PacketUpdate(PacketIds.GATE_TRIGGERS, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord, payload); // Send to player - CoreProxy.proxy.sendToPlayer(player, packet); + BuildCraftTransport.instance.sendToPlayer(player, packet); } /** @@ -336,7 +337,7 @@ public class ContainerGateInterface extends BuildCraftContainer { if (pipe == null || pipe.gate == null) return; for (int position = 0; position < pipe.gate.material.numSlots; position++) { - CoreProxy.proxy.sendToPlayer(player, new PacketUpdate(PacketIds.GATE_SELECTION, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord, getSelectionPayload(position))); + BuildCraftTransport.instance.sendToPlayer(player, new PacketUpdate(PacketIds.GATE_SELECTION, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord, getSelectionPayload(position))); } // System.out.println("Sending current selection to player");