Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-19 14:30:17 +01:00
Fix discarding of custom trim patterns/materials (#4642)
* Fix discarding of custom trim patterns/materials * Rename `stripNamespace` method to reflect its behaviour
Dieser Commit ist enthalten in:
Ursprung
0a261f1d9d
Commit
cda7a19a08
@ -47,7 +47,7 @@ public final class TrimRecipe {
|
||||
public static final ItemDescriptorWithCount TEMPLATE = tagDescriptor("minecraft:trim_templates");
|
||||
|
||||
public static TrimMaterial readTrimMaterial(GeyserSession session, RegistryEntry entry) {
|
||||
String key = stripNamespace(entry.getId());
|
||||
String key = stripMinecraftNamespace(entry.getId());
|
||||
|
||||
// Color is used when hovering over the item
|
||||
// Find the nearest legacy color from the RGB Java gives us to work with
|
||||
@ -67,7 +67,7 @@ public final class TrimRecipe {
|
||||
}
|
||||
|
||||
public static TrimPattern readTrimPattern(GeyserSession session, RegistryEntry entry) {
|
||||
String key = stripNamespace(entry.getId());
|
||||
String key = stripMinecraftNamespace(entry.getId());
|
||||
|
||||
String itemIdentifier = entry.getData().getString("template_item");
|
||||
ItemMapping itemMapping = session.getItemMappings().getMapping(itemIdentifier);
|
||||
@ -79,11 +79,15 @@ public final class TrimRecipe {
|
||||
}
|
||||
|
||||
// TODO find a good place for a stripNamespace util method
|
||||
private static String stripNamespace(String identifier) {
|
||||
private static String stripMinecraftNamespace(String identifier) {
|
||||
int i = identifier.indexOf(':');
|
||||
if (i >= 0) {
|
||||
String namespace = identifier.substring(0, i);
|
||||
// Only strip minecraft namespace
|
||||
if (namespace.equals("minecraft")) {
|
||||
return identifier.substring(i + 1);
|
||||
}
|
||||
}
|
||||
return identifier;
|
||||
}
|
||||
|
||||
|
@ -51,14 +51,15 @@ public class ArmorItem extends Item {
|
||||
|
||||
ArmorTrim trim = components.get(DataComponentType.TRIM);
|
||||
if (trim != null) {
|
||||
// discard custom trim patterns/materials to prevent visual glitches on bedrock
|
||||
if (trim.material().isCustom() || trim.pattern().isCustom()) {
|
||||
return;
|
||||
}
|
||||
|
||||
TrimMaterial material = session.getRegistryCache().trimMaterials().byId(trim.material().id());
|
||||
TrimPattern pattern = session.getRegistryCache().trimPatterns().byId(trim.pattern().id());
|
||||
|
||||
// discard custom trim patterns/materials to prevent visual glitches on bedrock
|
||||
if (!getNamespace(material.getMaterialId()).equals("minecraft")
|
||||
|| !getNamespace(pattern.getPatternId()).equals("minecraft")) {
|
||||
return;
|
||||
}
|
||||
|
||||
NbtMapBuilder trimBuilder = NbtMap.builder();
|
||||
// bedrock has an uppercase first letter key, and the value is not namespaced
|
||||
trimBuilder.put("Material", material.getMaterialId());
|
||||
@ -71,4 +72,13 @@ public class ArmorItem extends Item {
|
||||
public boolean isValidRepairItem(Item other) {
|
||||
return material.getRepairIngredient() == other;
|
||||
}
|
||||
|
||||
// TODO maybe some kind of namespace util?
|
||||
private static String getNamespace(String identifier) {
|
||||
int i = identifier.indexOf(':');
|
||||
if (i >= 0) {
|
||||
return identifier.substring(0, i);
|
||||
}
|
||||
return "minecraft";
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren