Check for trailing input in ItemFactory#createItemStack (#12312)

This commit is contained in:
TonytheMacaroni 2025-03-21 12:51:09 -04:00 committed by GitHub
parent 72f13f8bbb
commit 7cc6cb5013
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -153,7 +153,9 @@ public final class CraftItemFactory implements ItemFactory {
@Override
public ItemStack createItemStack(String input) throws IllegalArgumentException {
try {
ItemParser.ItemResult arg = new ItemParser(MinecraftServer.getDefaultRegistryAccess()).parse(new StringReader(input));
StringReader reader = new StringReader(input);
ItemParser.ItemResult arg = new ItemParser(MinecraftServer.getDefaultRegistryAccess()).parse(reader);
Preconditions.checkArgument(!reader.canRead(), "Trailing input found when parsing ItemStack: %s", input);
Item item = arg.item().value();
net.minecraft.world.item.ItemStack nmsItemStack = new net.minecraft.world.item.ItemStack(item);