Search in sources :

Example 1 with PacketSocketUpdate

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);
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) PacketPayload(forestry.core.network.PacketPayload) PacketSocketUpdate(forestry.core.network.PacketSocketUpdate) PacketUpdate(forestry.core.network.PacketUpdate) ItemStack(net.minecraft.item.ItemStack)

Example 2 with PacketSocketUpdate

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);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) PacketPayload(forestry.core.network.PacketPayload) PacketSocketUpdate(forestry.core.network.PacketSocketUpdate) PacketUpdate(forestry.core.network.PacketUpdate) ItemStack(net.minecraft.item.ItemStack)

Example 3 with PacketSocketUpdate

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;
    }
}
Also used : ContainerEngineBronze(forestry.energy.gui.ContainerEngineBronze) ContainerGenerator(forestry.energy.gui.ContainerGenerator) PacketSocketUpdate(forestry.core.network.PacketSocketUpdate) ContainerEngineTin(forestry.energy.gui.ContainerEngineTin) EngineTin(forestry.energy.gadgets.EngineTin) GuiEngineTin(forestry.energy.gui.GuiEngineTin) ContainerEngineCopper(forestry.energy.gui.ContainerEngineCopper) ContainerEngineTin(forestry.energy.gui.ContainerEngineTin)

Example 4 with PacketSocketUpdate

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;
    }
}
Also used : ContainerFarm(forestry.farming.gui.ContainerFarm) PacketSocketUpdate(forestry.core.network.PacketSocketUpdate) TileFarmPlain(forestry.farming.gadgets.TileFarmPlain)

Aggregations

PacketSocketUpdate (forestry.core.network.PacketSocketUpdate)4 PacketPayload (forestry.core.network.PacketPayload)2 PacketUpdate (forestry.core.network.PacketUpdate)2 ItemStack (net.minecraft.item.ItemStack)2 TileEntity (net.minecraft.tileentity.TileEntity)2 EngineTin (forestry.energy.gadgets.EngineTin)1 ContainerEngineBronze (forestry.energy.gui.ContainerEngineBronze)1 ContainerEngineCopper (forestry.energy.gui.ContainerEngineCopper)1 ContainerEngineTin (forestry.energy.gui.ContainerEngineTin)1 ContainerGenerator (forestry.energy.gui.ContainerGenerator)1 GuiEngineTin (forestry.energy.gui.GuiEngineTin)1 TileFarmPlain (forestry.farming.gadgets.TileFarmPlain)1 ContainerFarm (forestry.farming.gui.ContainerFarm)1