Search in sources :

Example 1 with ICircuitBoard

use of forestry.api.circuits.ICircuitBoard in project ForestryMC by ForestryMC.

the class TileEngineElectric method setSocket.

@Override
public void setSocket(int slot, ItemStack stack) {
    if (!stack.isEmpty() && !ChipsetManager.circuitRegistry.isChipset(stack)) {
        return;
    }
    // Dispose correctly of old chipsets
    if (!sockets.getStackInSlot(slot).isEmpty()) {
        if (ChipsetManager.circuitRegistry.isChipset(sockets.getStackInSlot(slot))) {
            ICircuitBoard chipset = ChipsetManager.circuitRegistry.getCircuitBoard(sockets.getStackInSlot(slot));
            if (chipset != null) {
                chipset.onRemoval(this);
            }
        }
    }
    sockets.setInventorySlotContents(slot, stack);
    if (stack.isEmpty()) {
        return;
    }
    ICircuitBoard chipset = ChipsetManager.circuitRegistry.getCircuitBoard(stack);
    if (chipset != null) {
        chipset.onInsertion(this);
    }
}
Also used : ICircuitBoard(forestry.api.circuits.ICircuitBoard)

Example 2 with ICircuitBoard

use of forestry.api.circuits.ICircuitBoard in project ForestryMC by ForestryMC.

the class TileEngineElectric method readFromNBT.

// / SAVING / LOADING
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
    super.readFromNBT(nbttagcompound);
    if (ic2EnergySink != null) {
        ic2EnergySink.readFromNBT(nbttagcompound);
    }
    sockets.readFromNBT(nbttagcompound);
    ItemStack chip = sockets.getStackInSlot(0);
    if (chip != null) {
        ICircuitBoard chipset = ChipsetManager.circuitRegistry.getCircuitBoard(chip);
        if (chipset != null) {
            chipset.onLoad(this);
        }
    }
}
Also used : ICircuitBoard(forestry.api.circuits.ICircuitBoard) ItemStack(net.minecraft.item.ItemStack)

Example 3 with ICircuitBoard

use of forestry.api.circuits.ICircuitBoard in project ForestryMC by ForestryMC.

the class TileClimatiser method setSocket.

@Override
public void setSocket(int slot, ItemStack stack) {
    if (!stack.isEmpty() && !ChipsetManager.circuitRegistry.isChipset(stack)) {
        return;
    }
    // Dispose correctly of old chipsets
    if (!sockets.getStackInSlot(slot).isEmpty()) {
        if (ChipsetManager.circuitRegistry.isChipset(sockets.getStackInSlot(slot))) {
            ICircuitBoard chipset = ChipsetManager.circuitRegistry.getCircuitBoard(sockets.getStackInSlot(slot));
            if (chipset != null) {
                chipset.onRemoval(this);
            }
        }
    }
    sockets.setInventorySlotContents(slot, stack);
    if (stack.isEmpty()) {
        return;
    }
    ICircuitBoard chipset = ChipsetManager.circuitRegistry.getCircuitBoard(stack);
    if (chipset != null) {
        chipset.onInsertion(this);
    }
}
Also used : ICircuitBoard(forestry.api.circuits.ICircuitBoard)

Example 4 with ICircuitBoard

use of forestry.api.circuits.ICircuitBoard in project ForestryMC by ForestryMC.

the class FarmController method setSocket.

@Override
public void setSocket(int slot, ItemStack stack) {
    if (ChipsetManager.circuitRegistry.isChipset(stack)) {
        // Dispose old chipsets correctly
        if (!sockets.getStackInSlot(slot).isEmpty()) {
            if (ChipsetManager.circuitRegistry.isChipset(sockets.getStackInSlot(slot))) {
                ICircuitBoard chipset = ChipsetManager.circuitRegistry.getCircuitBoard(sockets.getStackInSlot(slot));
                if (chipset != null) {
                    chipset.onRemoval(this);
                }
            }
        }
        sockets.setInventorySlotContents(slot, stack);
        refreshFarmLogics();
        if (!stack.isEmpty()) {
            ICircuitBoard chipset = ChipsetManager.circuitRegistry.getCircuitBoard(stack);
            if (chipset != null) {
                chipset.onInsertion(this);
            }
        }
    }
}
Also used : ICircuitBoard(forestry.api.circuits.ICircuitBoard)

Example 5 with ICircuitBoard

use of forestry.api.circuits.ICircuitBoard 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)

Aggregations

ICircuitBoard (forestry.api.circuits.ICircuitBoard)11 ItemStack (net.minecraft.item.ItemStack)5 StimulatorCircuit (binnie.extrabees.circuit.StimulatorCircuit)1 ICircuit (forestry.api.circuits.ICircuit)1 PacketSocketUpdate (forestry.core.network.packets.PacketSocketUpdate)1 ArrayList (java.util.ArrayList)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 NBTTagList (net.minecraft.nbt.NBTTagList)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1