Search in sources :

Example 1 with NodeTileEntity

use of mcjty.rftoolscontrol.blocks.node.NodeTileEntity in project RFToolsControl by McJty.

the class ProcessorTileEntity method reset.

public void reset() {
    waitingForItems.clear();
    eventQueue.clear();
    stopPrograms();
    for (EnumFacing facing : EnumFacing.values()) {
        powerOut[facing.ordinal()] = 0;
    }
    for (BlockPos np : networkNodes.values()) {
        TileEntity te = getWorld().getTileEntity(np);
        if (te instanceof NodeTileEntity) {
            NodeTileEntity tileEntity = (NodeTileEntity) te;
            for (EnumFacing facing : EnumFacing.values()) {
                tileEntity.setPowerOut(facing, 0);
            }
        }
    }
    gfxOps.clear();
    orderedOps.clear();
    for (CpuCore core : cpuCores) {
        core.setDebug(false);
    }
    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) CpuCore(mcjty.rftoolscontrol.logic.running.CpuCore) EnumFacing(net.minecraft.util.EnumFacing) NodeTileEntity(mcjty.rftoolscontrol.blocks.node.NodeTileEntity) BlockPos(net.minecraft.util.math.BlockPos)

Example 2 with NodeTileEntity

use of mcjty.rftoolscontrol.blocks.node.NodeTileEntity 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 NodeTileEntity

use of mcjty.rftoolscontrol.blocks.node.NodeTileEntity in project RFToolsControl by McJty.

the class ProcessorTileEntity method getAdjacentPosition.

private BlockPos getAdjacentPosition(@Nonnull BlockSide side) {
    BlockPos p;
    if (side.getNodeName() != null && !side.getNodeName().isEmpty()) {
        p = networkNodes.get(side.getNodeName());
        if (p == null) {
            throw new ProgException(EXCEPT_MISSINGNODE);
        }
        TileEntity te = getWorld().getTileEntity(p);
        if (!(te instanceof NodeTileEntity)) {
            throw new ProgException(EXCEPT_MISSINGNODE);
        }
    } else {
        p = pos;
    }
    return p;
}
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) NodeTileEntity(mcjty.rftoolscontrol.blocks.node.NodeTileEntity) BlockPos(net.minecraft.util.math.BlockPos)

Example 4 with NodeTileEntity

use of mcjty.rftoolscontrol.blocks.node.NodeTileEntity in project RFToolsControl by McJty.

the class ProcessorTileEntity method setPowerOut.

@Override
public void setPowerOut(@Nonnull BlockSide side, int level) {
    EnumFacing facing = side.getSide();
    BlockPos p = getAdjacentPosition(side);
    if (p == null) {
        return;
    }
    if (level < 0) {
        level = 0;
    } else if (level > 15) {
        level = 15;
    }
    if (p.equals(pos)) {
        powerOut[facing.ordinal()] = level;
        markDirty();
        getWorld().neighborChanged(this.pos.offset(facing), this.getBlockType(), this.pos);
    } else {
        NodeTileEntity te = (NodeTileEntity) getWorld().getTileEntity(p);
        te.setPowerOut(facing, level);
    }
}
Also used : EnumFacing(net.minecraft.util.EnumFacing) NodeTileEntity(mcjty.rftoolscontrol.blocks.node.NodeTileEntity) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

NodeTileEntity (mcjty.rftoolscontrol.blocks.node.NodeTileEntity)4 BlockPos (net.minecraft.util.math.BlockPos)4 GenericEnergyReceiverTileEntity (mcjty.lib.entity.GenericEnergyReceiverTileEntity)3 CraftingStationTileEntity (mcjty.rftoolscontrol.blocks.craftingstation.CraftingStationTileEntity)3 MultiTankTileEntity (mcjty.rftoolscontrol.blocks.multitank.MultiTankTileEntity)3 WorkbenchTileEntity (mcjty.rftoolscontrol.blocks.workbench.WorkbenchTileEntity)3 TileEntity (net.minecraft.tileentity.TileEntity)3 EnumFacing (net.minecraft.util.EnumFacing)2 CpuCore (mcjty.rftoolscontrol.logic.running.CpuCore)1 ProgException (mcjty.rftoolscontrol.logic.running.ProgException)1