Handle item name changes in trim material registry

This commit is contained in:
Nassim Jahnke 2024-10-30 17:44:56 +01:00
parent 82c55b1d78
commit 93e92ffc82
No known key found for this signature in database
GPG Key ID: EF6771C01F6EF02F

View File

@ -59,6 +59,8 @@ public class RegistryDataRewriter {
key = Key.stripMinecraftNamespace(key);
if (key.equals("enchantment")) {
updateEnchantments(entries);
} else if (key.equals("trim_material")) {
updateTrimMaterials(entries);
}
final List<RegistryEntry> toAdd = this.toAdd.get(key);
@ -126,6 +128,22 @@ public class RegistryDataRewriter {
}
}
public void updateTrimMaterials(final RegistryEntry[] entries) {
if (protocol.getMappingData().getFullItemMappings() == null) {
return;
}
for (final RegistryEntry entry : entries) {
if (entry.tag() == null) {
continue;
}
final StringTag ingredientTag = ((CompoundTag) entry.tag()).getStringTag("ingredient");
final String mappedIngredient = protocol.getMappingData().getFullItemMappings().mappedIdentifier(ingredientTag.getValue());
ingredientTag.setValue(mappedIngredient);
}
}
private void updateNestedEffect(final CompoundTag effectsTag) {
final CompoundTag effect = effectsTag.getCompoundTag("effect");
if (effect == null) {