From 05a424db34f06e094e791bd749f0545715b2beeb Mon Sep 17 00:00:00 2001
From: Ruling-0 <47913168+Ruling-0@users.noreply.github.com>
Date: Tue, 24 Nov 2026 15:02:50 -0600
Subject: [PATCH] Documentation cleanup
---
.../postea/ExampleMigrators.java | 2 -
.../postea/api/BlockNameAndMeta.java | 13 +---
.../postea/api/BlockReplacementManager.java | 27 ++++----
.../postea/api/ChunkTransformContext.java | 44 ++++---------
.../api/CustomDataReplacementManager.java | 31 ++++-----
.../api/CustomDataTransformContext.java | 20 ++----
.../postea/api/IVersionedTransformer.java | 59 +++++++----------
.../api/PlayerDataTransformContext.java | 13 ++--
.../api/VersionedReplacementManager.java | 12 +---
.../mixins/early/MixinAnvilChunkLoader.java | 3 +-
.../postea/mixins/early/MixinChunk.java | 2 +-
.../postea/mixins/early/MixinEntity.java | 2 +-
.../mixins/early/MixinEntityPlayer.java | 2 +-
.../postea/utility/ChunkFixerUtility.java | 8 +--
.../postea/utility/IDRegistry.java | 53 +++++----------
.../postea/utility/NbtItemStacks.java | 18 +++---
.../postea/utility/NbtLists.java | 6 +-
.../utility/PlayerDataFixerUtility.java | 13 ++--
.../postea/utility/TransformerRegistry.java | 64 +++++++------------
.../postea/utility/VersionStamps.java | 23 +++----
.../utility/VersionedTransformerLog.java | 4 +-
.../postea/utility/WorldIdTable.java | 37 +++++------
.../postea/utility/NbtItemStacksTest.java | 4 +-
23 files changed, 169 insertions(+), 291 deletions(-)
diff --git a/src/main/java/com/gtnewhorizons/postea/ExampleMigrators.java b/src/main/java/com/gtnewhorizons/postea/ExampleMigrators.java
index 81786fb..ae8a714 100644
--- a/src/main/java/com/gtnewhorizons/postea/ExampleMigrators.java
+++ b/src/main/java/com/gtnewhorizons/postea/ExampleMigrators.java
@@ -364,7 +364,6 @@ abstract class ExampleMigrators {
return "examplemod:gemIndex";
}
- // The version the running mod writes gems under; bump it whenever the index assignment changes.
@Override
public int currentVersion() {
return 2;
@@ -372,7 +371,6 @@ abstract class ExampleMigrators {
@Override
public void transformChunk(ChunkTransformContext ctx) {
- // Data saved before this transformer existed carries no stamp.
if (ctx.storedVersion() == ChunkTransformContext.UNSTAMPED || ctx.storedVersion() == 1) {
int gemBlockId = Block.getIdFromBlock(Blocks.wool);
ctx.forEachBlock((x, y, z, id, meta) -> { if (id == gemBlockId) ctx.setBlock(x, y, z, id, meta + 1); });
diff --git a/src/main/java/com/gtnewhorizons/postea/api/BlockNameAndMeta.java b/src/main/java/com/gtnewhorizons/postea/api/BlockNameAndMeta.java
index 18f02ca..f45a71c 100644
--- a/src/main/java/com/gtnewhorizons/postea/api/BlockNameAndMeta.java
+++ b/src/main/java/com/gtnewhorizons/postea/api/BlockNameAndMeta.java
@@ -1,18 +1,11 @@
package com.gtnewhorizons.postea.api;
-/**
- * A block referenced by its namespaced id, together with a meta value. Returned by
- * {@link BlockReplacementManager#transformBlock(String, int)}.
- */
+/// A block's namespaced id and meta value, as returned by [BlockReplacementManager#transformBlock(String, int)].
public final class BlockNameAndMeta {
- /**
- * The namespaced id of the block.
- */
+ /// The namespaced id of the block.
public final String name;
- /**
- * The meta value of the block.
- */
+ /// The meta value of the block.
public final int metadata;
public BlockNameAndMeta(String name, int metadata) {
diff --git a/src/main/java/com/gtnewhorizons/postea/api/BlockReplacementManager.java b/src/main/java/com/gtnewhorizons/postea/api/BlockReplacementManager.java
index a25af50..2cb4c91 100644
--- a/src/main/java/com/gtnewhorizons/postea/api/BlockReplacementManager.java
+++ b/src/main/java/com/gtnewhorizons/postea/api/BlockReplacementManager.java
@@ -57,22 +57,17 @@ public abstract class BlockReplacementManager {
// region lookup
- /**
- * Runs the block transformers registered for the given id on a block that isn't placed in the world, and returns
- * what it would be transformed into.
- *
- * This is meant for mods that store blocks by their namespaced id inside their own NBT (e.g.: blocks that are
- * made out of other blocks), which Postea can't reach while converting chunks. Calling this when such a block is
- * loaded applies every migration registered to Postea to it.
- *
- * @apiNote Only call this while a world is loaded, transformers rely on the numeric ids resolved for that world.
- * The transformers are given a {@link com.gtnewhorizons.postea.utility.BlockConversionInfo} without a
- * world, and with all coordinates set to 0. Tile entity transformers are not run.
- *
- * @param name The namespaced id of the block.
- * @param metadata The meta value of the block.
- * @return The namespaced id and meta value of the block to use instead, or null if no transformer applies.
- */
+ /// Runs the block transformers registered for `name` on a block that is not placed in the world, and returns what
+ /// it would be transformed into.
+ ///
+ /// For mods that store blocks by namespaced id in their own NBT, which Postea cannot reach while converting
+ /// chunks. Call only while a world is loaded. Transformers
+ /// get a [com.gtnewhorizons.postea.utility.BlockConversionInfo] without a world and with all coordinates 0. Tile
+ /// entity transformers are not run.
+ ///
+ /// @param name the namespaced id of the block
+ /// @param metadata the meta value of the block
+ /// @return the replacement block, or null if no transformer applies
@SuppressWarnings("unused")
public static @Nullable BlockNameAndMeta transformBlock(@Nonnull String name, int metadata) {
if (name == null) throw new NullPointerException("name cannot be null");
diff --git a/src/main/java/com/gtnewhorizons/postea/api/ChunkTransformContext.java b/src/main/java/com/gtnewhorizons/postea/api/ChunkTransformContext.java
index f7b5ebe..aeb99ba 100644
--- a/src/main/java/com/gtnewhorizons/postea/api/ChunkTransformContext.java
+++ b/src/main/java/com/gtnewhorizons/postea/api/ChunkTransformContext.java
@@ -14,13 +14,12 @@ import com.gtnewhorizons.postea.utility.NbtItemStacks;
import com.gtnewhorizons.postea.utility.NbtLists;
import com.gtnewhorizons.postea.utility.VersionStamps;
-/**
- * A chunk as handed to {@link IVersionedTransformer#transformChunk}: its block storage and the raw {@code Level}
- * tag as read from disk, before tile entities and entities are parsed. Coordinates are chunk-local
- * ({@code 0..15}, {@code y 0..255}); block ids and metadata are the world's numeric values at full EndlessIDs
- * width. The world is not loaded yet: block access through {@link #world()} is not possible. When a transformer
- * changed a block id, Postea recomputes the height map and flags the chunk for a relight once all transformers ran.
- */
+/// A chunk's block storage and raw `Level` tag, as handed to [IVersionedTransformer#transformChunk].
+///
+/// The tag is as read from disk, before tile entities and entities are parsed. Coordinates are chunk-local (`0..15`,
+/// `y 0..255`), and block ids and metadata are the world's numeric values at full EndlessIDs width. The world is not
+/// loaded, so block access through [#world()] is not possible. When a transformer changes a block id, Postea
+/// recomputes the height map and flags the chunk for a relight after all transformers ran.
public final class ChunkTransformContext {
public static final int UNSTAMPED = VersionStamps.UNSTAMPED;
@@ -58,10 +57,7 @@ public final class ChunkTransformContext {
return chunk.zPosition;
}
- /**
- * The chunk's {@code Level} tag. Changes to its {@code TileEntities} and {@code Entities} lists are loaded by
- * the game.
- */
+ /// The chunk's `Level` tag. Changes to its `TileEntities` and `Entities` lists are loaded by the game.
public NBTTagCompound levelTag() {
return levelTag;
}
@@ -74,9 +70,7 @@ public final class ChunkTransformContext {
return NbtLists.compoundList(levelTag, "Entities");
}
- /**
- * The version this transformer's key was stamped with when the chunk was saved, or {@link #UNSTAMPED}.
- */
+ /// The version stamped under the transformer's key when the chunk was saved, or [#UNSTAMPED].
public int storedVersion() {
return storedVersion;
}
@@ -85,9 +79,7 @@ public final class ChunkTransformContext {
return currentVersion;
}
- /**
- * The block id at a chunk-local position; 0 for a missing section.
- */
+ /// The block id at a chunk-local position, or 0 for a missing section.
public int getBlockId(int x, int y, int z) {
SubChunkAccess access = section(y >> 4, false);
return access == null ? 0 : access.getBlockId(x, y & 15, z);
@@ -98,9 +90,7 @@ public final class ChunkTransformContext {
return access == null ? 0 : access.getMeta(x, y & 15, z);
}
- /**
- * Sets the block at a chunk-local position, creating the section when a non-air block goes into a missing one.
- */
+ /// Sets the block at a chunk-local position, creating the section when a non-air block goes into a missing one.
public void setBlock(int x, int y, int z, int blockId, int metadata) {
SubChunkAccess access = section(y >> 4, blockId != 0);
if (access == null) return;
@@ -109,9 +99,7 @@ public final class ChunkTransformContext {
access.setMeta(x, y & 15, z, metadata);
}
- /**
- * Visits every non-air block of every present section.
- */
+ /// Visits every non-air block of every present section.
public void forEachBlock(BlockVisitor visitor) {
ExtendedBlockStorage[] storage = chunk.getBlockStorageArray();
for (int index = 0; index < storage.length; index++) {
@@ -129,18 +117,14 @@ public final class ChunkTransformContext {
}
}
- /**
- * Visits every serialized item stack held by the chunk's tile entities and entities; see
- * {@link NbtItemStacks#forEach}.
- */
+ /// Visits every serialized item stack held by the chunk's tile entities and entities. See
+ /// [NbtItemStacks#forEach].
public void forEachItemStackTag(Consumer visitor) {
NbtItemStacks.forEach(tileEntityTags(), visitor);
NbtItemStacks.forEach(entityTags(), visitor);
}
- /**
- * Whether a block id (not only metadata) was rewritten.
- */
+ /// Whether a block id, not only metadata, was rewritten.
public boolean blockIdsChanged() {
return blockIdsChanged;
}
diff --git a/src/main/java/com/gtnewhorizons/postea/api/CustomDataReplacementManager.java b/src/main/java/com/gtnewhorizons/postea/api/CustomDataReplacementManager.java
index 9bfc16e..491cd0a 100644
--- a/src/main/java/com/gtnewhorizons/postea/api/CustomDataReplacementManager.java
+++ b/src/main/java/com/gtnewhorizons/postea/api/CustomDataReplacementManager.java
@@ -11,23 +11,21 @@ import com.gtnewhorizons.postea.utility.VersionedTransformerLog;
import cpw.mods.fml.common.FMLCommonHandler;
-/**
- * Manages applying an {@link IVersionedTransformer} to mods' custom storage files.
- *
- *
Call {@link #transform} once on the root read from disk, before consuming it, and persist that root (stamps
- * included) when writing the storage back.
- *
A save path that rebuilds its NBT from scratch calls {@link #stamp} on the fresh root instead.
- *
- */
+/// Applies [IVersionedTransformer]s to a mod's custom storage files.
+///
+/// Call [#transform] once on the root read from disk, before consuming it, and persist that root, stamps included,
+/// when writing the storage back. A save path that rebuilds its NBT from scratch calls [#stamp] on the fresh root
+/// instead.
+///
+/// Custom data belongs to a world, so both methods do nothing unless a server runs in this JVM.
public abstract class CustomDataReplacementManager {
- /**
- * Transforms {@code root} in place through every registered transformer whose stamp differs from its current
- * version, then writes the updated stamps onto {@code root}. Does nothing without a running server. Throws
- * {@link IllegalStateException} when called before the world's saved id mappings were applied.
- */
+ /// Transforms `root` in place through every registered transformer whose stamp differs from its current
+ /// version, then writes the updated stamps onto `root`. Throws [IllegalStateException] when called before the
+ /// world's saved id mappings were applied.
public static void transform(String storageId, NBTTagCompound root) {
- // Not the effective side: mods save their storage from worker threads, which 1.7.10 reports as client.
+ // Custom data is only transformed while a server runs. Not getEffectiveSide(): mods save from worker
+ // threads, which 1.7.10 reports as client.
if (FMLCommonHandler.instance()
.getMinecraftServerInstance() == null) return;
if (!IDRegistry.isMappingApplied()) {
@@ -52,10 +50,7 @@ public abstract class CustomDataReplacementManager {
VersionStamps.write(root, stamps, VersionedReplacementManager.transformers());
}
- /**
- * Stamps a freshly built root about to be written to disk with every registered transformer's current version.
- * Does nothing without a running server.
- */
+ /// Stamps a freshly built root with every registered transformer's current version.
public static void stamp(NBTTagCompound root) {
if (FMLCommonHandler.instance()
.getMinecraftServerInstance() == null) return;
diff --git a/src/main/java/com/gtnewhorizons/postea/api/CustomDataTransformContext.java b/src/main/java/com/gtnewhorizons/postea/api/CustomDataTransformContext.java
index 16e766b..5d9cfaf 100644
--- a/src/main/java/com/gtnewhorizons/postea/api/CustomDataTransformContext.java
+++ b/src/main/java/com/gtnewhorizons/postea/api/CustomDataTransformContext.java
@@ -7,10 +7,8 @@ import net.minecraft.nbt.NBTTagCompound;
import com.gtnewhorizons.postea.utility.NbtItemStacks;
import com.gtnewhorizons.postea.utility.VersionStamps;
-/**
- * Context for a mod's custom world storage, used by {@link IVersionedTransformer#transformCustomData}. Stacks here
- * may have string {@code id}s instead of numeric ones; {@link #forEachItemStackTag} visits both.
- */
+/// A mod's custom world storage, as handed to [IVersionedTransformer#transformCustomData]. Stacks here may have
+/// string `id`s instead of numeric ones, and [#forEachItemStackTag] visits both.
public final class CustomDataTransformContext {
public static final int UNSTAMPED = VersionStamps.UNSTAMPED;
@@ -27,9 +25,7 @@ public final class CustomDataTransformContext {
this.currentVersion = currentVersion;
}
- /**
- * The storage's identity as its owner registered it, e.g. {@code "betterquesting:questDatabase"}.
- */
+ /// The storage's identity as its owner registered it, e.g. `"betterquesting:questDatabase"`.
public String storageId() {
return storageId;
}
@@ -38,9 +34,7 @@ public final class CustomDataTransformContext {
return root;
}
- /**
- * The version this transformer's key was stamped with when the storage was written, or {@link #UNSTAMPED}.
- */
+ /// The version stamped under the transformer's key when the storage was written, or [#UNSTAMPED].
public int storedVersion() {
return storedVersion;
}
@@ -49,10 +43,8 @@ public final class CustomDataTransformContext {
return currentVersion;
}
- /**
- * Visits every serialized item stack in the storage, including stacks whose {@code id} is a string name; see
- * {@link NbtItemStacks#forEach}.
- */
+ /// Visits every serialized item stack in the storage, including stacks whose `id` is a string name. See
+ /// [NbtItemStacks#forEach].
public void forEachItemStackTag(Consumer visitor) {
NbtItemStacks.forEach(root, visitor, true);
}
diff --git a/src/main/java/com/gtnewhorizons/postea/api/IVersionedTransformer.java b/src/main/java/com/gtnewhorizons/postea/api/IVersionedTransformer.java
index dbe21d3..22988a2 100644
--- a/src/main/java/com/gtnewhorizons/postea/api/IVersionedTransformer.java
+++ b/src/main/java/com/gtnewhorizons/postea/api/IVersionedTransformer.java
@@ -1,49 +1,38 @@
package com.gtnewhorizons.postea.api;
-/**
- * A transformer that brings saved data written under an older version of its owner's content up to the current
- * version. Postea stamps every chunk and every player it saves with {@link #currentVersion()} under {@link #key()}
- * and, when reading, invokes the transformer only for data whose stamp differs, so each chunk and player is seen
- * exactly once per version change no matter how many sessions passed in between. Data saved before the transformer
- * existed reads as {@link ChunkTransformContext#UNSTAMPED}; the transformer decides what that means.
- *
- * Register through {@link VersionedReplacementManager#register(IVersionedTransformer)} during mod loading, postInit
- * at the latest. Transformers run in registration order and before every other Postea pass, so a transformer whose
- * output depends on another mod's versioned data (for example one that writes that mod's indices) must register
- * after that mod; FML's dependency ordering guarantees this when both register in the same lifecycle phase.
- *
- * Chunk transformers may run on a chunk I/O thread, several concurrently for different chunks. They must not touch
- * world state beyond the context and their own state must be safe to read concurrently.
- *
- * Mods that keep item stacks in their own world storage offer it through {@link CustomDataReplacementManager};
- * such storage is stamped the same way and reaches the transformer through {@link #transformCustomData}.
- */
+/// Upgrades saved chunks, players and custom world storage written under another version of a mod's content.
+///
+/// Postea stamps everything it saves with [#currentVersion()] under [#key()]. On read, the transformer runs for
+/// every stored stamp that differs from [#currentVersion()], older or newer. The transformer decides what a newer
+/// version means and throws if it cannot handle it. Data saved before the transformer existed reads as
+/// [ChunkTransformContext#UNSTAMPED].
+///
+/// Register with [VersionedReplacementManager#register(IVersionedTransformer)] by postInit. Transformers run in
+/// registration order, before every other Postea pass. One whose output depends on another mod's versioned data
+/// must register after that mod.
+///
+/// Chunk transformers may run on chunk I/O threads, several at once for different chunks. They must touch no world
+/// state beyond the context, and their own state must be safe to read concurrently.
+///
+/// Custom world storage offered through [CustomDataReplacementManager] is stamped the same way and reaches
+/// [#transformCustomData].
public interface IVersionedTransformer {
- /**
- * The stamp key, unique across all registered transformers, e.g. {@code "examplemod:idList"}.
- */
+ /// The stamp key, unique across all registered transformers, e.g. `"examplemod:idList"`. Must return the same
+ /// value for the transformer's lifetime.
String key();
- /**
- * The version the transformer's output is written under. Sampled at every read and every save.
- */
+ /// The version the transformer's output is written under. Read on every load and save, and may differ between
+ /// reads.
int currentVersion();
- /**
- * Brings a chunk stamped at {@link ChunkTransformContext#storedVersion()} to {@link #currentVersion()}.
- */
+ /// Brings a chunk stamped at [ChunkTransformContext#storedVersion()] to [#currentVersion()].
default void transformChunk(ChunkTransformContext ctx) {}
- /**
- * Brings a player's saved data stamped at {@link PlayerDataTransformContext#storedVersion()} to
- * {@link #currentVersion()}.
- */
+ /// Brings a player's saved data stamped at [PlayerDataTransformContext#storedVersion()] to [#currentVersion()].
default void transformPlayer(PlayerDataTransformContext ctx) {}
- /**
- * Brings a mod's custom world storage stamped at {@link CustomDataTransformContext#storedVersion()} to
- * {@link #currentVersion()}. Stacks in such storage may carry a string {@code id} instead of a numeric one.
- */
+ /// Brings custom world storage stamped at [CustomDataTransformContext#storedVersion()] to [#currentVersion()].
+ /// Stacks in such storage may carry a string `id` instead of a numeric one.
default void transformCustomData(CustomDataTransformContext ctx) {}
}
diff --git a/src/main/java/com/gtnewhorizons/postea/api/PlayerDataTransformContext.java b/src/main/java/com/gtnewhorizons/postea/api/PlayerDataTransformContext.java
index e24eb88..b369150 100644
--- a/src/main/java/com/gtnewhorizons/postea/api/PlayerDataTransformContext.java
+++ b/src/main/java/com/gtnewhorizons/postea/api/PlayerDataTransformContext.java
@@ -8,11 +8,10 @@ import net.minecraft.nbt.NBTTagCompound;
import com.gtnewhorizons.postea.utility.NbtItemStacks;
import com.gtnewhorizons.postea.utility.VersionStamps;
-/**
- * A player's saved data as handed to {@link IVersionedTransformer#transformPlayer}: the root tag about to be
- * loaded into the player, which holds the inventory, ender chest, {@code ForgeData}, and every extended-properties
- * compound. The player object is constructed but not yet loaded from the tag.
- */
+/// A player's saved data, as handed to [IVersionedTransformer#transformPlayer].
+///
+/// The root tag holds the inventory, ender chest, `ForgeData` and every extended-properties compound. The player
+/// object is constructed but not yet loaded from the tag.
public final class PlayerDataTransformContext {
public static final int UNSTAMPED = VersionStamps.UNSTAMPED;
@@ -46,9 +45,7 @@ public final class PlayerDataTransformContext {
return currentVersion;
}
- /**
- * Visits every serialized item stack anywhere in the player's data; see {@link NbtItemStacks#forEach}.
- */
+ /// Visits every serialized item stack anywhere in the player's data. See [NbtItemStacks#forEach].
public void forEachItemStackTag(Consumer visitor) {
NbtItemStacks.forEach(playerTag, visitor);
}
diff --git a/src/main/java/com/gtnewhorizons/postea/api/VersionedReplacementManager.java b/src/main/java/com/gtnewhorizons/postea/api/VersionedReplacementManager.java
index d56f3d8..359d3cc 100644
--- a/src/main/java/com/gtnewhorizons/postea/api/VersionedReplacementManager.java
+++ b/src/main/java/com/gtnewhorizons/postea/api/VersionedReplacementManager.java
@@ -5,16 +5,12 @@ import java.util.List;
import java.util.Objects;
import java.util.concurrent.CopyOnWriteArrayList;
-/**
- * Registration of {@link IVersionedTransformer}s. See that interface for the execution contract.
- */
+/// Registry of [IVersionedTransformer]s. See that interface for the execution contract.
public abstract class VersionedReplacementManager {
private static final List TRANSFORMERS = new CopyOnWriteArrayList<>();
- /**
- * Registers a transformer. Throws {@link IllegalArgumentException} when its key is empty or already registered.
- */
+ /// Registers a transformer. Throws [IllegalArgumentException] when its key is empty or already registered.
public static void register(IVersionedTransformer transformer) {
String key = Objects.requireNonNull(transformer.key(), "key must not be null");
if (key.isEmpty()) throw new IllegalArgumentException("Versioned transformer key must not be empty");
@@ -27,9 +23,7 @@ public abstract class VersionedReplacementManager {
TRANSFORMERS.add(transformer);
}
- /**
- * The registered transformers in registration order.
- */
+ /// The registered transformers in registration order, as an unmodifiable view.
public static List transformers() {
return Collections.unmodifiableList(TRANSFORMERS);
}
diff --git a/src/main/java/com/gtnewhorizons/postea/mixins/early/MixinAnvilChunkLoader.java b/src/main/java/com/gtnewhorizons/postea/mixins/early/MixinAnvilChunkLoader.java
index 64b1fab..dbc31a5 100644
--- a/src/main/java/com/gtnewhorizons/postea/mixins/early/MixinAnvilChunkLoader.java
+++ b/src/main/java/com/gtnewhorizons/postea/mixins/early/MixinAnvilChunkLoader.java
@@ -16,8 +16,7 @@ import com.gtnewhorizons.postea.utility.ChunkFixerUtility;
@Mixin(value = AnvilChunkLoader.class, priority = 1100)
public abstract class MixinAnvilChunkLoader {
- // Forge-added funnel for sync and async loads; runs after relocation fix-ups and after ChunkAPI's own
- // readChunkFromNBT replacement, so covers vanilla, NEID, EndlessIDs, and ChunkAPI.
+ /// Hooks the funnel shared by sync and async loads, which runs after ChunkAPI's `readChunkFromNBT` replacement.
@Inject(method = "checkedReadChunkFromNBT__Async", at = @At("RETURN"), remap = false, require = 1)
private void postea$chunkHook(CallbackInfoReturnable