Search in sources :

Example 1 with PacketSocketUpdate

use of forestry.core.network.packets.PacketSocketUpdate in project ForestryMC by ForestryMC.

the class ContainerSocketedHelper method handleChipsetClickServer.

@Override
public void handleChipsetClickServer(int slot, EntityPlayerMP player, ItemStack itemstack) {
    if (!tile.getSocket(slot).isEmpty()) {
        return;
    }
    if (!ChipsetManager.circuitRegistry.isChipset(itemstack)) {
        return;
    }
    ICircuitBoard circuitBoard = ChipsetManager.circuitRegistry.getCircuitBoard(itemstack);
    if (circuitBoard == null) {
        return;
    }
    if (!tile.getSocketType().equals(circuitBoard.getSocketType())) {
        return;
    }
    ItemStack toSocket = itemstack.copy();
    toSocket.setCount(1);
    tile.setSocket(slot, toSocket);
    ItemStack stack = player.inventory.getItemStack();
    stack.shrink(1);
    player.updateHeldItem();
    PacketSocketUpdate packet = new PacketSocketUpdate(tile);
    NetworkUtil.sendToPlayer(packet, player);
}
Also used : ICircuitBoard(forestry.api.circuits.ICircuitBoard) PacketSocketUpdate(forestry.core.network.packets.PacketSocketUpdate) ItemStack(net.minecraft.item.ItemStack)

Example 2 with PacketSocketUpdate

use of forestry.core.network.packets.PacketSocketUpdate in project ForestryMC by ForestryMC.

the class ContainerSocketedHelper method handleSolderingIronClickServer.

@Override
public void handleSolderingIronClickServer(int slot, EntityPlayerMP player, ItemStack itemstack) {
    ItemStack socket = tile.getSocket(slot);
    if (socket.isEmpty() || !(itemstack.getItem() instanceof ISolderingIron)) {
        return;
    }
    // Not sufficient space in player's inventory. failed to stow.
    if (!InventoryUtil.stowInInventory(socket, player.inventory, false)) {
        return;
    }
    tile.setSocket(slot, ItemStack.EMPTY);
    InventoryUtil.stowInInventory(socket, player.inventory, true);
    itemstack.damageItem(1, player);
    player.updateHeldItem();
    PacketSocketUpdate packet = new PacketSocketUpdate(tile);
    NetworkUtil.sendToPlayer(packet, player);
}
Also used : ISolderingIron(forestry.core.circuits.ISolderingIron) PacketSocketUpdate(forestry.core.network.packets.PacketSocketUpdate) ItemStack(net.minecraft.item.ItemStack)

Aggregations

PacketSocketUpdate (forestry.core.network.packets.PacketSocketUpdate)2 ItemStack (net.minecraft.item.ItemStack)2 ICircuitBoard (forestry.api.circuits.ICircuitBoard)1 ISolderingIron (forestry.core.circuits.ISolderingIron)1