use of forestry.core.network.PacketSocketUpdate in project ForestryMC by ForestryMC.
the class ContainerSocketed method handleChipsetClick.
public void handleChipsetClick(int slot, EntityPlayer player, ItemStack itemstack) {
if (!Proxies.common.isSimulating(player.worldObj)) {
PacketPayload payload = new PacketPayload(1, 0, 0);
payload.intPayload[0] = slot;
Proxies.net.sendToServer(new PacketUpdate(PacketIds.CHIPSET_CLICK, payload));
player.inventory.setItemStack(null);
return;
}
ItemStack toSocket = itemstack.copy();
toSocket.stackSize = 1;
tile.setSocket(slot, toSocket);
if (Proxies.common.isSimulating(player.worldObj)) {
ItemStack stack = player.inventory.getItemStack();
stack.stackSize--;
if (stack.stackSize <= 0) {
player.inventory.setItemStack(null);
}
Proxies.net.inventoryChangeNotify(player);
TileEntity te = (TileEntity) tile;
Proxies.net.sendToPlayer(new PacketSocketUpdate(PacketIds.SOCKET_UPDATE, te.xCoord, te.yCoord, te.zCoord, tile), player);
}
}
use of forestry.core.network.PacketSocketUpdate in project ForestryMC by ForestryMC.
the class ContainerSocketed method handleSolderingIronClick.
public void handleSolderingIronClick(int slot, EntityPlayer player, ItemStack itemstack) {
if (!Proxies.common.isSimulating(player.worldObj)) {
PacketPayload payload = new PacketPayload(1, 0, 0);
payload.intPayload[0] = slot;
Proxies.net.sendToServer(new PacketUpdate(PacketIds.SOLDERING_IRON_CLICK, payload));
return;
}
ItemStack socket = tile.getSocket(slot);
if (socket == null) {
return;
}
StackUtils.stowInInventory(socket, player.inventory, true);
// Not sufficient space in player's inventory. failed to stow.
if (socket.stackSize > 0) {
return;
}
tile.setSocket(slot, null);
itemstack.damageItem(1, player);
if (itemstack.stackSize <= 0) {
player.inventory.setItemStack(null);
}
TileEntity te = (TileEntity) tile;
Proxies.net.sendToPlayer(new PacketSocketUpdate(PacketIds.SOCKET_UPDATE, te.xCoord, te.yCoord, te.zCoord, tile), player);
}
use of forestry.core.network.PacketSocketUpdate in project ForestryMC by ForestryMC.
the class GuiHandlerEnergy method getServerGuiElement.
@Override
public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
if (id >= GuiId.values().length) {
return null;
}
switch(GuiId.values()[id]) {
case EngineBronzeGUI:
return new ContainerEngineBronze(player.inventory, (EngineBronze) getTileForestry(world, x, y, z));
case EngineCopperGUI:
return new ContainerEngineCopper(player.inventory, (EngineCopper) getTileForestry(world, x, y, z));
case EngineTinGUI:
EngineTin tile = (EngineTin) getTileForestry(world, x, y, z);
Proxies.net.sendToPlayer(new PacketSocketUpdate(PacketIds.SOCKET_UPDATE, x, y, z, tile), player);
return new ContainerEngineTin(player.inventory, tile);
case GeneratorGUI:
return new ContainerGenerator(player.inventory, (MachineGenerator) getTileForestry(world, x, y, z));
default:
return null;
}
}
use of forestry.core.network.PacketSocketUpdate in project ForestryMC by ForestryMC.
the class GuiHandlerFarming method getServerGuiElement.
@Override
public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
if (id >= GuiId.values().length) {
return null;
}
switch(GuiId.values()[id]) {
case MultiFarmGUI:
TileFarmPlain tile = (TileFarmPlain) getTileForestry(world, x, y, z);
Proxies.net.sendToPlayer(new PacketSocketUpdate(PacketIds.SOCKET_UPDATE, x, y, z, tile), player);
return new ContainerFarm(player.inventory, tile);
default:
return null;
}
}
Aggregations