fix: sync with upstream tree canOcclude() fix, add [1.21.1] inline comments
CRITICAL FIX: this branch 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 upstream tree version.
This commit is contained in:
parent
ae589cdc61
commit
e9b32ff209
2 changed files with 10 additions and 5 deletions
|
|
@ -245,7 +245,9 @@ public class DynmapPlugin
|
||||||
}
|
}
|
||||||
int lightAtten = 15;
|
int lightAtten = 15;
|
||||||
try { // Workaround for mods with broken block state logic...
|
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) {
|
} catch (Exception x) {
|
||||||
Log.warning(String.format("Exception while checking lighting data for block state: %s[%s]", bn, statename));
|
Log.warning(String.format("Exception while checking lighting data for block state: %s[%s]", bn, statename));
|
||||||
Log.verboseinfo("Exception: " + x.toString());
|
Log.verboseinfo("Exception: " + x.toString());
|
||||||
|
|
@ -254,7 +256,8 @@ public class DynmapPlugin
|
||||||
// Fill in base attributes
|
// Fill in base attributes
|
||||||
bld.setBaseState(basebs).setStateIndex(idx - baseidx).setBlockName(bn).setStateName(statename).setLegacyBlockID(idx).setAttenuatesLight(lightAtten);
|
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.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.isAir()) { bld.setAir(); }
|
||||||
if (bs.is(BlockTags.LOGS)) { bld.setLog(); }
|
if (bs.is(BlockTags.LOGS)) { bld.setLog(); }
|
||||||
if (bs.is(BlockTags.LEAVES)) { bld.setLeaves(); }
|
if (bs.is(BlockTags.LEAVES)) { bld.setLeaves(); }
|
||||||
|
|
@ -913,6 +916,7 @@ public class DynmapPlugin
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
// [1.21.1] ServerTickEvent.Post replaces TickEvent.ServerTickEvent + Phase check
|
||||||
public void tickEvent(ServerTickEvent.Post event) {
|
public void tickEvent(ServerTickEvent.Post event) {
|
||||||
cur_tick_starttime = System.nanoTime();
|
cur_tick_starttime = System.nanoTime();
|
||||||
long elapsed = cur_tick_starttime - lasttick;
|
long elapsed = cur_tick_starttime - lasttick;
|
||||||
|
|
@ -1853,10 +1857,10 @@ public class DynmapPlugin
|
||||||
for (ChunkHolder ch : world.getChunkSource().chunkMap.visibleChunkMap.values()) {
|
for (ChunkHolder ch : world.getChunkSource().chunkMap.visibleChunkMap.values()) {
|
||||||
ChunkAccess c = null;
|
ChunkAccess c = null;
|
||||||
try {
|
try {
|
||||||
c = ch.getLatestChunk();
|
c = ch.getLatestChunk(); // [1.21.1] replaces getLastAvailable()
|
||||||
} catch (Exception x) { }
|
} catch (Exception x) { }
|
||||||
if (c == null) continue;
|
if (c == null) continue;
|
||||||
ChunkStatus cs = c.getPersistedStatus();
|
ChunkStatus cs = c.getPersistedStatus(); // [1.21.1] replaces getStatus()
|
||||||
ChunkPos pos = ch.getPos();
|
ChunkPos pos = ch.getPos();
|
||||||
if (cs == ChunkStatus.FULL) { // Cooked?
|
if (cs == ChunkStatus.FULL) { // Cooked?
|
||||||
// Add it as known
|
// Add it as known
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ public class NBT {
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(String s, int i) {
|
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);
|
Tag base = obj.get(s);
|
||||||
if (base == null)
|
if (base == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -93,6 +93,7 @@ public class NBT {
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public String getAsString(String s) {
|
public String getAsString(String s) {
|
||||||
|
// [1.21.1] Added null safety - getAsString behavior changed
|
||||||
Tag t = obj.get(s);
|
Tag t = obj.get(s);
|
||||||
return t != null ? t.getAsString() : "";
|
return t != null ? t.getAsString() : "";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue