Cached tag parser for itemstack reading (#12547)

This commit is contained in:
Bjarne Koll 2025-05-17 13:42:51 +02:00 committed by GitHub
parent d683970d40
commit 369ad1706b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -551,6 +551,7 @@ public final class CraftMagicNumbers implements UnsafeValues {
return ret;
}
private static final TagParser<Tag> SNBT_REGISTRY_UNAWARE_PARSER = TagParser.create(NbtOps.INSTANCE);
@Override
public @org.jetbrains.annotations.NotNull ItemStack deserializeStack(@org.jetbrains.annotations.NotNull final Map<String, Object> args) {
final int version = args.getOrDefault("schema_version", 1) instanceof Number val ? val.intValue() : -1;
@ -581,7 +582,7 @@ public final class CraftMagicNumbers implements UnsafeValues {
componentMap.forEach((componentKey, componentString) -> {
final Tag componentTag;
try {
componentTag = TagParser.create(NbtOps.INSTANCE).parseFully(componentString);
componentTag = SNBT_REGISTRY_UNAWARE_PARSER.parseFully(componentString);
} catch (final CommandSyntaxException e) {
throw new RuntimeException("Error parsing item stack data components", e);
}