attempt at fixing blueprint building ordering, for #1620
This commit is contained in:
parent
ee349e00b5
commit
b30995aea0
5 changed files with 36 additions and 14 deletions
common/buildcraft
api/blueprints
core/blueprints
|
@ -213,12 +213,6 @@ public class SchematicBlock extends SchematicBlockBase implements Comparable<Sc
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(SchematicBlock o) {
|
public int compareTo(SchematicBlock o) {
|
||||||
if (block.isOpaqueCube() == o.block.isOpaqueCube()) {
|
return 0;
|
||||||
return 0;
|
|
||||||
} else if (block.isOpaqueCube()) {
|
|
||||||
return -1;
|
|
||||||
} else {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,6 +78,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
|
||||||
b.y = yCoord;
|
b.y = yCoord;
|
||||||
b.z = zCoord;
|
b.z = zCoord;
|
||||||
b.mode = Mode.ClearIfInvalid;
|
b.mode = Mode.ClearIfInvalid;
|
||||||
|
b.buildStage = 0;
|
||||||
|
|
||||||
buildList.add(b);
|
buildList.add(b);
|
||||||
}
|
}
|
||||||
|
@ -86,7 +87,8 @@ public class BptBuilderBlueprint extends BptBuilderBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LinkedList<BuildingSlotBlock> tmpBuildList = new LinkedList<BuildingSlotBlock>();
|
LinkedList<BuildingSlotBlock> tmpBuildCubeList = new LinkedList<BuildingSlotBlock>();
|
||||||
|
LinkedList<BuildingSlotBlock> tmpBuildComplexList = new LinkedList<BuildingSlotBlock>();
|
||||||
|
|
||||||
for (int j = 0; j < blueprint.sizeY; ++j) {
|
for (int j = 0; j < blueprint.sizeY; ++j) {
|
||||||
for (int i = 0; i < blueprint.sizeX; ++i) {
|
for (int i = 0; i < blueprint.sizeX; ++i) {
|
||||||
|
@ -110,7 +112,14 @@ public class BptBuilderBlueprint extends BptBuilderBase {
|
||||||
|
|
||||||
if (!builtLocations.contains(new BlockIndex(xCoord, yCoord,
|
if (!builtLocations.contains(new BlockIndex(xCoord, yCoord,
|
||||||
zCoord))) {
|
zCoord))) {
|
||||||
tmpBuildList.add(b);
|
|
||||||
|
if (((SchematicBlock) b.schematic).block.isOpaqueCube()) {
|
||||||
|
tmpBuildCubeList.add(b);
|
||||||
|
b.buildStage = 1;
|
||||||
|
} else {
|
||||||
|
tmpBuildComplexList.add(b);
|
||||||
|
b.buildStage = 2;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
postProcessing.add(b);
|
postProcessing.add(b);
|
||||||
}
|
}
|
||||||
|
@ -118,9 +127,11 @@ public class BptBuilderBlueprint extends BptBuilderBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Collections.sort(tmpBuildList);
|
Collections.sort(tmpBuildCubeList);
|
||||||
|
Collections.sort(tmpBuildComplexList);
|
||||||
|
|
||||||
buildList.addAll(tmpBuildList);
|
buildList.addAll(tmpBuildCubeList);
|
||||||
|
buildList.addAll(tmpBuildComplexList);
|
||||||
|
|
||||||
iterator = new BuildingSlotIterator(buildList);
|
iterator = new BuildingSlotIterator(buildList);
|
||||||
|
|
||||||
|
@ -189,6 +200,11 @@ public class BptBuilderBlueprint extends BptBuilderBase {
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
BuildingSlotBlock slot = iterator.next();
|
BuildingSlotBlock slot = iterator.next();
|
||||||
|
|
||||||
|
if (slot.buildStage > buildList.getFirst().buildStage) {
|
||||||
|
iterator.reset ();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
boolean getNext = false;
|
boolean getNext = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -52,6 +52,7 @@ public class BptBuilderTemplate extends BptBuilderBase {
|
||||||
b.y = yCoord;
|
b.y = yCoord;
|
||||||
b.z = zCoord;
|
b.z = zCoord;
|
||||||
b.mode = Mode.ClearIfInvalid;
|
b.mode = Mode.ClearIfInvalid;
|
||||||
|
b.buildStage = 0;
|
||||||
|
|
||||||
buildList.add(b);
|
buildList.add(b);
|
||||||
}
|
}
|
||||||
|
@ -78,6 +79,7 @@ public class BptBuilderTemplate extends BptBuilderBase {
|
||||||
b.z = zCoord;
|
b.z = zCoord;
|
||||||
|
|
||||||
b.mode = Mode.Build;
|
b.mode = Mode.Build;
|
||||||
|
b.buildStage = 1;
|
||||||
|
|
||||||
buildList.add(b);
|
buildList.add(b);
|
||||||
}
|
}
|
||||||
|
@ -135,9 +137,12 @@ public class BptBuilderTemplate extends BptBuilderBase {
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
BuildingSlotBlock slot = iterator.next();
|
BuildingSlotBlock slot = iterator.next();
|
||||||
|
|
||||||
if (slot == null) {
|
if (slot.buildStage > buildList.getFirst().buildStage) {
|
||||||
break;
|
iterator.reset ();
|
||||||
} else if (slot.mode == Mode.ClearIfInvalid) {
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (slot.mode == Mode.ClearIfInvalid) {
|
||||||
if (BlockUtil.isSoftBlock(world, slot.x, slot.y, slot.z)
|
if (BlockUtil.isSoftBlock(world, slot.x, slot.y, slot.z)
|
||||||
|| BlockUtil.isUnbreakableBlock(world, slot.x, slot.y, slot.z)) {
|
|| BlockUtil.isUnbreakableBlock(world, slot.x, slot.y, slot.z)) {
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
|
|
|
@ -31,6 +31,8 @@ public class BuildingSlotBlock extends BuildingSlot implements Comparable<Buildi
|
||||||
|
|
||||||
public Mode mode = Mode.Build;
|
public Mode mode = Mode.Build;
|
||||||
|
|
||||||
|
public int buildStage = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SchematicBlockBase getSchematic () {
|
public SchematicBlockBase getSchematic () {
|
||||||
if (schematic == null) {
|
if (schematic == null) {
|
||||||
|
|
|
@ -59,4 +59,9 @@ public class BuildingSlotIterator {
|
||||||
current.remove();
|
current.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void reset () {
|
||||||
|
current = buildList.iterator();
|
||||||
|
nbIterations = 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue