Search in sources :

Example 1 with ISolderingIron

use of forestry.core.circuits.ISolderingIron in project ForestryMC by ForestryMC.

the class SocketWidget method handleMouseClick.

@Override
public void handleMouseClick(int mouseX, int mouseY, int mouseButton) {
    ItemStack itemstack = manager.minecraft.player.inventory.getItemStack();
    if (itemstack.isEmpty()) {
        return;
    }
    Item held = itemstack.getItem();
    Container container = manager.gui.inventorySlots;
    if (!(container instanceof IContainerSocketed)) {
        return;
    }
    IContainerSocketed containerSocketed = (IContainerSocketed) container;
    // Insert chipsets
    if (held instanceof ItemCircuitBoard) {
        containerSocketed.handleChipsetClick(slot);
    } else if (held instanceof ISolderingIron) {
        containerSocketed.handleSolderingIronClick(slot);
    }
}
Also used : Item(net.minecraft.item.Item) Container(net.minecraft.inventory.Container) ISolderingIron(forestry.core.circuits.ISolderingIron) ItemCircuitBoard(forestry.core.circuits.ItemCircuitBoard) ItemStack(net.minecraft.item.ItemStack) IContainerSocketed(forestry.core.gui.IContainerSocketed)

Example 2 with ISolderingIron

use of forestry.core.circuits.ISolderingIron 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

ISolderingIron (forestry.core.circuits.ISolderingIron)2 ItemStack (net.minecraft.item.ItemStack)2 ItemCircuitBoard (forestry.core.circuits.ItemCircuitBoard)1 IContainerSocketed (forestry.core.gui.IContainerSocketed)1 PacketSocketUpdate (forestry.core.network.packets.PacketSocketUpdate)1 Container (net.minecraft.inventory.Container)1 Item (net.minecraft.item.Item)1