crash gently with malformed itemstack data

This commit is contained in:
gnembon committed 2025-04-06 00:57:01 +02:00
1 parent 5d21d50b8b
commit 77603e16e9
3 files changed
+6 -6

No files matched your search

@@ -109,7 +109,7 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
public static Value fromStack(ItemStack stack, RegistryAccess regs)
{
NBTSerializableValue value = new NBTSerializableValue();
value.nbtSupplier = () -> ItemStack.CODEC.encodeStart(regs.createSerializationContext(NbtOps.INSTANCE), stack).getOrThrow();
value.nbtSupplier = () -> ItemStack.CODEC.encodeStart(regs.createSerializationContext(NbtOps.INSTANCE), stack).getOrThrow(s -> new InternalExpressionException("Failed to parse item stack data: " + s));
return value;
}
@@ -347,7 +347,7 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
public static ItemStack parseItem(String itemString, @Nullable CompoundTag customTag, RegistryAccess regs)
{
if (customTag != null) {
return ItemStack.CODEC.parse(regs.createSerializationContext(NbtOps.INSTANCE), customTag).resultOrPartial().orElse(null);
return ItemStack.CODEC.parse(regs.createSerializationContext(NbtOps.INSTANCE), customTag).getOrThrow(s -> new InternalExpressionException("Failed to parse item stack data: " + s));
}
try
{