From 38a8c733115e3ad55acaa233705d8366c758ff84 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sun, 11 Dec 2022 17:28:07 -0600 Subject: [PATCH] Minor MetaFile reformatting --- .../com/seibel/lod/core/file/MetaFile.java | 46 +++++++++++-------- .../com/seibel/lod/core/file/PlayerData.java | 22 +++++++-- 2 files changed, 43 insertions(+), 25 deletions(-) diff --git a/core/src/main/java/com/seibel/lod/core/file/MetaFile.java b/core/src/main/java/com/seibel/lod/core/file/MetaFile.java index ee4f247d7..9ecb35654 100644 --- a/core/src/main/java/com/seibel/lod/core/file/MetaFile.java +++ b/core/src/main/java/com/seibel/lod/core/file/MetaFile.java @@ -18,35 +18,41 @@ import com.seibel.lod.core.logging.DhLoggerBuilder; import com.seibel.lod.core.util.LodUtil; import org.apache.logging.log4j.Logger; +/** + * Used size: 40 bytes
+ * Remaining space: 24 bytes
+ * Total size: 64 bytes


+ * + * + * Metadata format:

+ * + * 4 bytes: magic bytes: "DHv0" (in ascii: 0x44 48 76 30) (this also signals the metadata format)
+ * 4 bytes: section X position
+ * 4 bytes: section Y position (Unused, for future proofing)
+ * 4 bytes: section Z position

+ * + * 4 bytes: data checksum
//TODO: Implement checksum + * 1 byte: section detail level
+ * 1 byte: data detail level // Note: not sure if this is needed
+ * 1 byte: loader version
+ * 1 byte: unused

+ * + * 8 bytes: datatype identifier

+ * + * 8 bytes: data version + */ public class MetaFile { private static final Logger LOGGER = DhLoggerBuilder.getLogger(); - //Metadata format: - // - // 4 bytes: magic bytes: "DHv0" (in ascii: 0x44 48 76 30) (this also signal the metadata format) - // 4 bytes: section X position - // 4 bytes: section Y position (Unused, for future proofing) - // 4 bytes: section Z position - // - // 4 bytes: data checksum //TODO: Implement checksum - // 1 byte: section detail level - // 1 byte: data detail level // Note: not sure if this is needed - // 1 byte: loader version - // 1 byte: unused - // - // 8 bytes: datatype identifier - // - // 8 bytes: data version + - // Used size: 40 bytes - // Remaining space: 24 bytes - // Total size: 64 bytes + public static final int METADATA_SIZE = 64; public static final int METADATA_RESERVED_SIZE = 24; public static final int METADATA_MAGIC_BYTES = 0x44_48_76_30; - // Currently set to false because for some reason Window is throwing PermissionDeniedException when trying to atomic replace a file... + /** Currently set to false because for some reason Window is throwing PermissionDeniedException when trying to atomic replace a file... */ public static final boolean USE_ATOMIC_MOVE_REPLACE = false; public final DhSectionPos pos; diff --git a/core/src/main/java/com/seibel/lod/core/file/PlayerData.java b/core/src/main/java/com/seibel/lod/core/file/PlayerData.java index 055c70dc4..679121ff5 100644 --- a/core/src/main/java/com/seibel/lod/core/file/PlayerData.java +++ b/core/src/main/java/com/seibel/lod/core/file/PlayerData.java @@ -56,12 +56,23 @@ public class PlayerData * I'm not sure what this will look like for worlds that don't have a spawn point. */ public DhBlockPos worldSpawnPointBlockPos; + + + @Nullable - public static PlayerData tryGetPlayerData(IMinecraftClientWrapper mcClient) { - if (!mcClient.playerExists()) return null; - try { + public static PlayerData tryGetPlayerData(IMinecraftClientWrapper mcClient) + { + if (!mcClient.playerExists()) + { + return null; + } + + try + { return new PlayerData(mcClient); - } catch (RuntimeException e) { + } + catch (RuntimeException e) + { // Player no longer exists due to concurrency. FIXME: Remember here is called not on main thread!!! return null; } @@ -125,7 +136,8 @@ public class PlayerData @Override public String toString() { - return "PlayerBlockPos: [" + playerBlockPos.getX() + "," + playerBlockPos.getY() + "," + playerBlockPos.getZ() + "]"; + return "PlayerBlockPos: [" + playerBlockPos.x + "," + playerBlockPos.y + "," + playerBlockPos.z + "]"; } + }