Search in sources :

Example 1 with CraftingStationTileEntity

use of mcjty.rftoolscontrol.blocks.craftingstation.CraftingStationTileEntity in project RFToolsControl by McJty.

the class ProcessorTileEntity method craftFail.

public void craftFail(IProgram program) {
    if (!program.hasCraftTicket()) {
        throw new ProgException(EXCEPT_MISSINGCRAFTTICKET);
    }
    String ticket = program.getCraftTicket();
    for (BlockPos p : craftingStations) {
        TileEntity te = getWorld().getTileEntity(p);
        if (te instanceof CraftingStationTileEntity) {
            CraftingStationTileEntity craftingStation = (CraftingStationTileEntity) te;
            craftingStation.craftFail(ticket);
        }
    }
}
Also used : ProgException(mcjty.rftoolscontrol.logic.running.ProgException) GenericEnergyReceiverTileEntity(mcjty.lib.entity.GenericEnergyReceiverTileEntity) CraftingStationTileEntity(mcjty.rftoolscontrol.blocks.craftingstation.CraftingStationTileEntity) WorkbenchTileEntity(mcjty.rftoolscontrol.blocks.workbench.WorkbenchTileEntity) NodeTileEntity(mcjty.rftoolscontrol.blocks.node.NodeTileEntity) MultiTankTileEntity(mcjty.rftoolscontrol.blocks.multitank.MultiTankTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) CraftingStationTileEntity(mcjty.rftoolscontrol.blocks.craftingstation.CraftingStationTileEntity) BlockPos(net.minecraft.util.math.BlockPos) NBTTagString(net.minecraft.nbt.NBTTagString)

Example 2 with CraftingStationTileEntity

use of mcjty.rftoolscontrol.blocks.craftingstation.CraftingStationTileEntity in project RFToolsControl by McJty.

the class ProcessorTileEntity method scanNodes.

public void scanNodes() {
    if (!hasNetworkCard()) {
        log(TextFormatting.RED + "No network card!");
        return;
    }
    if (channel == null || channel.isEmpty()) {
        log(TextFormatting.RED + "Setup a channel first!");
        return;
    }
    networkNodes.clear();
    craftingStations.clear();
    int range = hasNetworkCard == NetworkCardItem.TIER_NORMAL ? 8 : 16;
    for (int x = -range; x <= range; x++) {
        for (int y = -range; y <= range; y++) {
            for (int z = -range; z <= range; z++) {
                BlockPos n = new BlockPos(pos.getX() + x, pos.getY() + y, pos.getZ() + z);
                TileEntity te = getWorld().getTileEntity(n);
                if (te instanceof NodeTileEntity) {
                    NodeTileEntity node = (NodeTileEntity) te;
                    if (channel.equals(node.getChannelName())) {
                        if (node.getNodeName() == null || node.getNodeName().isEmpty()) {
                            log("Node is missing a name!");
                        } else {
                            networkNodes.put(node.getNodeName(), n);
                            node.setProcessor(getPos());
                        }
                    }
                } else if (te instanceof CraftingStationTileEntity) {
                    CraftingStationTileEntity craftingStation = (CraftingStationTileEntity) te;
                    craftingStation.registerProcessor(pos);
                    craftingStations.add(n);
                }
            }
        }
    }
    log("Found " + networkNodes.size() + " node(s)");
    log("Found " + craftingStations.size() + " crafting station(s)");
    markDirty();
}
Also used : GenericEnergyReceiverTileEntity(mcjty.lib.entity.GenericEnergyReceiverTileEntity) CraftingStationTileEntity(mcjty.rftoolscontrol.blocks.craftingstation.CraftingStationTileEntity) WorkbenchTileEntity(mcjty.rftoolscontrol.blocks.workbench.WorkbenchTileEntity) NodeTileEntity(mcjty.rftoolscontrol.blocks.node.NodeTileEntity) MultiTankTileEntity(mcjty.rftoolscontrol.blocks.multitank.MultiTankTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) NodeTileEntity(mcjty.rftoolscontrol.blocks.node.NodeTileEntity) CraftingStationTileEntity(mcjty.rftoolscontrol.blocks.craftingstation.CraftingStationTileEntity) BlockPos(net.minecraft.util.math.BlockPos)

Example 3 with CraftingStationTileEntity

use of mcjty.rftoolscontrol.blocks.craftingstation.CraftingStationTileEntity in project RFToolsControl by McJty.

the class ProcessorTileEntity method craftOk.

public void craftOk(IProgram program, @Nullable Integer slot) {
    if (!program.hasCraftTicket()) {
        throw new ProgException(EXCEPT_MISSINGCRAFTTICKET);
    }
    String ticket = program.getCraftTicket();
    CardInfo info = this.cardInfo[((RunningProgram) program).getCardIndex()];
    Integer realSlot = info.getRealSlot(slot);
    ItemStack craftedItem = ItemStack.EMPTY;
    if (realSlot != null) {
        craftedItem = getItemHandler().getStackInSlot(realSlot);
    }
    for (BlockPos p : craftingStations) {
        TileEntity te = getWorld().getTileEntity(p);
        if (te instanceof CraftingStationTileEntity) {
            CraftingStationTileEntity craftingStation = (CraftingStationTileEntity) te;
            craftedItem = craftingStation.craftOk(this, ticket, craftedItem);
        }
    }
    if (realSlot != null) {
        // Put back what could not be accepted
        getInventoryHelper().setStackInSlot(realSlot, craftedItem);
    }
}
Also used : ProgException(mcjty.rftoolscontrol.logic.running.ProgException) GenericEnergyReceiverTileEntity(mcjty.lib.entity.GenericEnergyReceiverTileEntity) CraftingStationTileEntity(mcjty.rftoolscontrol.blocks.craftingstation.CraftingStationTileEntity) WorkbenchTileEntity(mcjty.rftoolscontrol.blocks.workbench.WorkbenchTileEntity) NodeTileEntity(mcjty.rftoolscontrol.blocks.node.NodeTileEntity) MultiTankTileEntity(mcjty.rftoolscontrol.blocks.multitank.MultiTankTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) CraftingStationTileEntity(mcjty.rftoolscontrol.blocks.craftingstation.CraftingStationTileEntity) BlockPos(net.minecraft.util.math.BlockPos) NBTTagString(net.minecraft.nbt.NBTTagString) ItemStack(net.minecraft.item.ItemStack)

Example 4 with CraftingStationTileEntity

use of mcjty.rftoolscontrol.blocks.craftingstation.CraftingStationTileEntity in project RFToolsControl by McJty.

the class ProcessorTileEntity method getCraftResult.

@Override
public ItemStack getCraftResult(IProgram program) {
    if (!program.hasCraftTicket()) {
        // @todo ? exception?
        return ItemStack.EMPTY;
    }
    for (BlockPos p : craftingStations) {
        TileEntity te = getWorld().getTileEntity(p);
        if (te instanceof CraftingStationTileEntity) {
            CraftingStationTileEntity craftingStation = (CraftingStationTileEntity) te;
            ItemStack stack = craftingStation.getCraftResult(program.getCraftTicket());
            if (!stack.isEmpty()) {
                return stack;
            }
        }
    }
    return ItemStack.EMPTY;
}
Also used : GenericEnergyReceiverTileEntity(mcjty.lib.entity.GenericEnergyReceiverTileEntity) CraftingStationTileEntity(mcjty.rftoolscontrol.blocks.craftingstation.CraftingStationTileEntity) WorkbenchTileEntity(mcjty.rftoolscontrol.blocks.workbench.WorkbenchTileEntity) NodeTileEntity(mcjty.rftoolscontrol.blocks.node.NodeTileEntity) MultiTankTileEntity(mcjty.rftoolscontrol.blocks.multitank.MultiTankTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) CraftingStationTileEntity(mcjty.rftoolscontrol.blocks.craftingstation.CraftingStationTileEntity) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack)

Aggregations

GenericEnergyReceiverTileEntity (mcjty.lib.entity.GenericEnergyReceiverTileEntity)4 CraftingStationTileEntity (mcjty.rftoolscontrol.blocks.craftingstation.CraftingStationTileEntity)4 MultiTankTileEntity (mcjty.rftoolscontrol.blocks.multitank.MultiTankTileEntity)4 NodeTileEntity (mcjty.rftoolscontrol.blocks.node.NodeTileEntity)4 WorkbenchTileEntity (mcjty.rftoolscontrol.blocks.workbench.WorkbenchTileEntity)4 TileEntity (net.minecraft.tileentity.TileEntity)4 BlockPos (net.minecraft.util.math.BlockPos)4 ProgException (mcjty.rftoolscontrol.logic.running.ProgException)2 ItemStack (net.minecraft.item.ItemStack)2 NBTTagString (net.minecraft.nbt.NBTTagString)2