This commit is contained in:
asiekierka 2015-03-25 15:35:19 +01:00
parent 3608844213
commit 60802f5045
3 changed files with 61 additions and 51 deletions

View file

@ -30,8 +30,9 @@ import buildcraft.core.utils.BlockUtils;
public class BptBuilderTemplate extends BptBuilderBase {
private LinkedList<BuildingSlotBlock> clearList = new LinkedList<BuildingSlotBlock>();
private LinkedList<BuildingSlotBlock> buildList = new LinkedList<BuildingSlotBlock>();
private BuildingSlotIterator iterator;
private BuildingSlotIterator iteratorBuild, iteratorClear;
public BptBuilderTemplate(BlueprintBase bluePrint, World world, int x, int y, int z) {
super(bluePrint, world, x, y, z);
@ -65,7 +66,7 @@ public class BptBuilderTemplate extends BptBuilderBase {
b.mode = Mode.ClearIfInvalid;
b.buildStage = 0;
buildList.add(b);
clearList.add(b);
}
}
}
@ -102,11 +103,12 @@ public class BptBuilderTemplate extends BptBuilderBase {
}
}
iterator = new BuildingSlotIterator(buildList);
iteratorBuild = new BuildingSlotIterator(buildList);
iteratorClear = new BuildingSlotIterator(clearList);
}
private void checkDone() {
if (buildList.size() == 0) {
if (buildList.size() == 0 && clearList.size() == 0) {
done = true;
} else {
done = false;
@ -120,7 +122,7 @@ public class BptBuilderTemplate extends BptBuilderBase {
@Override
public BuildingSlot getNextBlock(World world, TileAbstractBuilder inv) {
if (buildList.size() != 0) {
if (buildList.size() != 0 || clearList.size() != 0) {
BuildingSlotBlock slot = internalGetNextBlock(world, inv);
checkDone();
@ -152,57 +154,66 @@ public class BptBuilderTemplate extends BptBuilderBase {
}
}
iterator.startIteration();
// Step 1: Check the cleared
iteratorClear.startIteration();
while (iteratorClear.hasNext()) {
BuildingSlotBlock slot = iteratorClear.next();
while (iterator.hasNext()) {
BuildingSlotBlock slot = iterator.next();
if (slot.buildStage > buildList.getFirst().buildStage) {
iterator.reset ();
return null;
if (slot.buildStage > clearList.getFirst().buildStage) {
iteratorClear.reset();
break;
}
if (BlockUtils.isUnbreakableBlock(world, slot.x, slot.y, slot.z)
|| isBlockBreakCanceled(world, slot.x, slot.y, slot.z)) {
iterator.remove();
if (slot.mode == Mode.ClearIfInvalid) {
|| isBlockBreakCanceled(world, slot.x, slot.y, slot.z)
|| BuildCraftAPI.isSoftBlock(world, slot.x, slot.y, slot.z)) {
iteratorClear.remove();
clearedLocations.add(new BlockIndex(slot.x, slot.y, slot.z));
} else {
builtLocations.add(new BlockIndex(slot.x, slot.y, slot.z));
}
} else if (slot.mode == Mode.ClearIfInvalid) {
if (BuildCraftAPI.isSoftBlock(world, slot.x, slot.y, slot.z)) {
iterator.remove();
clearedLocations.add(new BlockIndex(slot.x, slot.y, slot.z));
} else {
if (canDestroy(builder, context, slot)) {
} else if (canDestroy(builder, context, slot)) {
consumeEnergyToDestroy(builder, slot);
createDestroyItems(slot);
result = slot;
iterator.remove();
iteratorClear.remove();
clearedLocations.add(new BlockIndex(slot.x, slot.y, slot.z));
break;
}
}
} else if (slot.mode == Mode.Build) {
if (!BuildCraftAPI.isSoftBlock(world, slot.x, slot.y, slot.z)
|| isBlockPlaceCanceled(world, x, y, z, slot.schematic)) {
iterator.remove();
if (result != null) {
return result;
}
// Step 2: Check the built, but only if we have anything to place and enough energy
if (firstSlotToConsume == null || builder.getBattery().getEnergyStored() < BuilderAPI.BUILD_ENERGY) {
return null;
}
iteratorBuild.startIteration();
while (iteratorBuild.hasNext()) {
BuildingSlotBlock slot = iteratorBuild.next();
if (slot.buildStage > buildList.getFirst().buildStage) {
iteratorBuild.reset();
break;
}
if (BlockUtils.isUnbreakableBlock(world, slot.x, slot.y, slot.z)
|| isBlockPlaceCanceled(world, x, y, z, slot.schematic)
|| !BuildCraftAPI.isSoftBlock(world, slot.x, slot.y, slot.z)) {
iteratorBuild.remove();
builtLocations.add(new BlockIndex(slot.x, slot.y, slot.z));
} else {
if (builder.consumeEnergy(BuilderAPI.BUILD_ENERGY) && firstSlotToConsume != null) {
} else if (builder.consumeEnergy(BuilderAPI.BUILD_ENERGY)) {
slot.addStackConsumed(firstSlotToConsume.decreaseStackInSlot(1));
result = slot;
iterator.remove();
iteratorBuild.remove();
builtLocations.add(new BlockIndex(slot.x, slot.y, slot.z));
break;
}
}
}
}
return result;
}

View file

@ -168,15 +168,14 @@ public class RenderEngine extends TileEntitySpecialRenderer implements IInventor
bindTexture(chamberTexture);
float chamberf = 2F / 16F;
int chamberc = (((int) step + 2) / 2);
for (int i = 0; i <= step + 2; i += 2) {
chamber.render(factor);
GL11.glTranslatef(translate[0] * chamberf, translate[1] * chamberf, translate[2] * chamberf);
}
for (int i = 0; i <= step + 2; i += 2) {
GL11.glTranslatef(-translate[0] * chamberf, -translate[1] * chamberf, -translate[2] * chamberf);
}
GL11.glTranslatef(-translate[0] * chamberf * chamberc, -translate[1] * chamberf * chamberc, -translate[2] * chamberf * chamberc);
bindTexture(trunkTexture);