use of buildcraft.builders.TileArchitect in project BuildCraft by BuildCraft.
the class RecursiveBlueprintReader method iterate.
public void iterate() {
if (done) {
return;
} else if (currentSubReader == null && subIndex < architect.subBlueprints.size()) {
BlockPos subBlock = architect.subBlueprints.get(subIndex);
TileEntity subTile = architect.getWorld().getTileEntity(subBlock);
if (subTile instanceof TileArchitect) {
TileArchitect subArchitect = (TileArchitect) subTile;
currentSubReader = new RecursiveBlueprintReader(subArchitect, writingBlueprint);
} else if (subTile instanceof TileConstructionMarker || subTile instanceof TileBuilder) {
BlueprintBase blueprint = null;
EnumFacing orientation = EnumFacing.EAST;
if (subTile instanceof TileConstructionMarker) {
TileConstructionMarker marker = (TileConstructionMarker) subTile;
blueprint = ItemBlueprint.loadBlueprint(marker.itemBlueprint);
orientation = marker.direction;
} else if (subTile instanceof TileBuilder) {
TileBuilder builder = (TileBuilder) subTile;
blueprint = ItemBlueprint.loadBlueprint(builder.getStackInSlot(0));
orientation = architect.getWorld().getBlockState(subBlock).getValue(BuildCraftProperties.BLOCK_FACING).getOpposite();
}
if (blueprint != null) {
BlockPos nPos = subTile.getPos().subtract(architect.getBox().min());
writingBlueprint.addSubBlueprint(blueprint, nPos, orientation);
}
subIndex++;
} else {
subIndex++;
}
} else if (currentSubReader != null) {
currentSubReader.iterate();
World world = currentSubReader.architect.getWorld();
EnumFacing facing = world.getBlockState(currentSubReader.architect.getPos()).getValue(BuildCraftProperties.BLOCK_FACING).getOpposite();
BlockPos pos = currentSubReader.architect.getPos().subtract(architect.getBox().min());
if (currentSubReader.isDone()) {
writingBlueprint.addSubBlueprint(currentSubReader.getBlueprint(), pos, facing);
currentSubReader = null;
subIndex++;
}
} else if (blockScanner != null && blockScanner.blocksLeft() != 0) {
for (BlockPos index : blockScanner) {
writingBlueprint.readFromWorld(writingContext, architect, index);
}
computingTime = 1 - (float) blockScanner.blocksLeft() / (float) blockScanner.totalBlocks();
if (blockScanner.blocksLeft() == 0) {
writingBlueprint.readEntitiesFromWorld(writingContext, architect);
Vec3d transform = Utils.VEC_ZERO.subtract(Utils.convert(writingContext.surroundingBox().min()));
writingBlueprint.translateToBlueprint(transform);
EnumFacing o = architect.getWorld().getBlockState(architect.getPos()).getValue(BuildCraftProperties.BLOCK_FACING).getOpposite();
writingBlueprint.rotate = architect.readConfiguration.rotate;
writingBlueprint.excavate = architect.readConfiguration.excavate;
if (writingBlueprint.rotate) {
if (o == EnumFacing.EAST) {
// Do nothing
} else if (o == EnumFacing.SOUTH) {
writingBlueprint.rotateLeft(writingContext);
writingBlueprint.rotateLeft(writingContext);
writingBlueprint.rotateLeft(writingContext);
} else if (o == EnumFacing.WEST) {
writingBlueprint.rotateLeft(writingContext);
writingBlueprint.rotateLeft(writingContext);
} else if (o == EnumFacing.NORTH) {
writingBlueprint.rotateLeft(writingContext);
}
}
}
} else if (blockScanner != null) {
createBlueprint();
done = true;
}
}
Aggregations