migrated part of the sendTo* calls to the new network API

This commit is contained in:
SpaceToad 2014-01-14 19:22:10 +01:00
parent 14003341e3
commit 3b973044ea
10 changed files with 46 additions and 21 deletions

View file

@ -140,7 +140,7 @@ public class GuiBlueprintLibrary extends GuiBuildCraft {
} else if (deleteButton != null && button == deleteButton) { } else if (deleteButton != null && button == deleteButton) {
packet.actionId = TileBlueprintLibrary.COMMAND_DELETE; packet.actionId = TileBlueprintLibrary.COMMAND_DELETE;
} }
CoreProxy.proxy.sendToServer(packet.getPacket()); BuildCraftBuilders.instance.sendToServer(packet);
} }
@Override @Override
@ -162,7 +162,7 @@ public class GuiBlueprintLibrary extends GuiBuildCraft {
payload.intPayload = new int[]{ySlot}; payload.intPayload = new int[]{ySlot};
PacketLibraryAction packet = new PacketLibraryAction(PacketIds.LIBRARY_SELECT, library.xCoord, library.yCoord, library.zCoord); PacketLibraryAction packet = new PacketLibraryAction(PacketIds.LIBRARY_SELECT, library.xCoord, library.yCoord, library.zCoord);
packet.actionId = ySlot; packet.actionId = ySlot;
CoreProxy.proxy.sendToServer(packet.getPacket()); BuildCraftBuilders.instance.sendToServer(packet);
} }
} }
} }

View file

@ -7,6 +7,7 @@
*/ */
package buildcraft.builders.gui; package buildcraft.builders.gui;
import buildcraft.BuildCraftBuilders;
import buildcraft.builders.TileArchitect; import buildcraft.builders.TileArchitect;
import buildcraft.core.DefaultProps; import buildcraft.core.DefaultProps;
import buildcraft.core.gui.GuiBuildCraft; import buildcraft.core.gui.GuiBuildCraft;
@ -16,9 +17,12 @@ 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 buildcraft.core.utils.StringUtils; import buildcraft.core.utils.StringUtils;
import java.util.Date; import java.util.Date;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
public class GuiTemplate extends GuiBuildCraft { public class GuiTemplate extends GuiBuildCraft {
@ -87,7 +91,7 @@ public class GuiTemplate extends GuiBuildCraft {
PacketPayloadArrays payload = new PacketPayloadArrays(); PacketPayloadArrays payload = new PacketPayloadArrays();
payload.intPayload = new int[]{c}; payload.intPayload = new int[]{c};
PacketUpdate packet = new PacketUpdate(PacketIds.ARCHITECT_NAME, template.xCoord, template.yCoord, template.zCoord, payload); PacketUpdate packet = new PacketUpdate(PacketIds.ARCHITECT_NAME, template.xCoord, template.yCoord, template.zCoord, payload);
CoreProxy.proxy.sendToServer(packet.getPacket()); BuildCraftBuilders.instance.sendToServer(packet);
} else { } else {
super.keyTyped(c, i); super.keyTyped(c, i);
} }

View file

@ -7,6 +7,7 @@
*/ */
package buildcraft.core; package buildcraft.core;
import buildcraft.BuildCraftMod;
import buildcraft.api.power.IPowerReceptor; import buildcraft.api.power.IPowerReceptor;
import buildcraft.core.network.ISynchronizedTile; import buildcraft.core.network.ISynchronizedTile;
import buildcraft.core.network.PacketPayload; import buildcraft.core.network.PacketPayload;
@ -16,9 +17,11 @@ import buildcraft.core.network.PacketUpdate;
import buildcraft.core.network.TilePacketWrapper; import buildcraft.core.network.TilePacketWrapper;
import buildcraft.core.proxy.CoreProxy; import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.utils.Utils; import buildcraft.core.utils.Utils;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -87,9 +90,9 @@ public abstract class TileBuildCraft extends TileEntity implements ISynchronized
public void destroy() { public void destroy() {
} }
public void sendNetworkUpdate() { public void sendNetworkUpdate(BuildCraftMod mod) {
if (CoreProxy.proxy.isSimulating(worldObj)) { 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);
} }
} }

View file

@ -7,14 +7,18 @@
*/ */
package buildcraft.factory.gui; package buildcraft.factory.gui;
import buildcraft.BuildCraftFactory;
import buildcraft.core.gui.BuildCraftContainer; import buildcraft.core.gui.BuildCraftContainer;
import buildcraft.core.network.PacketIds; import buildcraft.core.network.PacketIds;
import buildcraft.core.network.PacketPayloadStream; 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 io.netty.buffer.ByteBuf;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.ICrafting;
@ -54,13 +58,12 @@ public class ContainerRefinery extends BuildCraftContainer {
if (CoreProxy.proxy.isRenderWorld(refinery.worldObj)) { if (CoreProxy.proxy.isRenderWorld(refinery.worldObj)) {
PacketPayloadStream payload = new PacketPayloadStream(new PacketPayloadStream.StreamWriter() { PacketPayloadStream payload = new PacketPayloadStream(new PacketPayloadStream.StreamWriter() {
@Override @Override
public void writeData(DataOutputStream data) throws IOException { public void writeData(ByteBuf data) {
data.writeByte(slot); data.writeByte(slot);
data.writeShort(filter != null ? filter.getID() : -1); data.writeShort(filter != null ? filter.getID() : -1);
} }
}); });
CoreProxy.proxy.sendToServer(new PacketUpdate(PacketIds.REFINERY_FILTER_SET, refinery.xCoord, refinery.yCoord, refinery.zCoord, payload) BuildCraftFactory.instance.sendToServer(new PacketUpdate(PacketIds.REFINERY_FILTER_SET, refinery.xCoord, refinery.yCoord, refinery.zCoord, payload));
.getPacket());
} }
} }

View file

@ -2,6 +2,7 @@ package buildcraft.silicon;
import buildcraft.api.power.ILaserTarget; import buildcraft.api.power.ILaserTarget;
import buildcraft.BuildCraftCore; import buildcraft.BuildCraftCore;
import buildcraft.BuildCraftSilicon;
import buildcraft.api.gates.IAction; import buildcraft.api.gates.IAction;
import buildcraft.api.gates.IActionReceptor; import buildcraft.api.gates.IActionReceptor;
import buildcraft.core.IMachine; import buildcraft.core.IMachine;
@ -23,9 +24,12 @@ import buildcraft.core.triggers.ActionMachineControl;
import buildcraft.core.utils.CraftingHelper; import buildcraft.core.utils.CraftingHelper;
import buildcraft.core.utils.StringUtils; import buildcraft.core.utils.StringUtils;
import buildcraft.core.utils.Utils; import buildcraft.core.utils.Utils;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.List; import java.util.List;
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.inventory.IInventory; 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.SOUTH;
import static net.minecraftforge.common.ForgeDirection.WEST; import static net.minecraftforge.common.ForgeDirection.WEST;
import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.OreDictionary;
import org.bouncycastle.util.Arrays; import org.bouncycastle.util.Arrays;
public class TileAdvancedCraftingTable extends TileLaserTableBase implements IInventory, ILaserTarget, IMachine, IActionReceptor, ISidedInventory { public class TileAdvancedCraftingTable extends TileLaserTableBase implements IInventory, ILaserTarget, IMachine, IActionReceptor, ISidedInventory {
@ -366,7 +371,7 @@ public class TileAdvancedCraftingTable extends TileLaserTableBase implements IIn
updateRecipe(); updateRecipe();
if (CoreProxy.proxy.isRenderWorld(worldObj)) { if (CoreProxy.proxy.isRenderWorld(worldObj)) {
PacketSlotChange packet = new PacketSlotChange(PacketIds.ADVANCED_WORKBENCH_SETSLOT, xCoord, yCoord, zCoord, slot, stack); PacketSlotChange packet = new PacketSlotChange(PacketIds.ADVANCED_WORKBENCH_SETSLOT, xCoord, yCoord, zCoord, slot, stack);
CoreProxy.proxy.sendToServer(packet.getPacket()); BuildCraftSilicon.instance.sendToServer(packet);
} }
} }

View file

@ -1,5 +1,6 @@
package buildcraft.silicon; package buildcraft.silicon;
import buildcraft.BuildCraftSilicon;
import buildcraft.core.recipes.AssemblyRecipeManager; import buildcraft.core.recipes.AssemblyRecipeManager;
import buildcraft.api.gates.IAction; import buildcraft.api.gates.IAction;
import buildcraft.core.DefaultProps; import buildcraft.core.DefaultProps;
@ -11,10 +12,12 @@ import buildcraft.core.utils.Utils;
import buildcraft.core.recipes.AssemblyRecipeManager.AssemblyRecipe; import buildcraft.core.recipes.AssemblyRecipeManager.AssemblyRecipe;
import buildcraft.core.utils.StringUtils; import buildcraft.core.utils.StringUtils;
import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLCommonHandler;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
@ -272,7 +275,7 @@ public class TileAssemblyTable extends TileLaserTableBase implements IMachine, I
packet.posY = yCoord; packet.posY = yCoord;
packet.posZ = zCoord; packet.posZ = zCoord;
// FIXME: This needs to be switched over to new synch system. // 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); DefaultProps.NETWORK_UPDATE_RANGE);
} }
} }

View file

@ -8,6 +8,7 @@
package buildcraft.silicon.gui; package buildcraft.silicon.gui;
import buildcraft.BuildCraftCore; import buildcraft.BuildCraftCore;
import buildcraft.BuildCraftSilicon;
import buildcraft.core.CoreIconProvider; import buildcraft.core.CoreIconProvider;
import buildcraft.core.DefaultProps; import buildcraft.core.DefaultProps;
import buildcraft.core.gui.GuiAdvancedInterface; import buildcraft.core.gui.GuiAdvancedInterface;
@ -19,13 +20,16 @@ import buildcraft.core.utils.StringUtils;
import buildcraft.core.recipes.AssemblyRecipeManager.AssemblyRecipe; import buildcraft.core.recipes.AssemblyRecipeManager.AssemblyRecipe;
import buildcraft.silicon.TileAssemblyTable; import buildcraft.silicon.TileAssemblyTable;
import buildcraft.silicon.TileAssemblyTable.SelectionMessage; import buildcraft.silicon.TileAssemblyTable.SelectionMessage;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
public class GuiAssemblyTable extends GuiAdvancedInterface { public class GuiAssemblyTable extends GuiAdvancedInterface {
@ -112,8 +116,8 @@ public class GuiAssemblyTable extends GuiAdvancedInterface {
// Request current selection from server // Request current selection from server
if (CoreProxy.proxy.isRenderWorld(assemblyTable.worldObj)) { if (CoreProxy.proxy.isRenderWorld(assemblyTable.worldObj)) {
CoreProxy.proxy.sendToServer(new PacketCoordinates(PacketIds.SELECTION_ASSEMBLY_GET, assemblyTable.xCoord, assemblyTable.yCoord, BuildCraftSilicon.instance.sendToServer(new PacketCoordinates(PacketIds.SELECTION_ASSEMBLY_GET, assemblyTable.xCoord, assemblyTable.yCoord,
assemblyTable.zCoord).getPacket()); 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); PacketNBT packet = new PacketNBT(PacketIds.SELECTION_ASSEMBLY, message.getNBT(), table.xCoord, table.yCoord, table.zCoord);
CoreProxy.proxy.sendToServer(packet.getPacket()); BuildCraftSilicon.instance.sendToServer(packet);
} }
} }

View file

@ -19,6 +19,7 @@ import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler; import net.minecraftforge.fluids.IFluidHandler;
import buildcraft.BuildCraftCore; import buildcraft.BuildCraftCore;
import buildcraft.BuildCraftTransport;
import buildcraft.api.core.SafeTimeTracker; import buildcraft.api.core.SafeTimeTracker;
import buildcraft.api.gates.ITrigger; import buildcraft.api.gates.ITrigger;
import buildcraft.api.transport.IPipeTile.PipeType; import buildcraft.api.transport.IPipeTile.PipeType;
@ -201,7 +202,7 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler
} }
PacketFluidUpdate packet = computeFluidUpdate(init, true); PacketFluidUpdate packet = computeFluidUpdate(init, true);
if (packet != null) { 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);
} }
} }
} }

View file

@ -15,6 +15,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.BuildCraftCore; import buildcraft.BuildCraftCore;
import buildcraft.BuildCraftTransport;
import buildcraft.api.core.SafeTimeTracker; import buildcraft.api.core.SafeTimeTracker;
import buildcraft.api.gates.ITrigger; import buildcraft.api.gates.ITrigger;
import buildcraft.api.power.IPowerEmitter; import buildcraft.api.power.IPowerEmitter;
@ -258,7 +259,7 @@ public class PipeTransportPower extends PipeTransport {
packet.displayPower = clientDisplayPower; packet.displayPower = clientDisplayPower;
packet.overload = isOverloaded(); 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);
} }
} }

View file

@ -7,6 +7,7 @@
*/ */
package buildcraft.transport.gui; package buildcraft.transport.gui;
import buildcraft.BuildCraftTransport;
import buildcraft.api.gates.ActionManager; import buildcraft.api.gates.ActionManager;
import buildcraft.api.gates.IAction; import buildcraft.api.gates.IAction;
import buildcraft.api.gates.IOverrideDefaultTriggers; import buildcraft.api.gates.IOverrideDefaultTriggers;
@ -215,7 +216,7 @@ public class ContainerGateInterface extends BuildCraftContainer {
} }
public void sendSelectionChange(int position) { 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)) { if (!isNetInitialized && CoreProxy.proxy.isRenderWorld(pipe.container.worldObj)) {
isNetInitialized = true; 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)) { if (!isSynchronized && CoreProxy.proxy.isRenderWorld(pipe.container.worldObj)) {
isSynchronized = true; 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); PacketUpdate packet = new PacketUpdate(PacketIds.GATE_ACTIONS, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord, payload);
// Send to player // 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); PacketUpdate packet = new PacketUpdate(PacketIds.GATE_TRIGGERS, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord, payload);
// Send to player // 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) if (pipe == null || pipe.gate == null)
return; return;
for (int position = 0; position < pipe.gate.material.numSlots; position++) { 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"); // System.out.println("Sending current selection to player");