Skip to content

Commit

Permalink
improve position column populating
Browse files Browse the repository at this point in the history
  • Loading branch information
serenibyss committed Dec 18, 2024
1 parent 0f12138 commit b38e3c7
Showing 1 changed file with 30 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,30 @@ public static List<DataForcedChunks> getAll(int dim) {
}

private void tryParseLocation(NBTTagCompound raw) {
int xCoord = 0, yCoord = 0, zCoord = 0;
// OpenComputers stores chunk coords (XZ) so we need to approximate them to block pos
if (raw.hasKey("address", Constants.NBT.TAG_STRING)) {
Integer chunkX = null, chunkZ = null;
if (raw.hasKey("x", Constants.NBT.TAG_INT)) {
chunkX = raw.getInteger("x");
}
if (raw.hasKey("z", Constants.NBT.TAG_INT)) {
chunkZ = raw.getInteger("z");
}
if (chunkX != null && chunkZ != null) {
ChunkCoordIntPair chunkPos = new ChunkCoordIntPair(chunkX, chunkZ);
this.type = new CachedString(
String.format("[ %4d ? %4d ]", chunkPos.getCenterXPos(), chunkPos.getCenterZPosition()));
return;
}
}

Integer xCoord = null, yCoord = null, zCoord = null;

if (raw.hasKey("xCoord", Constants.NBT.TAG_INT)) { // Railcraft
xCoord = raw.getInteger("xCoord");
} else if (raw.hasKey("OwnerX", Constants.NBT.TAG_INT)) { // GregTech
xCoord = raw.getInteger("OwnerX");
} else if (raw.hasKey("x", Constants.NBT.TAG_INT)) { // Extra Utilities, OpenComputers
} else if (raw.hasKey("x", Constants.NBT.TAG_INT)) { // Extra Utilities
xCoord = raw.getInteger("x");
} else if (raw.hasKey("poppetX", Constants.NBT.TAG_INT)) { // Witchery
xCoord = raw.getInteger("poppetX");
Expand All @@ -130,19 +147,25 @@ private void tryParseLocation(NBTTagCompound raw) {
zCoord = raw.getInteger("zCoord");
} else if (raw.hasKey("OwnerZ", Constants.NBT.TAG_INT)) { // GregTech
zCoord = raw.getInteger("OwnerZ");
} else if (raw.hasKey("z", Constants.NBT.TAG_INT)) { // Extra Utilities, OpenComputers
} else if (raw.hasKey("z", Constants.NBT.TAG_INT)) { // Extra Utilities
zCoord = raw.getInteger("z");
} else if (raw.hasKey("poppetZ", Constants.NBT.TAG_INT)) { // Witchery
zCoord = raw.getInteger("poppetZ");
} else if (raw.hasKey("ChunkLoaderTileZ", Constants.NBT.TAG_INT)) { // Galacticraft
zCoord = raw.getInteger("ChunkLoaderTileZ");
}

if (xCoord != 0 && yCoord != 0 && zCoord != 0) {
position = new CachedString(String.format("[ %4d %4d %4d ]", xCoord, yCoord, zCoord));
} else {
position = NONE_CACHED;
if (xCoord == null && yCoord == null && zCoord == null) {
this.position = NONE_CACHED;
return;
}

String position = String.format(
"[ %s %s %s ]",
xCoord == null ? "?" : String.format("%4d", xCoord),
yCoord == null ? "?" : String.format("%4d", yCoord),
zCoord == null ? "?" : String.format("%4d", zCoord));
this.position = new CachedString(position);
}

private void tryParseType(NBTTagCompound raw) {
Expand Down

0 comments on commit b38e3c7

Please sign in to comment.