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