diff --git a/common/src/main/java/com/viaversion/viaversion/util/TagUtil.java b/common/src/main/java/com/viaversion/viaversion/util/TagUtil.java index 163b5b511..8b5a95940 100644 --- a/common/src/main/java/com/viaversion/viaversion/util/TagUtil.java +++ b/common/src/main/java/com/viaversion/viaversion/util/TagUtil.java @@ -26,19 +26,33 @@ import org.checkerframework.checker.nullness.qual.Nullable; public final class TagUtil { public static ListTag getRegistryEntries(final CompoundTag tag, final String key) { + return getRegistryEntries(tag, key, null); + } + + public static ListTag getRegistryEntries(final CompoundTag tag, final String key, final @Nullable ListTag defaultValue) { CompoundTag registry = tag.getCompoundTag(Key.namespaced(key)); if (registry == null) { registry = tag.getCompoundTag(Key.stripMinecraftNamespace(key)); + if (registry == null) { + return defaultValue; + } } return registry.getListTag("value", CompoundTag.class); } public static ListTag removeRegistryEntries(final CompoundTag tag, final String key) { + return removeRegistryEntries(tag, key, null); + } + + public static ListTag removeRegistryEntries(final CompoundTag tag, final String key, final @Nullable ListTag defaultValue) { String currentKey = Key.namespaced(key); CompoundTag registry = tag.getCompoundTag(currentKey); if (registry == null) { currentKey = Key.stripMinecraftNamespace(key); registry = tag.getCompoundTag(currentKey); + if (registry == null) { + return defaultValue; + } } tag.remove(currentKey); return registry.getListTag("value", CompoundTag.class);