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

@@ -888,7 +888,7 @@ public class WorldAccess
ItemStack tool;
if (tag != null)
{
tool = ItemStack.CODEC.parse(regs.createSerializationContext(NbtOps.INSTANCE), tag).result().orElse(null);
tool = ItemStack.CODEC.parse(regs.createSerializationContext(NbtOps.INSTANCE), tag).getOrThrow(s -> new InternalExpressionException("Failed to parse item stack data: " + s));
}
else
{
@@ -956,7 +956,7 @@ public class WorldAccess
{
return Value.NULL;
}
return new NBTSerializableValue(() -> ItemStack.CODEC.encodeStart(regs.createSerializationContext(NbtOps.INSTANCE), tool).getOrThrow());
return new NBTSerializableValue(() -> ItemStack.CODEC.encodeStart(regs.createSerializationContext(NbtOps.INSTANCE), tool).getOrThrow(s -> new InternalExpressionException("Failed to parse item stack data: " + s)));
});