fixed NPE when saving positions, close #1782

This commit is contained in:
SpaceToad 2014-05-11 14:19:59 +02:00
parent 1c90496cde
commit c0412cc831

View file

@ -40,6 +40,10 @@ public class Position {
y = cj; y = cj;
z = ck; z = ck;
orientation = corientation; orientation = corientation;
if (orientation == null) {
orientation = ForgeDirection.UNKNOWN;
}
} }
public Position(Position p) { public Position(Position p) {
@ -57,6 +61,7 @@ public class Position {
x = tile.xCoord; x = tile.xCoord;
y = tile.yCoord; y = tile.yCoord;
z = tile.zCoord; z = tile.zCoord;
orientation = ForgeDirection.UNKNOWN;
} }
public void moveRight(double step) { public void moveRight(double step) {
@ -127,6 +132,10 @@ public class Position {
} }
public void writeToNBT(NBTTagCompound nbttagcompound) { public void writeToNBT(NBTTagCompound nbttagcompound) {
if (orientation == null) {
orientation = ForgeDirection.UNKNOWN;
}
nbttagcompound.setDouble("i", x); nbttagcompound.setDouble("i", x);
nbttagcompound.setDouble("j", y); nbttagcompound.setDouble("j", y);
nbttagcompound.setDouble("k", z); nbttagcompound.setDouble("k", z);