1
0
mirror of https://github.com/GeyserMC/Geyser.git synced 2025-12-19 14:59:27 +00:00

Fix loading of trim materials with an empty description (#5814)

* Fix loading of trim materials with an empty description

* Use white character just in case

* Use ChatColor.WHITE instead

* Whoops
This commit is contained in:
Eclipse
2025-09-11 16:30:53 +00:00
committed by GitHub
parent 50855d0fe4
commit cb65d1a687

View File

@@ -35,6 +35,7 @@ import org.geysermc.geyser.item.type.Item;
import org.geysermc.geyser.registry.Registries; import org.geysermc.geyser.registry.Registries;
import org.geysermc.geyser.registry.type.ItemMapping; import org.geysermc.geyser.registry.type.ItemMapping;
import org.geysermc.geyser.session.cache.registry.RegistryEntryContext; import org.geysermc.geyser.session.cache.registry.RegistryEntryContext;
import org.geysermc.geyser.text.ChatColor;
import org.geysermc.geyser.translator.text.MessageTranslator; import org.geysermc.geyser.translator.text.MessageTranslator;
import org.geysermc.mcprotocollib.protocol.data.game.Holder; import org.geysermc.mcprotocollib.protocol.data.game.Holder;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.ArmorTrim; import org.geysermc.mcprotocollib.protocol.data.game.item.component.ArmorTrim;
@@ -63,6 +64,7 @@ public final class TrimRecipe {
// Find the nearest legacy color from the style Java gives us to work with // Find the nearest legacy color from the style Java gives us to work with
Component description = MessageTranslator.componentFromNbtTag(context.data().get("description")); Component description = MessageTranslator.componentFromNbtTag(context.data().get("description"));
String legacy = MessageTranslator.convertMessage(Component.space().style(description.style())); String legacy = MessageTranslator.convertMessage(Component.space().style(description.style()));
String color = legacy.isEmpty() ? ChatColor.WHITE : legacy.substring(2).trim();
int networkId = context.getNetworkId(context.id()); int networkId = context.getNetworkId(context.id());
ItemMapping trimItem = null; ItemMapping trimItem = null;
@@ -81,7 +83,7 @@ public final class TrimRecipe {
} }
// Just pick out the resulting color code, without RESET in front. // Just pick out the resulting color code, without RESET in front.
return new TrimMaterial(key, legacy.substring(2).trim(), trimItem.getBedrockIdentifier()); return new TrimMaterial(key, color, trimItem.getBedrockIdentifier());
} }
// TODO this is WRONG. this changed. FIXME in 1.21.5 // TODO this is WRONG. this changed. FIXME in 1.21.5