improve sign change log display

This commit is contained in:
Brokkonaut
2023-12-09 02:39:59 +01:00
parent 224bc1bae7
commit e3dda845e2

View File

@ -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<String> lines = sideSection == null ? Collections.emptyList() : sideSection.getStringList("lines");
List<String> 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;
}
}