minor reformat in block index and fix path builder loading, close #1655
This commit is contained in:
parent
1ba976baff
commit
931f22d5be
2 changed files with 33 additions and 24 deletions
|
@ -196,7 +196,22 @@ public class TileBuilder extends TileAbstractBuilder implements IMachine {
|
|||
|
||||
|
||||
if (initNBT != null) {
|
||||
iterateBpt();
|
||||
iterateBpt(true);
|
||||
|
||||
if (initNBT.hasKey("iterator")) {
|
||||
BlockIndex expectedTo = new BlockIndex(initNBT.getCompoundTag("iterator"));
|
||||
|
||||
while (!done && bluePrintBuilder != null && currentPathIterator != null) {
|
||||
BlockIndex bi = new BlockIndex((int) currentPathIterator.ix,
|
||||
(int) currentPathIterator.iy, (int) currentPathIterator.iz);
|
||||
|
||||
if (bi.equals(expectedTo)) {
|
||||
break;
|
||||
}
|
||||
|
||||
iterateBpt(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (bluePrintBuilder != null) {
|
||||
NBTTagCompound builderCpt = new NBTTagCompound();
|
||||
|
@ -204,13 +219,6 @@ public class TileBuilder extends TileAbstractBuilder implements IMachine {
|
|||
initNBT.getCompoundTag("builderState"), this);
|
||||
}
|
||||
|
||||
/*
|
||||
* if (currentPathIterator != null) { NBTTagCompound iteratorNBT =
|
||||
* new NBTTagCompound();
|
||||
* currentPathIterator.to.writeTo(iteratorNBT);
|
||||
* nbttagcompound.setTag ("iterator", iteratorNBT); }
|
||||
*/
|
||||
|
||||
initNBT = null;
|
||||
}
|
||||
|
||||
|
@ -244,7 +252,7 @@ public class TileBuilder extends TileAbstractBuilder implements IMachine {
|
|||
sendNetworkUpdate();
|
||||
}
|
||||
|
||||
iterateBpt();
|
||||
iterateBpt(false);
|
||||
}
|
||||
|
||||
public void createLasersForPath() {
|
||||
|
@ -313,7 +321,7 @@ public class TileBuilder extends TileAbstractBuilder implements IMachine {
|
|||
}
|
||||
}
|
||||
|
||||
public void iterateBpt() {
|
||||
public void iterateBpt(boolean forceIterate) {
|
||||
if (items[0] == null || !(items[0].getItem() instanceof ItemBlueprint)) {
|
||||
if (bluePrintBuilder != null) {
|
||||
bluePrintBuilder = null;
|
||||
|
@ -332,7 +340,7 @@ public class TileBuilder extends TileAbstractBuilder implements IMachine {
|
|||
return;
|
||||
}
|
||||
|
||||
if (bluePrintBuilder == null || bluePrintBuilder.isDone(this)) {
|
||||
if (bluePrintBuilder == null || (bluePrintBuilder.isDone(this) || forceIterate)) {
|
||||
if (path != null && path.size() > 1) {
|
||||
if (currentPathIterator == null) {
|
||||
Iterator<BlockIndex> it = path.iterator();
|
||||
|
@ -403,7 +411,7 @@ public class TileBuilder extends TileAbstractBuilder implements IMachine {
|
|||
if (i == 0) {
|
||||
RPCHandler.rpcBroadcastPlayers(this, "setItemRequirements",
|
||||
null, null);
|
||||
iterateBpt();
|
||||
iterateBpt(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -416,7 +424,7 @@ public class TileBuilder extends TileAbstractBuilder implements IMachine {
|
|||
|
||||
if (!worldObj.isRemote) {
|
||||
if (i == 0) {
|
||||
iterateBpt();
|
||||
iterateBpt(false);
|
||||
done = false;
|
||||
}
|
||||
}
|
||||
|
@ -509,7 +517,9 @@ public class TileBuilder extends TileAbstractBuilder implements IMachine {
|
|||
|
||||
if (currentPathIterator != null) {
|
||||
NBTTagCompound iteratorNBT = new NBTTagCompound();
|
||||
currentPathIterator.to.writeTo(iteratorNBT);
|
||||
new BlockIndex((int) currentPathIterator.ix,
|
||||
(int) currentPathIterator.iy, (int) currentPathIterator.iz)
|
||||
.writeTo(iteratorNBT);
|
||||
bptNBT.setTag ("iterator", iteratorNBT);
|
||||
}
|
||||
|
||||
|
@ -551,7 +561,7 @@ public class TileBuilder extends TileAbstractBuilder implements IMachine {
|
|||
return;
|
||||
}
|
||||
|
||||
iterateBpt();
|
||||
iterateBpt(false);
|
||||
|
||||
if (getWorld().getWorldInfo().getGameType() == GameType.CREATIVE) {
|
||||
build();
|
||||
|
|
|
@ -32,7 +32,6 @@ public class BlockIndex implements Comparable<BlockIndex> {
|
|||
}
|
||||
|
||||
public BlockIndex(NBTTagCompound c) {
|
||||
|
||||
this.x = c.getInteger("i");
|
||||
this.y = c.getInteger("j");
|
||||
this.z = c.getInteger("k");
|
||||
|
@ -44,24 +43,24 @@ public class BlockIndex implements Comparable<BlockIndex> {
|
|||
@Override
|
||||
public int compareTo(BlockIndex o) {
|
||||
|
||||
if (o.x < x)
|
||||
if (o.x < x) {
|
||||
return 1;
|
||||
else if (o.x > x)
|
||||
} else if (o.x > x) {
|
||||
return -1;
|
||||
else if (o.z < z)
|
||||
} else if (o.z < z) {
|
||||
return 1;
|
||||
else if (o.z > z)
|
||||
} else if (o.z > z) {
|
||||
return -1;
|
||||
else if (o.y < y)
|
||||
} else if (o.y < y) {
|
||||
return 1;
|
||||
else if (o.y > y)
|
||||
} else if (o.y > y) {
|
||||
return -1;
|
||||
else
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void writeTo(NBTTagCompound c) {
|
||||
|
||||
c.setInteger("i", x);
|
||||
c.setInteger("j", y);
|
||||
c.setInteger("k", z);
|
||||
|
|
Loading…
Reference in a new issue