@@ -9,6 +9,7 @@ public class Location extends BlockPos {
99 World world ;
1010 static final int WORLD_SPACING = 2000 ;
1111 static final int WORLD_SPACING_HALF = WORLD_SPACING /2 ;
12+ static BlockPos zeroPoint = new BlockPos (0 ,0 ,0 );
1213
1314 // Altitudes for world number i are >-WORLD_SPACING_HALF-WORLD_SPACING*i and
1415 // <= WORLD_SPACING_HALF-WORLD_SPACING*i, with altitude 0 being at -WORLD_SPACING*i.
@@ -53,25 +54,32 @@ static public double encodeAltitude(int worldIndex, double y) {
5354 super (x ,y ,z );
5455 this .world = world ;
5556 }
57+
58+ public static BlockPos getOrigin (World w ) {
59+ if (RaspberryJamMod .absoluteCoordinates )
60+ return zeroPoint ;
61+ else
62+ return w .getSpawnPoint ();
63+ }
5664
5765 static Location decodeLocation (World [] serverWorlds , int x , int y , int z ) {
5866 World w = getWorldByEncodedAltitude (serverWorlds , y );
59- BlockPos spawnPos = w . getSpawnPoint ( );
60- return new Location (w , x +spawnPos .getX (), (int )decodeAltitude (y )+spawnPos .getY (), z +spawnPos .getZ ());
67+ BlockPos originPos = getOrigin ( w );
68+ return new Location (w , x +originPos .getX (), (int )decodeAltitude (y )+originPos .getY (), z +originPos .getZ ());
6169 }
6270
6371 static Vec3w decodeVec3w (World [] serverWorlds , double x , double y , double z ) {
6472 World w = getWorldByEncodedAltitude (serverWorlds , y );
65- BlockPos spawnPos = w . getSpawnPoint ( );
66- return new Vec3w (w , x +spawnPos .getX (), (int )decodeAltitude (y )+spawnPos .getY (), z +spawnPos .getZ ());
73+ BlockPos originPos = getOrigin ( w );
74+ return new Vec3w (w , x +originPos .getX (), (int )decodeAltitude (y )+originPos .getY (), z +originPos .getZ ());
6775 }
6876
6977 public static Vec3d encodeVec3 (World [] serverWorlds , World w , Vec3d pos ) {
7078 for (int i = 0 ; i < serverWorlds .length ; i ++) {
7179 if (serverWorlds [i ] == w ) {
72- BlockPos spawnPos = w . getSpawnPoint ( );
73- return new Vec3d (pos .xCoord -spawnPos .getX (), encodeAltitude (i , pos .yCoord -spawnPos .getY ()),
74- pos .zCoord -spawnPos .getZ ());
80+ BlockPos originPos = getOrigin ( w );
81+ return new Vec3d (pos .xCoord -originPos .getX (), encodeAltitude (i , pos .yCoord -originPos .getY ()),
82+ pos .zCoord -originPos .getZ ());
7583 }
7684 }
7785 return pos ;
@@ -80,8 +88,8 @@ public static Vec3d encodeVec3(World[] serverWorlds, World w, Vec3d pos) {
8088 public static Vec3i encodeVec3i (World [] serverWorlds , World w , int x , int y , int z ) {
8189 for (int i = 0 ; i < serverWorlds .length ; i ++) {
8290 if (serverWorlds [i ] == w ) {
83- BlockPos spawnPos = w . getSpawnPoint ( );
84- return new Vec3i (x -spawnPos .getX (), encodeAltitude (i , y -spawnPos .getY ()), z -spawnPos .getZ ());
91+ BlockPos originPos = getOrigin ( w );
92+ return new Vec3i (x -originPos .getX (), encodeAltitude (i , y -originPos .getY ()), z -originPos .getZ ());
8593 }
8694 }
8795 return new Vec3i (x ,y ,z );
0 commit comments