diff --git a/src/main/java/de/diddiz/LogBlock/blockstate/BlockStateCodecSign.java b/src/main/java/de/diddiz/LogBlock/blockstate/BlockStateCodecSign.java index e230dae..7295709 100644 --- a/src/main/java/de/diddiz/LogBlock/blockstate/BlockStateCodecSign.java +++ b/src/main/java/de/diddiz/LogBlock/blockstate/BlockStateCodecSign.java @@ -143,11 +143,8 @@ public class BlockStateCodecSign implements BlockStateCodec { tc.addExtra(isWaxed ? "(waxed)" : "(not waxed)"); } for (Side side : Side.values()) { + boolean sideHeaderAdded = false; ConfigurationSection sideSection = side == Side.FRONT ? state : state.getConfigurationSection(side.name().toLowerCase()); - if (tc.getExtra() != null && !tc.getExtra().isEmpty()) { - tc.addExtra(" "); - } - tc.addExtra(side.name() + ":"); List lines = sideSection == null ? Collections.emptyList() : sideSection.getStringList("lines"); List oldLines = Collections.emptyList(); @@ -178,6 +175,7 @@ public class BlockStateCodecSign implements BlockStateCodec { } if (!lines.equals(oldLines)) { + sideHeaderAdded = addSideHeaderText(tc, side, sideHeaderAdded); for (String line : lines) { if (tc.getExtra() != null && !tc.getExtra().isEmpty()) { tc.addExtra(" "); @@ -190,6 +188,7 @@ public class BlockStateCodecSign implements BlockStateCodec { } } if (signColor != oldSignColor) { + sideHeaderAdded = addSideHeaderText(tc, side, sideHeaderAdded); if (tc.getExtra() != null && !tc.getExtra().isEmpty()) { tc.addExtra(" "); } @@ -200,6 +199,7 @@ public class BlockStateCodecSign implements BlockStateCodec { tc.addExtra(")"); } if (glowing != oldGlowing) { + sideHeaderAdded = addSideHeaderText(tc, side, sideHeaderAdded); if (tc.getExtra() != null && !tc.getExtra().isEmpty()) { tc.addExtra(" "); } @@ -214,4 +214,14 @@ public class BlockStateCodecSign implements BlockStateCodec { } return null; } + + private static boolean addSideHeaderText(TextComponent tc, Side side, boolean wasAdded) { + if (!wasAdded) { + if (tc.getExtra() != null && !tc.getExtra().isEmpty()) { + tc.addExtra(" "); + } + tc.addExtra(side.name() + ":"); + } + return true; + } }