try to fix #2584
This commit is contained in:
parent
3608844213
commit
60802f5045
3 changed files with 61 additions and 51 deletions
|
@ -30,8 +30,9 @@ import buildcraft.core.utils.BlockUtils;
|
||||||
|
|
||||||
public class BptBuilderTemplate extends BptBuilderBase {
|
public class BptBuilderTemplate extends BptBuilderBase {
|
||||||
|
|
||||||
|
private LinkedList<BuildingSlotBlock> clearList = new LinkedList<BuildingSlotBlock>();
|
||||||
private LinkedList<BuildingSlotBlock> buildList = 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) {
|
public BptBuilderTemplate(BlueprintBase bluePrint, World world, int x, int y, int z) {
|
||||||
super(bluePrint, world, x, y, z);
|
super(bluePrint, world, x, y, z);
|
||||||
|
@ -65,7 +66,7 @@ public class BptBuilderTemplate extends BptBuilderBase {
|
||||||
b.mode = Mode.ClearIfInvalid;
|
b.mode = Mode.ClearIfInvalid;
|
||||||
b.buildStage = 0;
|
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() {
|
private void checkDone() {
|
||||||
if (buildList.size() == 0) {
|
if (buildList.size() == 0 && clearList.size() == 0) {
|
||||||
done = true;
|
done = true;
|
||||||
} else {
|
} else {
|
||||||
done = false;
|
done = false;
|
||||||
|
@ -120,7 +122,7 @@ public class BptBuilderTemplate extends BptBuilderBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BuildingSlot getNextBlock(World world, TileAbstractBuilder inv) {
|
public BuildingSlot getNextBlock(World world, TileAbstractBuilder inv) {
|
||||||
if (buildList.size() != 0) {
|
if (buildList.size() != 0 || clearList.size() != 0) {
|
||||||
BuildingSlotBlock slot = internalGetNextBlock(world, inv);
|
BuildingSlotBlock slot = internalGetNextBlock(world, inv);
|
||||||
checkDone();
|
checkDone();
|
||||||
|
|
||||||
|
@ -152,55 +154,64 @@ public class BptBuilderTemplate extends BptBuilderBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator.startIteration();
|
// Step 1: Check the cleared
|
||||||
|
iteratorClear.startIteration();
|
||||||
|
while (iteratorClear.hasNext()) {
|
||||||
|
BuildingSlotBlock slot = iteratorClear.next();
|
||||||
|
|
||||||
while (iterator.hasNext()) {
|
if (slot.buildStage > clearList.getFirst().buildStage) {
|
||||||
BuildingSlotBlock slot = iterator.next();
|
iteratorClear.reset();
|
||||||
|
break;
|
||||||
if (slot.buildStage > buildList.getFirst().buildStage) {
|
|
||||||
iterator.reset ();
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BlockUtils.isUnbreakableBlock(world, slot.x, slot.y, slot.z)
|
if (BlockUtils.isUnbreakableBlock(world, slot.x, slot.y, slot.z)
|
||||||
|| isBlockBreakCanceled(world, slot.x, slot.y, slot.z)) {
|
|| isBlockBreakCanceled(world, slot.x, slot.y, slot.z)
|
||||||
iterator.remove();
|
|| BuildCraftAPI.isSoftBlock(world, slot.x, slot.y, slot.z)) {
|
||||||
if (slot.mode == Mode.ClearIfInvalid) {
|
iteratorClear.remove();
|
||||||
clearedLocations.add(new BlockIndex(slot.x, slot.y, slot.z));
|
clearedLocations.add(new BlockIndex(slot.x, slot.y, slot.z));
|
||||||
} else {
|
} else if (canDestroy(builder, context, slot)) {
|
||||||
builtLocations.add(new BlockIndex(slot.x, slot.y, slot.z));
|
consumeEnergyToDestroy(builder, slot);
|
||||||
}
|
createDestroyItems(slot);
|
||||||
} 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)) {
|
|
||||||
consumeEnergyToDestroy(builder, slot);
|
|
||||||
createDestroyItems(slot);
|
|
||||||
|
|
||||||
result = slot;
|
result = slot;
|
||||||
iterator.remove();
|
iteratorClear.remove();
|
||||||
clearedLocations.add(new BlockIndex(slot.x, slot.y, slot.z));
|
clearedLocations.add(new BlockIndex(slot.x, slot.y, slot.z));
|
||||||
|
|
||||||
break;
|
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();
|
|
||||||
builtLocations.add(new BlockIndex(slot.x, slot.y, slot.z));
|
|
||||||
} else {
|
|
||||||
if (builder.consumeEnergy(BuilderAPI.BUILD_ENERGY) && firstSlotToConsume != null) {
|
|
||||||
slot.addStackConsumed(firstSlotToConsume.decreaseStackInSlot(1));
|
|
||||||
result = slot;
|
|
||||||
iterator.remove();
|
|
||||||
builtLocations.add(new BlockIndex(slot.x, slot.y, slot.z));
|
|
||||||
|
|
||||||
break;
|
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)) {
|
||||||
|
slot.addStackConsumed(firstSlotToConsume.decreaseStackInSlot(1));
|
||||||
|
result = slot;
|
||||||
|
iteratorBuild.remove();
|
||||||
|
builtLocations.add(new BlockIndex(slot.x, slot.y, slot.z));
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -168,15 +168,14 @@ public class RenderEngine extends TileEntitySpecialRenderer implements IInventor
|
||||||
bindTexture(chamberTexture);
|
bindTexture(chamberTexture);
|
||||||
|
|
||||||
float chamberf = 2F / 16F;
|
float chamberf = 2F / 16F;
|
||||||
|
int chamberc = (((int) step + 2) / 2);
|
||||||
|
|
||||||
for (int i = 0; i <= step + 2; i += 2) {
|
for (int i = 0; i <= step + 2; i += 2) {
|
||||||
chamber.render(factor);
|
chamber.render(factor);
|
||||||
GL11.glTranslatef(translate[0] * chamberf, translate[1] * chamberf, translate[2] * chamberf);
|
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 * chamberc, -translate[1] * chamberf * chamberc, -translate[2] * chamberf * chamberc);
|
||||||
GL11.glTranslatef(-translate[0] * chamberf, -translate[1] * chamberf, -translate[2] * chamberf);
|
|
||||||
}
|
|
||||||
|
|
||||||
bindTexture(trunkTexture);
|
bindTexture(trunkTexture);
|
||||||
|
|
||||||
|
|
|
@ -157,7 +157,7 @@ public class BlockTank extends BlockBuildCraft {
|
||||||
if (current.stackSize != 1) {
|
if (current.stackSize != 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!world.isRemote) {
|
if (!world.isRemote) {
|
||||||
IFluidContainerItem container = (IFluidContainerItem) current.getItem();
|
IFluidContainerItem container = (IFluidContainerItem) current.getItem();
|
||||||
FluidStack liquid = container.getFluid(current);
|
FluidStack liquid = container.getFluid(current);
|
||||||
|
|
Loading…
Reference in a new issue