Putting an item with invalid enchantments in the first slot of an anvil and an item with valid ones in the second one causes a crash
The bug
Minecraft crashes when you put an item with invalid enchantments in the first slot of an anvil and an item with valid enchantments in the second one.
How to reproduce
- Give yourself an item with invalid enchantments
/give @p minecraft:diamond_boots 1 0 {ench:[{id:-1s}]} - Get another item with valid enchantments
- Put the item with the invalid enchantments in the first slot and the one with the valid ones in the second one
Code analysis
Based on 1.11.2 decompiled using MCP 9.35 rc1
The method net.minecraft.inventory.ContainerRepair.updateRepairOutput() does not skip enchantments with the id null. However, it might be better to change the method net.minecraft.enchantment.EnchantmentHelper.getEnchantments(ItemStack) to not add not existing enchantments to the map in the first place.
Crash report
Description: Updating screen events java.lang.NullPointerException: Updating screen events at aii.c(SourceFile:105) at acm.e(SourceFile:251) at acm.a(SourceFile:154) at acm$1.x_(SourceFile:44) at rr.a(SourceFile:104) at adl.d(SourceFile:79) at acl.a(SourceFile:486) at acm.b(SourceFile:431) at acl.a(SourceFile:194) at bnp.a(SourceFile:413) at big.a(SourceFile:520) at big.a(SourceFile:342) at bih.a(SourceFile:125) at bho.k(SourceFile:404) at bho.p(SourceFile:381) at bes.t(SourceFile:1586) at bes.av(SourceFile:970) at bes.a(SourceFile:398) at net.minecraft.client.main.Main.main(SourceFile:124)
2017-02-02, 10:41 PM
2018-07-06, 03:19 AM
2018-07-05, 09:22 PM
8
8