use of buildcraft.core.blueprints.BlueprintBase in project BuildCraft by BuildCraft.
the class TileBuilder method iterateBpt.
public void iterateBpt(boolean forceIterate) {
if (getStackInSlot(0) == null || !(getStackInSlot(0).getItem() instanceof ItemBlueprint)) {
if (box.isInitialized()) {
if (currentBuilder != null) {
currentBuilder = null;
}
if (box.isInitialized()) {
box.reset();
}
if (currentPathIterator != null) {
currentPathIterator = null;
}
scheduleRequirementUpdate();
sendNetworkUpdate();
return;
}
}
if (currentBuilder == null || (currentBuilder.isDone(this) || forceIterate)) {
if (path != null && path.size() > 1) {
if (currentPathIterator == null) {
Iterator<BlockPos> it = path.iterator();
BlockPos start = it.next();
EnumFacing face = worldObj.getBlockState(pos).getValue(BuildCraftProperties.BLOCK_FACING);
currentPathIterator = new PathIterator(start, it, face);
}
if (currentBuilder != null && currentBuilder.isDone(this)) {
currentBuilder.postProcessing(worldObj);
}
currentBuilder = currentPathIterator.next();
if (currentBuilder != null) {
box.reset();
box.initialize(currentBuilder);
sendNetworkUpdate();
}
if (currentBuilder == null) {
currentPathIterator = currentPathIterator.iterate();
}
if (currentPathIterator == null) {
done = true;
} else {
done = false;
}
scheduleRequirementUpdate();
} else {
if (currentBuilder != null && currentBuilder.isDone(this)) {
currentBuilder.postProcessing(worldObj);
currentBuilder = recursiveBuilder.nextBuilder();
scheduleRequirementUpdate();
} else {
BlueprintBase bpt = instanciateBlueprint();
if (bpt != null) {
EnumFacing face = worldObj.getBlockState(pos).getValue(BuildCraftProperties.BLOCK_FACING);
recursiveBuilder = new RecursiveBlueprintBuilder(bpt, worldObj, pos, face.getOpposite());
currentBuilder = recursiveBuilder.nextBuilder();
scheduleRequirementUpdate();
}
}
if (currentBuilder == null) {
done = true;
} else {
box.initialize(currentBuilder);
sendNetworkUpdate();
done = false;
}
}
}
if (done && getStackInSlot(0) != null) {
boolean dropBlueprint = true;
for (int i = 1; i < getSizeInventory(); ++i) {
if (getStackInSlot(i) == null) {
setInventorySlotContents(i, getStackInSlot(0));
dropBlueprint = false;
break;
}
}
if (dropBlueprint) {
InvUtils.dropItems(getWorld(), getStackInSlot(0), pos);
}
setInventorySlotContents(0, null);
box.reset();
sendNetworkUpdate();
}
}
use of buildcraft.core.blueprints.BlueprintBase in project BuildCraft by BuildCraft.
the class RecursiveBlueprintBuilder method nextBuilder.
public BptBuilderBase nextBuilder() {
if (!returnedThis) {
blueprint = blueprint.adjustToWorld(world, pos, dir);
returnedThis = true;
BptBuilderBase builder;
if (blueprint instanceof Blueprint) {
builder = new BptBuilderBlueprint((Blueprint) blueprint, world, pos);
} else if (blueprint instanceof Template) {
builder = new BptBuilderTemplate(blueprint, world, pos);
} else {
return null;
}
box.initialize(builder);
return builder;
}
// Free memory associated with this blueprint
blueprint = null;
if (current != null) {
BptBuilderBase builder = current.nextBuilder();
if (builder != null) {
return builder;
}
}
if (nextSubBlueprint >= subBlueprints.size()) {
return null;
}
NBTTagCompound nbt = subBlueprints.get(nextSubBlueprint);
BlueprintBase bpt = BlueprintBase.loadBluePrint(nbt.getCompoundTag("bpt"));
int nx = box.min().getX() + nbt.getInteger("x");
int ny = box.min().getY() + nbt.getInteger("y");
int nz = box.min().getZ() + nbt.getInteger("z");
EnumFacing nbtDir = EnumFacing.values()[nbt.getByte("dir")];
current = new RecursiveBlueprintBuilder(bpt, world, new BlockPos(nx, ny, nz), nbtDir);
nextSubBlueprint++;
return current.nextBuilder();
}
Aggregations