diff --git a/fabric-1.14.4/src/main/java/org/dynmap/fabric_1_14_4/DynmapPlugin.java b/fabric-1.14.4/src/main/java/org/dynmap/fabric_1_14_4/DynmapPlugin.java index 3b01797dd..8ef47922f 100644 --- a/fabric-1.14.4/src/main/java/org/dynmap/fabric_1_14_4/DynmapPlugin.java +++ b/fabric-1.14.4/src/main/java/org/dynmap/fabric_1_14_4/DynmapPlugin.java @@ -162,6 +162,22 @@ private boolean checkIfKnownChunk(FabricWorld fw, ChunkPos pos) { return false; } + /** + * Get the name of a property's value within a block state, as it is serialized into + * the chunk NBT. + * + * Property#name(T) resolves to the serialized name for enum properties, which is what + * the chunk palette stores. Calling toString() on the value instead yields the Java + * enum constant name. That matches only by coincidence -- as it does for vanilla, + * whose constants are uppercased serialized names -- so modded enums whose constant + * names differ (e.g. a constant N_E serialized as "ne") fail to resolve at chunk load + * and silently render as air. + */ + private static > String getPropertyValueName(BlockState bs, + net.minecraft.state.property.Property p) { + return p.name(bs.get(p)); + } + /** * Initialize block states (org.dynmap.blockstate.DynmapBlockState) */ @@ -206,7 +222,7 @@ public void initializeBlockStates() { if (statename.length() > 0) { statename += ","; } - statename += p.getName() + "=" + bs.get(p).toString(); + statename += p.getName() + "=" + getPropertyValueName(bs, p); } int lightAtten = bs.isFullOpaque(EmptyBlockView.INSTANCE, BlockPos.ORIGIN) ? 15 : (bs.isTranslucent(EmptyBlockView.INSTANCE, BlockPos.ORIGIN) ? 0 : 1); //Log.info("statename=" + bn + "[" + statename + "], lightAtten=" + lightAtten); diff --git a/fabric-1.15.2/src/main/java/org/dynmap/fabric_1_15_2/DynmapPlugin.java b/fabric-1.15.2/src/main/java/org/dynmap/fabric_1_15_2/DynmapPlugin.java index d001dfb22..13407bede 100644 --- a/fabric-1.15.2/src/main/java/org/dynmap/fabric_1_15_2/DynmapPlugin.java +++ b/fabric-1.15.2/src/main/java/org/dynmap/fabric_1_15_2/DynmapPlugin.java @@ -162,6 +162,22 @@ private boolean checkIfKnownChunk(FabricWorld fw, ChunkPos pos) { return false; } + /** + * Get the name of a property's value within a block state, as it is serialized into + * the chunk NBT. + * + * Property#name(T) resolves to the serialized name for enum properties, which is what + * the chunk palette stores. Calling toString() on the value instead yields the Java + * enum constant name. That matches only by coincidence -- as it does for vanilla, + * whose constants are uppercased serialized names -- so modded enums whose constant + * names differ (e.g. a constant N_E serialized as "ne") fail to resolve at chunk load + * and silently render as air. + */ + private static > String getPropertyValueName(BlockState bs, + net.minecraft.state.property.Property p) { + return p.name(bs.get(p)); + } + /** * Initialize block states (org.dynmap.blockstate.DynmapBlockState) */ @@ -206,7 +222,7 @@ public void initializeBlockStates() { if (statename.length() > 0) { statename += ","; } - statename += p.getName() + "=" + bs.get(p).toString(); + statename += p.getName() + "=" + getPropertyValueName(bs, p); } int lightAtten = bs.isFullOpaque(EmptyBlockView.INSTANCE, BlockPos.ORIGIN) ? 15 : (bs.isTranslucent(EmptyBlockView.INSTANCE, BlockPos.ORIGIN) ? 0 : 1); //Log.info("statename=" + bn + "[" + statename + "], lightAtten=" + lightAtten); diff --git a/fabric-1.16.4/src/main/java/org/dynmap/fabric_1_16_4/DynmapPlugin.java b/fabric-1.16.4/src/main/java/org/dynmap/fabric_1_16_4/DynmapPlugin.java index 1297f99bb..f4375888f 100644 --- a/fabric-1.16.4/src/main/java/org/dynmap/fabric_1_16_4/DynmapPlugin.java +++ b/fabric-1.16.4/src/main/java/org/dynmap/fabric_1_16_4/DynmapPlugin.java @@ -160,6 +160,22 @@ private boolean checkIfKnownChunk(FabricWorld fw, ChunkPos pos) { return false; } + /** + * Get the name of a property's value within a block state, as it is serialized into + * the chunk NBT. + * + * Property#name(T) resolves to the serialized name for enum properties, which is what + * the chunk palette stores. Calling toString() on the value instead yields the Java + * enum constant name. That matches only by coincidence -- as it does for vanilla, + * whose constants are uppercased serialized names -- so modded enums whose constant + * names differ (e.g. a constant N_E serialized as "ne") fail to resolve at chunk load + * and silently render as air. + */ + private static > String getPropertyValueName(BlockState bs, + net.minecraft.state.property.Property p) { + return p.name(bs.get(p)); + } + /** * Initialize block states (org.dynmap.blockstate.DynmapBlockState) */ @@ -204,7 +220,7 @@ public void initializeBlockStates() { if (statename.length() > 0) { statename += ","; } - statename += p.getName() + "=" + bs.get(p).toString(); + statename += p.getName() + "=" + getPropertyValueName(bs, p); } int lightAtten = bs.isOpaqueFullCube(EmptyBlockView.INSTANCE, BlockPos.ORIGIN) ? 15 : (bs.isTranslucent(EmptyBlockView.INSTANCE, BlockPos.ORIGIN) ? 0 : 1); //Log.info("statename=" + bn + "[" + statename + "], lightAtten=" + lightAtten); diff --git a/fabric-1.17.1/src/main/java/org/dynmap/fabric_1_17_1/DynmapPlugin.java b/fabric-1.17.1/src/main/java/org/dynmap/fabric_1_17_1/DynmapPlugin.java index bea87f23f..c236c2511 100644 --- a/fabric-1.17.1/src/main/java/org/dynmap/fabric_1_17_1/DynmapPlugin.java +++ b/fabric-1.17.1/src/main/java/org/dynmap/fabric_1_17_1/DynmapPlugin.java @@ -161,6 +161,22 @@ private boolean checkIfKnownChunk(FabricWorld fw, ChunkPos pos) { return false; } + /** + * Get the name of a property's value within a block state, as it is serialized into + * the chunk NBT. + * + * Property#name(T) resolves to the serialized name for enum properties, which is what + * the chunk palette stores. Calling toString() on the value instead yields the Java + * enum constant name. That matches only by coincidence -- as it does for vanilla, + * whose constants are uppercased serialized names -- so modded enums whose constant + * names differ (e.g. a constant N_E serialized as "ne") fail to resolve at chunk load + * and silently render as air. + */ + private static > String getPropertyValueName(BlockState bs, + net.minecraft.state.property.Property p) { + return p.name(bs.get(p)); + } + /** * Initialize block states (org.dynmap.blockstate.DynmapBlockState) */ @@ -205,7 +221,7 @@ public void initializeBlockStates() { if (statename.length() > 0) { statename += ","; } - statename += p.getName() + "=" + bs.get(p).toString(); + statename += p.getName() + "=" + getPropertyValueName(bs, p); } int lightAtten = bs.isOpaqueFullCube(EmptyBlockView.INSTANCE, BlockPos.ORIGIN) ? 15 : (bs.isTranslucent(EmptyBlockView.INSTANCE, BlockPos.ORIGIN) ? 0 : 1); //Log.info("statename=" + bn + "[" + statename + "], lightAtten=" + lightAtten); diff --git a/fabric-1.18.2/src/main/java/org/dynmap/fabric_1_18_2/DynmapPlugin.java b/fabric-1.18.2/src/main/java/org/dynmap/fabric_1_18_2/DynmapPlugin.java index 84fdeb43d..e12bbfb3f 100644 --- a/fabric-1.18.2/src/main/java/org/dynmap/fabric_1_18_2/DynmapPlugin.java +++ b/fabric-1.18.2/src/main/java/org/dynmap/fabric_1_18_2/DynmapPlugin.java @@ -122,6 +122,22 @@ public static class BlockUpdateRec { public static DynmapBlockState[] stateByID; + /** + * Get the name of a property's value within a block state, as it is serialized into + * the chunk NBT. + * + * Property#name(T) resolves to the serialized name for enum properties, which is what + * the chunk palette stores. Calling toString() on the value instead yields the Java + * enum constant name. That matches only by coincidence -- as it does for vanilla, + * whose constants are uppercased serialized names -- so modded enums whose constant + * names differ (e.g. a constant N_E serialized as "ne") fail to resolve at chunk load + * and silently render as air. + */ + private static > String getPropertyValueName(BlockState bs, + net.minecraft.state.property.Property p) { + return p.name(bs.get(p)); + } + /** * Initialize block states (org.dynmap.blockstate.DynmapBlockState) */ @@ -166,7 +182,7 @@ public void initializeBlockStates() { if (statename.length() > 0) { statename += ","; } - statename += p.getName() + "=" + bs.get(p).toString(); + statename += p.getName() + "=" + getPropertyValueName(bs, p); } int lightAtten = bs.isOpaqueFullCube(EmptyBlockView.INSTANCE, BlockPos.ORIGIN) ? 15 : (bs.isTranslucent(EmptyBlockView.INSTANCE, BlockPos.ORIGIN) ? 0 : 1); //Log.info("statename=" + bn + "[" + statename + "], lightAtten=" + lightAtten); diff --git a/fabric-1.19.4/src/main/java/org/dynmap/fabric_1_19_4/DynmapPlugin.java b/fabric-1.19.4/src/main/java/org/dynmap/fabric_1_19_4/DynmapPlugin.java index ddfe24a0b..d976780c8 100644 --- a/fabric-1.19.4/src/main/java/org/dynmap/fabric_1_19_4/DynmapPlugin.java +++ b/fabric-1.19.4/src/main/java/org/dynmap/fabric_1_19_4/DynmapPlugin.java @@ -117,6 +117,22 @@ public static class BlockUpdateRec { public static DynmapBlockState[] stateByID; + /** + * Get the name of a property's value within a block state, as it is serialized into + * the chunk NBT. + * + * Property#name(T) resolves to the serialized name for enum properties, which is what + * the chunk palette stores. Calling toString() on the value instead yields the Java + * enum constant name. That matches only by coincidence -- as it does for vanilla, + * whose constants are uppercased serialized names -- so modded enums whose constant + * names differ (e.g. a constant N_E serialized as "ne") fail to resolve at chunk load + * and silently render as air. + */ + private static > String getPropertyValueName(BlockState bs, + net.minecraft.state.property.Property p) { + return p.name(bs.get(p)); + } + /** * Initialize block states (org.dynmap.blockstate.DynmapBlockState) */ @@ -161,7 +177,7 @@ public void initializeBlockStates() { if (statename.length() > 0) { statename += ","; } - statename += p.getName() + "=" + bs.get(p).toString(); + statename += p.getName() + "=" + getPropertyValueName(bs, p); } int lightAtten = bs.isOpaqueFullCube(EmptyBlockView.INSTANCE, BlockPos.ORIGIN) ? 15 : (bs.isTransparent(EmptyBlockView.INSTANCE, BlockPos.ORIGIN) ? 0 : 1); //Log.info("statename=" + bn + "[" + statename + "], lightAtten=" + lightAtten); diff --git a/fabric-1.20.6/src/main/java/org/dynmap/fabric_1_20_6/DynmapPlugin.java b/fabric-1.20.6/src/main/java/org/dynmap/fabric_1_20_6/DynmapPlugin.java index 3f6264564..2d8158eba 100644 --- a/fabric-1.20.6/src/main/java/org/dynmap/fabric_1_20_6/DynmapPlugin.java +++ b/fabric-1.20.6/src/main/java/org/dynmap/fabric_1_20_6/DynmapPlugin.java @@ -118,6 +118,22 @@ public static class BlockUpdateRec { public static DynmapBlockState[] stateByID; + /** + * Get the name of a property's value within a block state, as it is serialized into + * the chunk NBT. + * + * Property#name(T) resolves to the serialized name for enum properties, which is what + * the chunk palette stores. Calling toString() on the value instead yields the Java + * enum constant name. That matches only by coincidence -- as it does for vanilla, + * whose constants are uppercased serialized names -- so modded enums whose constant + * names differ (e.g. a constant N_E serialized as "ne") fail to resolve at chunk load + * and silently render as air. + */ + private static > String getPropertyValueName(BlockState bs, + net.minecraft.state.property.Property p) { + return p.name(bs.get(p)); + } + /** * Initialize block states (org.dynmap.blockstate.DynmapBlockState) */ @@ -161,7 +177,7 @@ public void initializeBlockStates() { if (statename.length() > 0) { statename += ","; } - statename += p.getName() + "=" + bs.get(p).toString(); + statename += p.getName() + "=" + getPropertyValueName(bs, p); } int lightAtten = bs.isOpaqueFullCube(EmptyBlockView.INSTANCE, BlockPos.ORIGIN) ? 15 : (bs.isTransparent(EmptyBlockView.INSTANCE, BlockPos.ORIGIN) ? 0 : 1); //Log.info("statename=" + bn + "[" + statename + "], lightAtten=" + lightAtten); diff --git a/fabric-1.21.11/src/main/java/org/dynmap/fabric_1_21_11/DynmapPlugin.java b/fabric-1.21.11/src/main/java/org/dynmap/fabric_1_21_11/DynmapPlugin.java index 5e9141be5..aa8186708 100644 --- a/fabric-1.21.11/src/main/java/org/dynmap/fabric_1_21_11/DynmapPlugin.java +++ b/fabric-1.21.11/src/main/java/org/dynmap/fabric_1_21_11/DynmapPlugin.java @@ -118,6 +118,22 @@ public static class BlockUpdateRec { public static DynmapBlockState[] stateByID; + /** + * Get the name of a property's value within a block state, as it is serialized into + * the chunk NBT. + * + * Property#name(T) resolves to the serialized name for enum properties, which is what + * the chunk palette stores. Calling toString() on the value instead yields the Java + * enum constant name. That matches only by coincidence -- as it does for vanilla, + * whose constants are uppercased serialized names -- so modded enums whose constant + * names differ (e.g. a constant N_E serialized as "ne") fail to resolve at chunk load + * and silently render as air. + */ + private static > String getPropertyValueName(BlockState bs, + net.minecraft.state.property.Property p) { + return p.name(bs.get(p)); + } + /** * Initialize block states (org.dynmap.blockstate.DynmapBlockState) */ @@ -161,7 +177,7 @@ public void initializeBlockStates() { if (statename.length() > 0) { statename += ","; } - statename += p.getName() + "=" + bs.get(p).toString(); + statename += p.getName() + "=" + getPropertyValueName(bs, p); } int lightAtten = bs.isOpaqueFullCube() ? 15 : (bs.isTransparent() ? 0 : 1); //Log.info("statename=" + bn + "[" + statename + "], lightAtten=" + lightAtten); diff --git a/fabric-1.21.6/src/main/java/org/dynmap/fabric_1_21_7/DynmapPlugin.java b/fabric-1.21.6/src/main/java/org/dynmap/fabric_1_21_7/DynmapPlugin.java index d95fb9e59..5a8aa9abc 100644 --- a/fabric-1.21.6/src/main/java/org/dynmap/fabric_1_21_7/DynmapPlugin.java +++ b/fabric-1.21.6/src/main/java/org/dynmap/fabric_1_21_7/DynmapPlugin.java @@ -118,6 +118,22 @@ public static class BlockUpdateRec { public static DynmapBlockState[] stateByID; + /** + * Get the name of a property's value within a block state, as it is serialized into + * the chunk NBT. + * + * Property#name(T) resolves to the serialized name for enum properties, which is what + * the chunk palette stores. Calling toString() on the value instead yields the Java + * enum constant name. That matches only by coincidence -- as it does for vanilla, + * whose constants are uppercased serialized names -- so modded enums whose constant + * names differ (e.g. a constant N_E serialized as "ne") fail to resolve at chunk load + * and silently render as air. + */ + private static > String getPropertyValueName(BlockState bs, + net.minecraft.state.property.Property p) { + return p.name(bs.get(p)); + } + /** * Initialize block states (org.dynmap.blockstate.DynmapBlockState) */ @@ -161,7 +177,7 @@ public void initializeBlockStates() { if (statename.length() > 0) { statename += ","; } - statename += p.getName() + "=" + bs.get(p).toString(); + statename += p.getName() + "=" + getPropertyValueName(bs, p); } int lightAtten = bs.isOpaqueFullCube() ? 15 : (bs.isTransparent() ? 0 : 1); //Log.info("statename=" + bn + "[" + statename + "], lightAtten=" + lightAtten); diff --git a/fabric-1.21.9-10/src/main/java/org/dynmap/fabric_1_21_9_10/DynmapPlugin.java b/fabric-1.21.9-10/src/main/java/org/dynmap/fabric_1_21_9_10/DynmapPlugin.java index 8e7968186..6915fb103 100644 --- a/fabric-1.21.9-10/src/main/java/org/dynmap/fabric_1_21_9_10/DynmapPlugin.java +++ b/fabric-1.21.9-10/src/main/java/org/dynmap/fabric_1_21_9_10/DynmapPlugin.java @@ -118,6 +118,22 @@ public static class BlockUpdateRec { public static DynmapBlockState[] stateByID; + /** + * Get the name of a property's value within a block state, as it is serialized into + * the chunk NBT. + * + * Property#name(T) resolves to the serialized name for enum properties, which is what + * the chunk palette stores. Calling toString() on the value instead yields the Java + * enum constant name. That matches only by coincidence -- as it does for vanilla, + * whose constants are uppercased serialized names -- so modded enums whose constant + * names differ (e.g. a constant N_E serialized as "ne") fail to resolve at chunk load + * and silently render as air. + */ + private static > String getPropertyValueName(BlockState bs, + net.minecraft.state.property.Property p) { + return p.name(bs.get(p)); + } + /** * Initialize block states (org.dynmap.blockstate.DynmapBlockState) */ @@ -161,7 +177,7 @@ public void initializeBlockStates() { if (statename.length() > 0) { statename += ","; } - statename += p.getName() + "=" + bs.get(p).toString(); + statename += p.getName() + "=" + getPropertyValueName(bs, p); } int lightAtten = bs.isOpaqueFullCube() ? 15 : (bs.isTransparent() ? 0 : 1); //Log.info("statename=" + bn + "[" + statename + "], lightAtten=" + lightAtten); diff --git a/forge-1.14.4/src/main/java/org/dynmap/forge_1_14_4/DynmapPlugin.java b/forge-1.14.4/src/main/java/org/dynmap/forge_1_14_4/DynmapPlugin.java index 1e94f2734..b890078e9 100644 --- a/forge-1.14.4/src/main/java/org/dynmap/forge_1_14_4/DynmapPlugin.java +++ b/forge-1.14.4/src/main/java/org/dynmap/forge_1_14_4/DynmapPlugin.java @@ -242,7 +242,7 @@ public void initializeBlockStates() { statename += ","; } try { - statename += p.getName() + "=" + bs.get(p).toString(); + statename += p.getName() + "=" + p.getName(bs.get(p)); } catch (IllegalFormatConversionException e){ } } diff --git a/forge-1.15.2/src/main/java/org/dynmap/forge_1_15_2/DynmapPlugin.java b/forge-1.15.2/src/main/java/org/dynmap/forge_1_15_2/DynmapPlugin.java index 37f1c2d83..1b107a6f1 100644 --- a/forge-1.15.2/src/main/java/org/dynmap/forge_1_15_2/DynmapPlugin.java +++ b/forge-1.15.2/src/main/java/org/dynmap/forge_1_15_2/DynmapPlugin.java @@ -254,7 +254,7 @@ public void initializeBlockStates() { if (statename.length() > 0) { statename += ","; } - statename += p.getName() + "=" + bs.get(p).toString(); + statename += p.getName() + "=" + p.getName(bs.get(p)); } int lightAtten = bs.isOpaqueCube(EmptyBlockReader.INSTANCE, BlockPos.ZERO) ? 15 : (bs.propagatesSkylightDown(EmptyBlockReader.INSTANCE, BlockPos.ZERO) ? 0 : 1); //Log.info("statename=" + bn + "[" + statename + "], lightAtten=" + lightAtten); 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 d021ace47..53077ad0f 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 @@ -223,10 +223,23 @@ private static Registry getBiomeReg() { } /** - * Initialize block states (org.dynmap.blockstate.DynmapBlockState) + * Get the name of a property's value within a block state, as it is serialized into + * the chunk NBT. + * + * Property#getName(T) resolves to the serialized name for enum properties, which is what + * the chunk palette stores. Calling toString() on the value instead yields the Java + * enum constant name. That matches only by coincidence -- as it does for vanilla, + * whose constants are uppercased serialized names -- so modded enums whose constant + * names differ (e.g. a constant N_E serialized as "ne") fail to resolve at chunk load + * and silently render as air. */ + private static > String getPropertyValueName(BlockState bs, + net.minecraft.state.Property p) { + return p.getName(bs.get(p)); + } + /** - * + * Initialize block states (org.dynmap.blockstate.DynmapBlockState) */ public void initializeBlockStates() { stateByID = new DynmapBlockState[512*32]; // Simple map - scale as needed @@ -269,7 +282,7 @@ public void initializeBlockStates() { if (statename.length() > 0) { statename += ","; } - statename += p.getName() + "=" + bs.get(p).toString(); + statename += p.getName() + "=" + getPropertyValueName(bs, p); } int lightAtten = 15; try { // Workaround for mods with broken block state logic... 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 443b0225e..2ad88ec64 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 @@ -202,6 +202,22 @@ private static Registry getBiomeReg() { return reg; } + /** + * Get the name of a property's value within a block state, as it is serialized into + * the chunk NBT. + * + * Property#getName(T) resolves to the serialized name for enum properties, which is what + * the chunk palette stores. Calling toString() on the value instead yields the Java + * enum constant name. That matches only by coincidence -- as it does for vanilla, + * whose constants are uppercased serialized names -- so modded enums whose constant + * names differ (e.g. a constant N_E serialized as "ne") fail to resolve at chunk load + * and silently render as air. + */ + private static > String getPropertyValueName(BlockState bs, + net.minecraft.world.level.block.state.properties.Property p) { + return p.getName(bs.getValue(p)); + } + /** * Initialize block states (org.dynmap.blockstate.DynmapBlockState) */ @@ -246,7 +262,7 @@ public void initializeBlockStates() { if (statename.length() > 0) { statename += ","; } - statename += p.getName() + "=" + bs.getValue(p).toString(); + statename += p.getName() + "=" + getPropertyValueName(bs, p); } int lightAtten = 15; try { // Workaround for mods with broken block state logic... diff --git a/forge-1.18.2/src/main/java/org/dynmap/forge_1_18_2/DynmapPlugin.java b/forge-1.18.2/src/main/java/org/dynmap/forge_1_18_2/DynmapPlugin.java index 091434073..27182eea3 100644 --- a/forge-1.18.2/src/main/java/org/dynmap/forge_1_18_2/DynmapPlugin.java +++ b/forge-1.18.2/src/main/java/org/dynmap/forge_1_18_2/DynmapPlugin.java @@ -202,6 +202,22 @@ private static Registry getBiomeReg() { return reg; } + /** + * Get the name of a property's value within a block state, as it is serialized into + * the chunk NBT. + * + * Property#getName(T) resolves to the serialized name for enum properties, which is what + * the chunk palette stores. Calling toString() on the value instead yields the Java + * enum constant name. That matches only by coincidence -- as it does for vanilla, + * whose constants are uppercased serialized names -- so modded enums whose constant + * names differ (e.g. a constant N_E serialized as "ne") fail to resolve at chunk load + * and silently render as air. + */ + private static > String getPropertyValueName(BlockState bs, + net.minecraft.world.level.block.state.properties.Property p) { + return p.getName(bs.getValue(p)); + } + /** * Initialize block states (org.dynmap.blockstate.DynmapBlockState) */ @@ -246,7 +262,7 @@ public void initializeBlockStates() { if (statename.length() > 0) { statename += ","; } - statename += p.getName() + "=" + bs.getValue(p).toString(); + statename += p.getName() + "=" + getPropertyValueName(bs, p); } int lightAtten = 15; try { // Workaround for mods with broken block state logic... diff --git a/forge-1.19.3/src/main/java/org/dynmap/forge_1_19_3/DynmapPlugin.java b/forge-1.19.3/src/main/java/org/dynmap/forge_1_19_3/DynmapPlugin.java index 2e07ee279..9fdd08019 100644 --- a/forge-1.19.3/src/main/java/org/dynmap/forge_1_19_3/DynmapPlugin.java +++ b/forge-1.19.3/src/main/java/org/dynmap/forge_1_19_3/DynmapPlugin.java @@ -204,6 +204,22 @@ private static Registry getBiomeReg() { return reg; } + /** + * Get the name of a property's value within a block state, as it is serialized into + * the chunk NBT. + * + * Property#getName(T) resolves to the serialized name for enum properties, which is what + * the chunk palette stores. Calling toString() on the value instead yields the Java + * enum constant name. That matches only by coincidence -- as it does for vanilla, + * whose constants are uppercased serialized names -- so modded enums whose constant + * names differ (e.g. a constant N_E serialized as "ne") fail to resolve at chunk load + * and silently render as air. + */ + private static > String getPropertyValueName(BlockState bs, + net.minecraft.world.level.block.state.properties.Property p) { + return p.getName(bs.getValue(p)); + } + /** * Initialize block states (org.dynmap.blockstate.DynmapBlockState) */ @@ -248,7 +264,7 @@ public void initializeBlockStates() { if (statename.length() > 0) { statename += ","; } - statename += p.getName() + "=" + bs.getValue(p).toString(); + statename += p.getName() + "=" + getPropertyValueName(bs, p); } int lightAtten = 15; try { // Workaround for mods with broken block state logic... diff --git a/forge-1.20.6/src/main/java/org/dynmap/forge_1_20_6/DynmapPlugin.java b/forge-1.20.6/src/main/java/org/dynmap/forge_1_20_6/DynmapPlugin.java index 4c9b20869..dc2513cbe 100644 --- a/forge-1.20.6/src/main/java/org/dynmap/forge_1_20_6/DynmapPlugin.java +++ b/forge-1.20.6/src/main/java/org/dynmap/forge_1_20_6/DynmapPlugin.java @@ -201,6 +201,22 @@ private static Registry getBiomeReg() { return reg; } + /** + * Get the name of a property's value within a block state, as it is serialized into + * the chunk NBT. + * + * Property#getName(T) resolves to the serialized name for enum properties, which is what + * the chunk palette stores. Calling toString() on the value instead yields the Java + * enum constant name. That matches only by coincidence -- as it does for vanilla, + * whose constants are uppercased serialized names -- so modded enums whose constant + * names differ (e.g. a constant N_E serialized as "ne") fail to resolve at chunk load + * and silently render as air. + */ + private static > String getPropertyValueName(BlockState bs, + net.minecraft.world.level.block.state.properties.Property p) { + return p.getName(bs.getValue(p)); + } + /** * Initialize block states (org.dynmap.blockstate.DynmapBlockState) */ @@ -244,7 +260,7 @@ public void initializeBlockStates() { if (statename.length() > 0) { statename += ","; } - statename += p.getName() + "=" + bs.getValue(p).toString(); + statename += p.getName() + "=" + getPropertyValueName(bs, p); } int lightAtten = 15; try { // Workaround for mods with broken block state logic... diff --git a/forge-1.21.10/src/main/java/org/dynmap/forge_1_21_10/DynmapPlugin.java b/forge-1.21.10/src/main/java/org/dynmap/forge_1_21_10/DynmapPlugin.java index 0030ff67b..24931e78b 100644 --- a/forge-1.21.10/src/main/java/org/dynmap/forge_1_21_10/DynmapPlugin.java +++ b/forge-1.21.10/src/main/java/org/dynmap/forge_1_21_10/DynmapPlugin.java @@ -200,6 +200,22 @@ private static Registry getBiomeReg() { return reg; } + /** + * Get the name of a property's value within a block state, as it is serialized into + * the chunk NBT. + * + * Property#getName(T) resolves to the serialized name for enum properties, which is what + * the chunk palette stores. Calling toString() on the value instead yields the Java + * enum constant name. That matches only by coincidence -- as it does for vanilla, + * whose constants are uppercased serialized names -- so modded enums whose constant + * names differ (e.g. a constant N_E serialized as "ne") fail to resolve at chunk load + * and silently render as air. + */ + private static > String getPropertyValueName(BlockState bs, + net.minecraft.world.level.block.state.properties.Property p) { + return p.getName(bs.getValue(p)); + } + /** * Initialize block states (org.dynmap.blockstate.DynmapBlockState) */ @@ -243,7 +259,7 @@ public void initializeBlockStates() { if (statename.length() > 0) { statename += ","; } - statename += p.getName() + "=" + bs.getValue(p).toString(); + statename += p.getName() + "=" + getPropertyValueName(bs, p); } int lightAtten = 15; try { // Workaround for mods with broken block state logic... diff --git a/forge-1.21.11/src/main/java/org/dynmap/forge_1_21_11/DynmapPlugin.java b/forge-1.21.11/src/main/java/org/dynmap/forge_1_21_11/DynmapPlugin.java index d02010d88..cf366f2b0 100644 --- a/forge-1.21.11/src/main/java/org/dynmap/forge_1_21_11/DynmapPlugin.java +++ b/forge-1.21.11/src/main/java/org/dynmap/forge_1_21_11/DynmapPlugin.java @@ -200,6 +200,22 @@ private static Registry getBiomeReg() { return reg; } + /** + * Get the name of a property's value within a block state, as it is serialized into + * the chunk NBT. + * + * Property#getName(T) resolves to the serialized name for enum properties, which is what + * the chunk palette stores. Calling toString() on the value instead yields the Java + * enum constant name. That matches only by coincidence -- as it does for vanilla, + * whose constants are uppercased serialized names -- so modded enums whose constant + * names differ (e.g. a constant N_E serialized as "ne") fail to resolve at chunk load + * and silently render as air. + */ + private static > String getPropertyValueName(BlockState bs, + net.minecraft.world.level.block.state.properties.Property p) { + return p.getName(bs.getValue(p)); + } + /** * Initialize block states (org.dynmap.blockstate.DynmapBlockState) */ @@ -243,7 +259,7 @@ public void initializeBlockStates() { if (statename.length() > 0) { statename += ","; } - statename += p.getName() + "=" + bs.getValue(p).toString(); + statename += p.getName() + "=" + getPropertyValueName(bs, p); } int lightAtten = 15; try { // Workaround for mods with broken block state logic... diff --git a/forge-1.21.6/src/main/java/org/dynmap/forge_1_21_6/DynmapPlugin.java b/forge-1.21.6/src/main/java/org/dynmap/forge_1_21_6/DynmapPlugin.java index af0637452..a7b456587 100644 --- a/forge-1.21.6/src/main/java/org/dynmap/forge_1_21_6/DynmapPlugin.java +++ b/forge-1.21.6/src/main/java/org/dynmap/forge_1_21_6/DynmapPlugin.java @@ -199,6 +199,22 @@ private static Registry getBiomeReg() { return reg; } + /** + * Get the name of a property's value within a block state, as it is serialized into + * the chunk NBT. + * + * Property#getName(T) resolves to the serialized name for enum properties, which is what + * the chunk palette stores. Calling toString() on the value instead yields the Java + * enum constant name. That matches only by coincidence -- as it does for vanilla, + * whose constants are uppercased serialized names -- so modded enums whose constant + * names differ (e.g. a constant N_E serialized as "ne") fail to resolve at chunk load + * and silently render as air. + */ + private static > String getPropertyValueName(BlockState bs, + net.minecraft.world.level.block.state.properties.Property p) { + return p.getName(bs.getValue(p)); + } + /** * Initialize block states (org.dynmap.blockstate.DynmapBlockState) */ @@ -242,7 +258,7 @@ public void initializeBlockStates() { if (statename.length() > 0) { statename += ","; } - statename += p.getName() + "=" + bs.getValue(p).toString(); + statename += p.getName() + "=" + getPropertyValueName(bs, p); } int lightAtten = 15; try { // Workaround for mods with broken block state logic...