Search in sources :

Example 1 with EnumCircuitBoardType

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();
}
Also used : EnumCircuitBoardType(forestry.core.circuits.EnumCircuitBoardType) ImmutableSet(com.google.common.collect.ImmutableSet) IErrorState(forestry.api.core.IErrorState) ItemStack(net.minecraft.item.ItemStack)

Example 2 with EnumCircuitBoardType

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);
}
Also used : EnumCircuitBoardType(forestry.core.circuits.EnumCircuitBoardType) ICircuit(forestry.api.circuits.ICircuit) ItemStack(net.minecraft.item.ItemStack)

Aggregations

EnumCircuitBoardType (forestry.core.circuits.EnumCircuitBoardType)2 ItemStack (net.minecraft.item.ItemStack)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 ICircuit (forestry.api.circuits.ICircuit)1 IErrorState (forestry.api.core.IErrorState)1