crash gently with malformed itemstack data
This commit is contained in:
1 parent
5d21d50b8b
commit
77603e16e9
3 files changed
+6
-6
No files matched your search
@@ -888,7 +888,7 @@ public class WorldAccess
|
|||||||
ItemStack tool;
|
ItemStack tool;
|
||||||
if (tag != null)
|
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
|
else
|
||||||
{
|
{
|
||||||
@@ -956,7 +956,7 @@ public class WorldAccess
|
|||||||
{
|
{
|
||||||
return Value.NULL;
|
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)));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -726,7 +726,7 @@ public class ShapeDispatcher
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.item = ItemStack.CODEC.parse(regs.createSerializationContext(NbtOps.INSTANCE), ((NBTSerializableValue) options.get("item")).getCompoundTag() ).result().orElse(null);
|
this.item = ItemStack.CODEC.parse(regs.createSerializationContext(NbtOps.INSTANCE), ((NBTSerializableValue) options.get("item")).getCompoundTag() ).getOrThrow(s -> new InternalExpressionException("Failed to parse item stack data: " + s));
|
||||||
}
|
}
|
||||||
blockLight = NumericValue.asNumber(options.getOrDefault("blocklight", optional.get("blocklight"))).getInt();
|
blockLight = NumericValue.asNumber(options.getOrDefault("blocklight", optional.get("blocklight"))).getInt();
|
||||||
if (blockLight > 15)
|
if (blockLight > 15)
|
||||||
@@ -1663,7 +1663,7 @@ public class ShapeDispatcher
|
|||||||
public Value validate(Map<String, Value> options, MinecraftServer server, Value value)
|
public Value validate(Map<String, Value> options, MinecraftServer server, Value value)
|
||||||
{
|
{
|
||||||
ItemStack item = ValueConversions.getItemStackFromValue(value, true, server.registryAccess());
|
ItemStack item = ValueConversions.getItemStackFromValue(value, true, server.registryAccess());
|
||||||
return new NBTSerializableValue(ItemStack.CODEC.encodeStart(server.registryAccess().createSerializationContext(NbtOps.INSTANCE), item).result().orElse(null));
|
return new NBTSerializableValue(ItemStack.CODEC.encodeStart(server.registryAccess().createSerializationContext(NbtOps.INSTANCE), item).getOrThrow(s -> new InternalExpressionException("Failed to parse item stack data: " + s)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
|
|||||||
public static Value fromStack(ItemStack stack, RegistryAccess regs)
|
public static Value fromStack(ItemStack stack, RegistryAccess regs)
|
||||||
{
|
{
|
||||||
NBTSerializableValue value = new NBTSerializableValue();
|
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;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -347,7 +347,7 @@ public class NBTSerializableValue extends Value implements ContainerValueInterfa
|
|||||||
public static ItemStack parseItem(String itemString, @Nullable CompoundTag customTag, RegistryAccess regs)
|
public static ItemStack parseItem(String itemString, @Nullable CompoundTag customTag, RegistryAccess regs)
|
||||||
{
|
{
|
||||||
if (customTag != null) {
|
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
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user