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);
}
}
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);
}
}
}
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);
}
}
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);
}
}
}
}
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);
}
Aggregations