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