Correct versioned transformer threading, stack id and height map docs

This commit is contained in:
Ruling-0 committed 2026-11-25 14:46:00 -06:00
1 parent e3e0bcd685
commit 477713f002
5 files changed
+15 -7

No files matched your search

@@ -10,7 +10,8 @@ import com.gtnewhorizons.postea.utility.NbtItemStacks;
/// 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.
///
/// @param storageId the storage's identity as its owner registered it, e.g. `"betterquesting:questDatabase"`
/// @param storageId the id the owning mod passed to [CustomDataReplacementManager#transform], e.g.
/// `"betterquesting:questDatabase"`
/// @param storedVersion the version stamped under the transformer's key when the storage was written, or
/// [IVersionedTransformer#UNSTAMPED]
@Desugar
@@ -10,8 +10,10 @@ package com.gtnewhorizons.postea.api;
/// 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.
/// Transformers may run off the server thread, several at once for different data: chunks on chunk I/O threads, players
/// on the network thread handling their login, and custom data on whichever thread the owning mod reads it. A
/// transformer must touch no world state beyond the context, and its own state must be safe to read concurrently. Each
/// call has the context's data to itself, and runs after the world's saved id map has been applied.
///
/// Custom world storage offered through [CustomDataReplacementManager] is stamped the same way and reaches
/// [#transformCustomData].
@@ -10,7 +10,9 @@ import net.minecraft.nbt.NBTTagCompound;
/// Each pass calls [#stackTransform] once, before visiting any stack.
public abstract class VersionedStackTransformer implements IVersionedTransformer {
/// The rewrite applied to each stack tag in data stamped at `storedVersion`, or null when that data needs none.
/// The rewrite applied to each stack tag in data stamped at `storedVersion`, or null when that data needs none. In
/// custom world storage the rewrite also receives stacks whose `id` is a string name. A rewrite that matches only
/// numeric ids leaves those stacks unchanged.
protected abstract Consumer<NBTTagCompound> stackTransform(int storedVersion);
@Override
@@ -9,10 +9,10 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import com.gtnewhorizons.postea.mixins.interfaces.IPlayerStampsMixin;
/// Carries a player's version stamps to the entity `clonePlayer` builds on respawn, which is not read from NBT.
@Mixin(EntityPlayer.class)
public abstract class MixinEntityPlayer {
/// Copies the version stamps from the old player, because a respawned player is not built through NBT.
@Inject(method = "clonePlayer", at = @At("RETURN"), require = 1)
private void postea$carryVersionStamps(EntityPlayer oldPlayer, boolean respawn, CallbackInfo ci) {
if ((Object) this instanceof IPlayerStampsMixin player && oldPlayer instanceof IPlayerStampsMixin old) {
@@ -2,8 +2,11 @@ package com.gtnewhorizons.postea.utility;
import net.minecraft.world.chunk.Chunk;
/// Rebuilds a chunk's height map from the chunk's own storage, which is safe on the chunk I/O thread.
/// `Chunk.generateHeightMap` is client-only and `generateSkylightMap` reaches into the world.
/// Rebuilds a chunk's height map from the chunk's own storage. `Chunk.generateHeightMap` is client-only and
/// `generateSkylightMap` reaches into the world.
///
/// Block opacity comes from the position-aware `Block.getLightOpacity`, so a block that overrides it can read the world
/// from the chunk I/O thread.
final class HeightMaps {
private HeightMaps() {}