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) {
|
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) {
|
if (bluePrintBuilder != null) {
|
||||||
NBTTagCompound builderCpt = new NBTTagCompound();
|
NBTTagCompound builderCpt = new NBTTagCompound();
|
||||||
|
@ -204,13 +219,6 @@ public class TileBuilder extends TileAbstractBuilder implements IMachine {
|
||||||
initNBT.getCompoundTag("builderState"), this);
|
initNBT.getCompoundTag("builderState"), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* if (currentPathIterator != null) { NBTTagCompound iteratorNBT =
|
|
||||||
* new NBTTagCompound();
|
|
||||||
* currentPathIterator.to.writeTo(iteratorNBT);
|
|
||||||
* nbttagcompound.setTag ("iterator", iteratorNBT); }
|
|
||||||
*/
|
|
||||||
|
|
||||||
initNBT = null;
|
initNBT = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,7 +252,7 @@ public class TileBuilder extends TileAbstractBuilder implements IMachine {
|
||||||
sendNetworkUpdate();
|
sendNetworkUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
iterateBpt();
|
iterateBpt(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createLasersForPath() {
|
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 (items[0] == null || !(items[0].getItem() instanceof ItemBlueprint)) {
|
||||||
if (bluePrintBuilder != null) {
|
if (bluePrintBuilder != null) {
|
||||||
bluePrintBuilder = null;
|
bluePrintBuilder = null;
|
||||||
|
@ -332,7 +340,7 @@ public class TileBuilder extends TileAbstractBuilder implements IMachine {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bluePrintBuilder == null || bluePrintBuilder.isDone(this)) {
|
if (bluePrintBuilder == null || (bluePrintBuilder.isDone(this) || forceIterate)) {
|
||||||
if (path != null && path.size() > 1) {
|
if (path != null && path.size() > 1) {
|
||||||
if (currentPathIterator == null) {
|
if (currentPathIterator == null) {
|
||||||
Iterator<BlockIndex> it = path.iterator();
|
Iterator<BlockIndex> it = path.iterator();
|
||||||
|
@ -403,7 +411,7 @@ public class TileBuilder extends TileAbstractBuilder implements IMachine {
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
RPCHandler.rpcBroadcastPlayers(this, "setItemRequirements",
|
RPCHandler.rpcBroadcastPlayers(this, "setItemRequirements",
|
||||||
null, null);
|
null, null);
|
||||||
iterateBpt();
|
iterateBpt(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -416,7 +424,7 @@ public class TileBuilder extends TileAbstractBuilder implements IMachine {
|
||||||
|
|
||||||
if (!worldObj.isRemote) {
|
if (!worldObj.isRemote) {
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
iterateBpt();
|
iterateBpt(false);
|
||||||
done = false;
|
done = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -509,7 +517,9 @@ public class TileBuilder extends TileAbstractBuilder implements IMachine {
|
||||||
|
|
||||||
if (currentPathIterator != null) {
|
if (currentPathIterator != null) {
|
||||||
NBTTagCompound iteratorNBT = new NBTTagCompound();
|
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);
|
bptNBT.setTag ("iterator", iteratorNBT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -551,7 +561,7 @@ public class TileBuilder extends TileAbstractBuilder implements IMachine {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
iterateBpt();
|
iterateBpt(false);
|
||||||
|
|
||||||
if (getWorld().getWorldInfo().getGameType() == GameType.CREATIVE) {
|
if (getWorld().getWorldInfo().getGameType() == GameType.CREATIVE) {
|
||||||
build();
|
build();
|
||||||
|
|
|
@ -32,7 +32,6 @@ public class BlockIndex implements Comparable<BlockIndex> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockIndex(NBTTagCompound c) {
|
public BlockIndex(NBTTagCompound c) {
|
||||||
|
|
||||||
this.x = c.getInteger("i");
|
this.x = c.getInteger("i");
|
||||||
this.y = c.getInteger("j");
|
this.y = c.getInteger("j");
|
||||||
this.z = c.getInteger("k");
|
this.z = c.getInteger("k");
|
||||||
|
@ -44,24 +43,24 @@ public class BlockIndex implements Comparable<BlockIndex> {
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(BlockIndex o) {
|
public int compareTo(BlockIndex o) {
|
||||||
|
|
||||||
if (o.x < x)
|
if (o.x < x) {
|
||||||
return 1;
|
return 1;
|
||||||
else if (o.x > x)
|
} else if (o.x > x) {
|
||||||
return -1;
|
return -1;
|
||||||
else if (o.z < z)
|
} else if (o.z < z) {
|
||||||
return 1;
|
return 1;
|
||||||
else if (o.z > z)
|
} else if (o.z > z) {
|
||||||
return -1;
|
return -1;
|
||||||
else if (o.y < y)
|
} else if (o.y < y) {
|
||||||
return 1;
|
return 1;
|
||||||
else if (o.y > y)
|
} else if (o.y > y) {
|
||||||
return -1;
|
return -1;
|
||||||
else
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeTo(NBTTagCompound c) {
|
public void writeTo(NBTTagCompound c) {
|
||||||
|
|
||||||
c.setInteger("i", x);
|
c.setInteger("i", x);
|
||||||
c.setInteger("j", y);
|
c.setInteger("j", y);
|
||||||
c.setInteger("k", z);
|
c.setInteger("k", z);
|
||||||
|
|
Loading…
Reference in a new issue