mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-12-22 08:27:37 +01:00
Handle supported/primary items in registry data
Fixes ViaVersion/ViaBackwards#928
This commit is contained in:
parent
366675f7f8
commit
f2456abd5b
@ -108,7 +108,13 @@ public class RegistryDataRewriter {
|
||||
continue;
|
||||
}
|
||||
|
||||
final CompoundTag effects = ((CompoundTag) entry.tag()).getCompoundTag("effects");
|
||||
final CompoundTag tag = (CompoundTag) entry.tag();
|
||||
if (protocol.getMappingData().getFullItemMappings() != null) {
|
||||
updateItemList(tag.getListTag("supported_items", StringTag.class));
|
||||
updateItemList(tag.getListTag("primary_items", StringTag.class));
|
||||
}
|
||||
|
||||
final CompoundTag effects = tag.getCompoundTag("effects");
|
||||
if (effects == null) {
|
||||
continue;
|
||||
}
|
||||
@ -118,8 +124,8 @@ public class RegistryDataRewriter {
|
||||
if (effectEntry.getValue() instanceof final CompoundTag compoundTag) {
|
||||
updateNestedEffect(compoundTag);
|
||||
} else if (effectEntry.getValue() instanceof final ListTag<?> listTag && listTag.getElementType() == CompoundTag.class) {
|
||||
for (final Tag tag : listTag) {
|
||||
updateNestedEffect((CompoundTag) tag);
|
||||
for (final Tag effectTag : listTag) {
|
||||
updateNestedEffect((CompoundTag) effectTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -210,4 +216,20 @@ public class RegistryDataRewriter {
|
||||
private boolean hasAttributeMappings() {
|
||||
return protocol.getMappingData() != null && protocol.getMappingData().getAttributeMappings() != null;
|
||||
}
|
||||
|
||||
private void updateItemList(final ListTag<StringTag> listTag) {
|
||||
if (listTag == null) {
|
||||
return;
|
||||
}
|
||||
for (final StringTag tag : listTag) {
|
||||
updateItem(tag);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateItem(final StringTag tag) {
|
||||
final String mapped = protocol.getMappingData().getFullItemMappings().mappedIdentifier(tag.getValue());
|
||||
if (mapped != null) {
|
||||
tag.setValue(mapped);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user