mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-25 19:45:21 +01:00
Check both namespaced and implicit key when replacing registry
This commit is contained in:
parent
fa3c933b2f
commit
c00bc6b667
@ -190,7 +190,7 @@ public final class Protocol1_19_1To1_19 extends AbstractProtocol<ClientboundPack
|
|||||||
chatTypeStorage.clear();
|
chatTypeStorage.clear();
|
||||||
|
|
||||||
final CompoundTag registry = wrapper.passthrough(Type.NAMED_COMPOUND_TAG);
|
final CompoundTag registry = wrapper.passthrough(Type.NAMED_COMPOUND_TAG);
|
||||||
final ListTag<CompoundTag> chatTypes = TagUtil.getRegistryEntries(registry, "chat_type");
|
final ListTag<CompoundTag> chatTypes = TagUtil.removeRegistryEntries(registry, "chat_type");
|
||||||
for (final CompoundTag chatType : chatTypes) {
|
for (final CompoundTag chatType : chatTypes) {
|
||||||
final NumberTag idTag = chatType.getNumberTag("id");
|
final NumberTag idTag = chatType.getNumberTag("id");
|
||||||
chatTypeStorage.addChatType(idTag.asInt(), chatType);
|
chatTypeStorage.addChatType(idTag.asInt(), chatType);
|
||||||
|
@ -33,6 +33,21 @@ public final class TagUtil {
|
|||||||
return registry.getListTag("value", CompoundTag.class);
|
return registry.getListTag("value", CompoundTag.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ListTag<CompoundTag> removeRegistryEntries(final CompoundTag tag, final String key) {
|
||||||
|
String currentKey = Key.namespaced(key);
|
||||||
|
CompoundTag registry = tag.getCompoundTag(currentKey);
|
||||||
|
if (registry == null) {
|
||||||
|
currentKey = Key.stripMinecraftNamespace(key);
|
||||||
|
registry = tag.getCompoundTag(currentKey);
|
||||||
|
}
|
||||||
|
tag.remove(currentKey);
|
||||||
|
return registry.getListTag("value", CompoundTag.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean removeNamespaced(final CompoundTag tag, final String key) {
|
||||||
|
return tag.remove(Key.namespaced(key)) != null || tag.remove(Key.stripMinecraftNamespace(key)) != null;
|
||||||
|
}
|
||||||
|
|
||||||
public static Tag handleDeep(final Tag tag, final TagUpdater consumer) {
|
public static Tag handleDeep(final Tag tag, final TagUpdater consumer) {
|
||||||
return handleDeep(null, tag, consumer);
|
return handleDeep(null, tag, consumer);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user