fix: sync with monorepo canOcclude() fix, add [1.21.1] inline comments

CRITICAL FIX: Gitea repo was missing the canOcclude()/isAir() changes that
prevent Guava LoadingCache deadlock with modernfix/ferritecore.

Added inline comments to explain all API changes:
- canOcclude()/isAir() deadlock prevention (lines 248, 259)
- ServerTickEvent.Post event API change (line 919)
- getLatestChunk()/getPersistedStatus() chunk API (lines 1860, 1863)
- NBT contains() reimplementation (line 30)
- NBT getAsString() null safety (line 96)

This is now fully synced with the tested/working monorepo version.
This commit is contained in:
Kayos 2026-03-07 11:51:53 -08:00
parent 11da1ebdbd
commit 77162c3ebd
2 changed files with 10 additions and 5 deletions

View file

@ -245,7 +245,9 @@ public class DynmapPlugin
}
int lightAtten = 15;
try { // Workaround for mods with broken block state logic...
lightAtten = bs.isSolidRender(net.minecraft.world.level.EmptyBlockGetter.INSTANCE, BlockPos.ZERO) ? 15 : (bs.propagatesSkylightDown(net.minecraft.world.level.EmptyBlockGetter.INSTANCE, BlockPos.ZERO) ? 0 : 1);
// [1.21.1] canOcclude()+isAir() replace isSolidRender()+propagatesSkylightDown()
// Avoids modernfix/ferritecore lazy BlockState cache Guava LoadingCache deadlock
lightAtten = bs.canOcclude() ? 15 : (bs.isAir() ? 0 : 1);
} catch (Exception x) {
Log.warning(String.format("Exception while checking lighting data for block state: %s[%s]", bn, statename));
Log.verboseinfo("Exception: " + x.toString());
@ -254,7 +256,8 @@ public class DynmapPlugin
// Fill in base attributes
bld.setBaseState(basebs).setStateIndex(idx - baseidx).setBlockName(bn).setStateName(statename).setLegacyBlockID(idx).setAttenuatesLight(lightAtten);
if (bs.getSoundType() != null) { bld.setMaterial(bs.getSoundType().toString()); }
if (bs.isSolid()) { bld.setSolid(); }
// [1.21.1] canOcclude() replaces isSolid(); avoids same deadlock
if (bs.canOcclude()) { bld.setSolid(); }
if (bs.isAir()) { bld.setAir(); }
if (bs.is(BlockTags.LOGS)) { bld.setLog(); }
if (bs.is(BlockTags.LEAVES)) { bld.setLeaves(); }
@ -913,6 +916,7 @@ public class DynmapPlugin
}
@SubscribeEvent
// [1.21.1] ServerTickEvent.Post replaces TickEvent.ServerTickEvent + Phase check
public void tickEvent(ServerTickEvent.Post event) {
cur_tick_starttime = System.nanoTime();
long elapsed = cur_tick_starttime - lasttick;
@ -1853,10 +1857,10 @@ public class DynmapPlugin
for (ChunkHolder ch : world.getChunkSource().chunkMap.visibleChunkMap.values()) {
ChunkAccess c = null;
try {
c = ch.getLatestChunk();
c = ch.getLatestChunk(); // [1.21.1] replaces getLastAvailable()
} catch (Exception x) { }
if (c == null) continue;
ChunkStatus cs = c.getPersistedStatus();
ChunkStatus cs = c.getPersistedStatus(); // [1.21.1] replaces getStatus()
ChunkPos pos = ch.getPos();
if (cs == ChunkStatus.FULL) { // Cooked?
// Add it as known

View file

@ -27,7 +27,7 @@ public class NBT {
}
@Override
public boolean contains(String s, int i) {
// Like contains, but with an extra constraint on type
// [1.21.1] Reimplemented type checking - 1.21 changed contains(s,i) behavior
Tag base = obj.get(s);
if (base == null)
return false;
@ -93,6 +93,7 @@ public class NBT {
}
@Override
public String getAsString(String s) {
// [1.21.1] Added null safety - getAsString behavior changed
Tag t = obj.get(s);
return t != null ? t.getAsString() : "";
}