use of buildcraft.builders.TileConstructionMarker 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;
}
}
use of buildcraft.builders.TileConstructionMarker in project BuildCraft by BuildCraft.
the class BoardRobotBuilder method findClosestMarker.
private TileConstructionMarker findClosestMarker() {
double minDistance = Double.MAX_VALUE;
TileConstructionMarker minMarker = null;
IZone zone = robot.getZoneToWork();
for (TileConstructionMarker marker : TileConstructionMarker.currentMarkers) {
if (marker.getWorld() != robot.worldObj) {
continue;
}
if (!marker.needsToBuild()) {
continue;
}
if (zone != null && !zone.contains(Utils.convert(marker.getPos()))) {
continue;
}
double dx = robot.posX - marker.getPos().getX();
double dy = robot.posY - marker.getPos().getY();
double dz = robot.posZ - marker.getPos().getZ();
double distance = dx * dx + dy * dy + dz * dz;
if (distance < minDistance) {
minMarker = marker;
minDistance = distance;
}
}
if (minMarker != null && minDistance < MAX_RANGE_SQ) {
return minMarker;
} else {
return null;
}
}
Aggregations