From effec684b99545b688964257c41dc4ec038d06fe Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Fri, 14 Jan 2022 10:37:28 -0600 Subject: [PATCH] Workaround for mods with broken block state logic... --- .../src/main/java/org/dynmap/forge_1_16_5/DynmapPlugin.java | 5 ++++- .../src/main/java/org/dynmap/forge_1_17_1/DynmapPlugin.java | 5 ++++- .../src/main/java/org/dynmap/forge_1_18/DynmapPlugin.java | 6 +++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/forge-1.16.5/src/main/java/org/dynmap/forge_1_16_5/DynmapPlugin.java b/forge-1.16.5/src/main/java/org/dynmap/forge_1_16_5/DynmapPlugin.java index 97ccce03..b42d2a00 100644 --- a/forge-1.16.5/src/main/java/org/dynmap/forge_1_16_5/DynmapPlugin.java +++ b/forge-1.16.5/src/main/java/org/dynmap/forge_1_16_5/DynmapPlugin.java @@ -271,7 +271,10 @@ public class DynmapPlugin } statename += p.getName() + "=" + bs.get(p).toString(); } - int lightAtten = bs.isOpaqueCube(EmptyBlockReader.INSTANCE, BlockPos.ZERO) ? 15 : (bs.propagatesSkylightDown(EmptyBlockReader.INSTANCE, BlockPos.ZERO) ? 0 : 1); + int lightAtten = 15; + try { // Workaround for mods with broken block state logic... + lightAtten = bs.isOpaqueCube(EmptyBlockReader.INSTANCE, BlockPos.ZERO) ? 15 : (bs.propagatesSkylightDown(EmptyBlockReader.INSTANCE, BlockPos.ZERO) ? 0 : 1); + } catch (Exception x) {} //Log.info("statename=" + bn + "[" + statename + "], lightAtten=" + lightAtten); // Fill in base attributes bld.setBaseState(basebs).setStateIndex(idx - baseidx).setBlockName(bn).setStateName(statename).setMaterial(mat.toString()).setLegacyBlockID(idx).setAttenuatesLight(lightAtten); diff --git a/forge-1.17.1/src/main/java/org/dynmap/forge_1_17_1/DynmapPlugin.java b/forge-1.17.1/src/main/java/org/dynmap/forge_1_17_1/DynmapPlugin.java index aa5fb344..ab6174a0 100644 --- a/forge-1.17.1/src/main/java/org/dynmap/forge_1_17_1/DynmapPlugin.java +++ b/forge-1.17.1/src/main/java/org/dynmap/forge_1_17_1/DynmapPlugin.java @@ -248,7 +248,10 @@ public class DynmapPlugin } statename += p.getName() + "=" + bs.getValue(p).toString(); } - int lightAtten = bs.isSolidRender(EmptyBlockGetter.INSTANCE, BlockPos.ZERO) ? 15 : (bs.propagatesSkylightDown(EmptyBlockGetter.INSTANCE, BlockPos.ZERO) ? 0 : 1); + int lightAtten = 15; + try { // Workaround for mods with broken block state logic... + lightAtten = bs.isSolidRender(EmptyBlockGetter.INSTANCE, BlockPos.ZERO) ? 15 : (bs.propagatesSkylightDown(EmptyBlockGetter.INSTANCE, BlockPos.ZERO) ? 0 : 1); + } catch (Exception x) {} //Log.info("statename=" + bn + "[" + statename + "], lightAtten=" + lightAtten); // Fill in base attributes bld.setBaseState(basebs).setStateIndex(idx - baseidx).setBlockName(bn).setStateName(statename).setMaterial(mat.toString()).setLegacyBlockID(idx).setAttenuatesLight(lightAtten); diff --git a/forge-1.18/src/main/java/org/dynmap/forge_1_18/DynmapPlugin.java b/forge-1.18/src/main/java/org/dynmap/forge_1_18/DynmapPlugin.java index 613bd943..943c3a3a 100644 --- a/forge-1.18/src/main/java/org/dynmap/forge_1_18/DynmapPlugin.java +++ b/forge-1.18/src/main/java/org/dynmap/forge_1_18/DynmapPlugin.java @@ -248,7 +248,11 @@ public class DynmapPlugin } statename += p.getName() + "=" + bs.getValue(p).toString(); } - int lightAtten = bs.isSolidRender(EmptyBlockGetter.INSTANCE, BlockPos.ZERO) ? 15 : (bs.propagatesSkylightDown(EmptyBlockGetter.INSTANCE, BlockPos.ZERO) ? 0 : 1); + int lightAtten = 15; + try { // Workaround for mods with broken block state logic... + lightAtten =bs.isSolidRender(EmptyBlockGetter.INSTANCE, BlockPos.ZERO) ? 15 : (bs.propagatesSkylightDown(EmptyBlockGetter.INSTANCE, BlockPos.ZERO) ? 0 : 1); + } catch (Exception x) { + } //Log.info("statename=" + bn + "[" + statename + "], lightAtten=" + lightAtten); // Fill in base attributes bld.setBaseState(basebs).setStateIndex(idx - baseidx).setBlockName(bn).setStateName(statename).setMaterial(mat.toString()).setLegacyBlockID(idx).setAttenuatesLight(lightAtten);