From 77162c3ebd54eeb29771e125fcd5b1daa7f56058 Mon Sep 17 00:00:00 2001 From: Kayos Date: Sat, 7 Mar 2026 11:51:53 -0800 Subject: [PATCH] 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. --- .../org/dynmap/neoforge_1_21_1/DynmapPlugin.java | 12 ++++++++---- src/main/java/org/dynmap/neoforge_1_21_1/NBT.java | 3 ++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/dynmap/neoforge_1_21_1/DynmapPlugin.java b/src/main/java/org/dynmap/neoforge_1_21_1/DynmapPlugin.java index b54648a0..88fd479c 100644 --- a/src/main/java/org/dynmap/neoforge_1_21_1/DynmapPlugin.java +++ b/src/main/java/org/dynmap/neoforge_1_21_1/DynmapPlugin.java @@ -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 diff --git a/src/main/java/org/dynmap/neoforge_1_21_1/NBT.java b/src/main/java/org/dynmap/neoforge_1_21_1/NBT.java index 5aa461f8..0b4dd1e8 100644 --- a/src/main/java/org/dynmap/neoforge_1_21_1/NBT.java +++ b/src/main/java/org/dynmap/neoforge_1_21_1/NBT.java @@ -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() : ""; }