Remove deprecated getX() and getZ() from DhChunkPos

This commit is contained in:
James Seibel
2023-08-25 21:17:42 -05:00
parent cdc6635a76
commit 2e647b5781
5 changed files with 26 additions and 32 deletions
@@ -188,12 +188,12 @@ public class SubDimensionLevelMatcher implements AutoCloseable
{
// the chunk isn't empty but the LOD is...
String message = "Error: the chunk at (" + playerChunkPos.getX() + "," + playerChunkPos.getZ() + ") has a height of [" + newlyLoadedChunk.getHeight() + "] but the LOD generated is empty!";
String message = "Error: the chunk at (" + playerChunkPos.x + "," + playerChunkPos.z + ") has a height of [" + newlyLoadedChunk.getHeight() + "] but the LOD generated is empty!";
LOGGER.error(message);
}
else
{
String message = "Warning: The chunk at (" + playerChunkPos.getX() + "," + playerChunkPos.getZ() + ") is empty.";
String message = "Warning: The chunk at (" + playerChunkPos.x + "," + playerChunkPos.z + ") is empty.";
LOGGER.warn(message);
}
return null;
@@ -264,7 +264,7 @@ public class SubDimensionLevelMatcher implements AutoCloseable
// stop if the test chunk doesn't contain any data
if (!testLodDataExists)
{
String message = "The test chunk for dimension folder [" + LodUtil.shortenString(testLevelFolder.getName(), 8) + "] and chunk pos (" + playerChunkPos.getX() + "," + playerChunkPos.getZ() + ") is empty. This is expected if the position is outside the sub-dimension's generated area.";
String message = "The test chunk for dimension folder [" + LodUtil.shortenString(testLevelFolder.getName(), 8) + "] and chunk pos (" + playerChunkPos.x + "," + playerChunkPos.z + ") is empty. This is expected if the position is outside the sub-dimension's generated area.";
LOGGER.info(message);
continue;
}
@@ -272,7 +272,7 @@ public class SubDimensionLevelMatcher implements AutoCloseable
// get the player data for this dimension folder
SubDimensionPlayerData testPlayerData = new SubDimensionPlayerData(testLevelFolder);
LOGGER.info("Last known player pos: [" + testPlayerData.playerBlockPos.getX() + "," + testPlayerData.playerBlockPos.getY() + "," + testPlayerData.playerBlockPos.getZ() + "]");
LOGGER.info("Last known player pos: [" + testPlayerData.playerBlockPos.x + "," + testPlayerData.playerBlockPos.y + "," + testPlayerData.playerBlockPos.z + "]");
// check if the block positions are close
int playerBlockDist = testPlayerData.playerBlockPos.getManhattanDistance(playerData.playerBlockPos);
@@ -19,8 +19,6 @@
package com.seibel.distanthorizons.core.pos;
import java.util.Objects;
public class DhChunkPos
{
public final int x; // Low 32 bits
@@ -30,6 +28,7 @@ public class DhChunkPos
public final int hashCode;
public DhChunkPos(int x, int z)
{
this.x = x;
@@ -48,29 +47,24 @@ public class DhChunkPos
// >> 4 is the Same as div 16
this(blockPos.x >> 4, blockPos.z >> 4);
}
public DhChunkPos(long packed) { this(getX(packed), getZ(packed)); }
public DhChunkPos(long packed) { this(getXFromPackedLong(packed), getZFromPackedLong(packed)); }
public DhBlockPos center() { return new DhBlockPos(8 + x << 4, 0, 8 + z << 4); }
public DhBlockPos corner() { return new DhBlockPos(x << 4, 0, z << 4); }
public DhBlockPos center() { return new DhBlockPos(8 + this.x << 4, 0, 8 + this.z << 4); }
public DhBlockPos corner() { return new DhBlockPos(this.x << 4, 0, this.z << 4); }
public static long toLong(int x, int z) { return ((long) x & 0xFFFFFFFFL) << 32 | (long) z & 0xFFFFFFFFL; }
public static int getX(long chunkPos) { return (int) (chunkPos >> 32); }
public static int getZ(long chunkPos) { return (int) (chunkPos & 0xFFFFFFFFL); }
private static int getXFromPackedLong(long chunkPos) { return (int) (chunkPos >> 32); }
private static int getZFromPackedLong(long chunkPos) { return (int) (chunkPos & 0xFFFFFFFFL); }
@Deprecated
public int getX() { return x; }
@Deprecated
public int getZ() { return z; }
public int getMinBlockX() { return this.x << 4; }
public int getMinBlockZ() { return this.z << 4; }
public int getMinBlockX() { return x << 4; }
public int getMinBlockZ() { return z << 4; }
public DhBlockPos2D getMinBlockPos() { return new DhBlockPos2D(this.x << 4, this.z << 4); }
public DhBlockPos2D getMinBlockPos() { return new DhBlockPos2D(x << 4, z << 4); }
public long getLong() { return toLong(x, z); }
public long getLong() { return toLong(this.x, this.z); }
@Override
public boolean equals(Object obj)
@@ -79,14 +73,14 @@ public class DhChunkPos
{
return true;
}
else if (obj == null || getClass() != obj.getClass())
else if (obj == null || this.getClass() != obj.getClass())
{
return false;
}
else
{
DhChunkPos that = (DhChunkPos) obj;
return x == that.x && z == that.z;
return this.x == that.x && this.z == that.z;
}
}
@@ -94,7 +88,7 @@ public class DhChunkPos
public int hashCode() { return this.hashCode; }
@Override
public String toString() { return "C[" + x + "," + z + "]"; }
public String toString() { return "C[" + this.x + "," + this.z + "]"; }
@@ -221,11 +221,11 @@ public class LodUtil
public Pos2D next()
{
DhChunkPos pos = posIter.next();
return new Pos2D(pos.getX(), pos.getZ());
return new Pos2D(pos.x, pos.z);
}
},
MC_CLIENT.getPlayerChunkPos().getX() - renderDist,
MC_CLIENT.getPlayerChunkPos().getZ() - renderDist,
MC_CLIENT.getPlayerChunkPos().x - renderDist,
MC_CLIENT.getPlayerChunkPos().z - renderDist,
renderDist * 2 + 1);
}
@@ -58,11 +58,11 @@ public class RenderUtil
*/
public static boolean isChunkPosInLoadedArea(DhChunkPos pos, DhChunkPos center)
{
return (pos.getX() >= center.getX() - MC_RENDER.getRenderDistance()
&& pos.getX() <= center.getX() + MC_RENDER.getRenderDistance())
return (pos.x >= center.x - MC_RENDER.getRenderDistance()
&& pos.x <= center.x + MC_RENDER.getRenderDistance())
&&
(pos.getZ() >= center.getZ() - MC_RENDER.getRenderDistance()
&& pos.getZ() <= center.getZ() + MC_RENDER.getRenderDistance());
(pos.z >= center.z - MC_RENDER.getRenderDistance()
&& pos.z <= center.z + MC_RENDER.getRenderDistance());
}
/**
@@ -113,8 +113,8 @@ public interface IMinecraftRenderWrapper extends IBindable
int chunkDist = this.getRenderDistance() + 1; // For some reason having '+1' is actually closer to real value
DhChunkPos centerChunkPos = mcWrapper.getPlayerChunkPos();
int centerChunkX = centerChunkPos.getX();
int centerChunkZ = centerChunkPos.getZ();
int centerChunkX = centerChunkPos.x;
int centerChunkZ = centerChunkPos.z;
int chunkDist2Mul4 = chunkDist * chunkDist * 4;
// add every position within render distance