fix crash-causing negative and zero enchantment levels

This commit is contained in:
__felix__ authored and GitHub committed 2025-11-06 17:47:43 -05:00
1 parent fa85b073a6
commit f9f623eee7
1 file changed
+1 -1
@@ -109,7 +109,7 @@ public class TileOverchanter extends TileEntity implements IInventory, IWandable
for (int i = 0; i < nbttaglist.tagCount(); ++i) {
NBTTagCompound tag = nbttaglist.getCompoundTagAt(i);
if (tag != null && Integer.valueOf(tag.getShort("id")) == enchId) {
tag.setShort("lvl", (short) (Integer.valueOf(tag.getShort("lvl")) + 1));
tag.setShort("lvl", Math.max((short) 1, (short) (Integer.valueOf(tag.getShort("lvl")) + 1)));
NBTTagCompound stackTag = MiscUtils.getStackTag(inventory);
if (!stackTag.hasKey("overchants")) {
stackTag.setIntArray("overchants", new int[] { enchId });