use of forestry.core.circuits.EnumCircuitBoardType in project ForestryMC by ForestryMC.
the class ItemInventorySolderingIron method getErrorStates.
@Override
public ImmutableSet<IErrorState> getErrorStates() {
ImmutableSet.Builder<IErrorState> errorStates = ImmutableSet.builder();
if (layouts.getCurrent() == CircuitRegistry.DUMMY_LAYOUT) {
errorStates.add(EnumErrorCode.NO_CIRCUIT_LAYOUT);
}
ItemStack blankCircuitBoard = getStackInSlot(inputCircuitBoardSlot);
if (blankCircuitBoard.isEmpty()) {
errorStates.add(EnumErrorCode.NO_CIRCUIT_BOARD);
} else {
EnumCircuitBoardType type = EnumCircuitBoardType.values()[blankCircuitBoard.getItemDamage()];
int circuitCount = 0;
for (short i = 0; i < type.getSockets(); i++) {
if (!getStackInSlot(ingredientSlot1 + i).isEmpty()) {
circuitCount++;
}
}
if (circuitCount != type.getSockets()) {
errorStates.add(EnumErrorCode.CIRCUIT_MISMATCH);
} else {
int count = getCircuitCount();
if (count != type.getSockets()) {
errorStates.add(EnumErrorCode.NO_CIRCUIT_LAYOUT);
}
}
}
return errorStates.build();
}
use of forestry.core.circuits.EnumCircuitBoardType in project ForestryMC by ForestryMC.
the class ItemInventorySolderingIron method onSlotClick.
@Override
public void onSlotClick(int slotIndex, EntityPlayer player) {
if (layouts.getCurrent() == CircuitRegistry.DUMMY_LAYOUT) {
return;
}
ItemStack inputCircuitBoard = getStackInSlot(inputCircuitBoardSlot);
if (inputCircuitBoard.isEmpty() || inputCircuitBoard.getCount() > 1) {
return;
}
if (!getStackInSlot(finishedCircuitBoardSlot).isEmpty()) {
return;
}
// Need a chipset item
if (!ChipsetManager.circuitRegistry.isChipset(inputCircuitBoard)) {
return;
}
// Illegal type
if (inputCircuitBoard.getItemDamage() < 0 || inputCircuitBoard.getItemDamage() >= EnumCircuitBoardType.values().length) {
return;
}
EnumCircuitBoardType type = EnumCircuitBoardType.values()[inputCircuitBoard.getItemDamage()];
if (getCircuitCount() != type.getSockets()) {
return;
}
ICircuit[] circuits = getCircuits(true);
ItemStack outputCircuitBoard = ItemCircuitBoard.createCircuitboard(type, layouts.getCurrent(), circuits);
setInventorySlotContents(finishedCircuitBoardSlot, outputCircuitBoard);
setInventorySlotContents(inputCircuitBoardSlot, ItemStack.EMPTY);
}
Aggregations