Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-113127

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Minecraft 1.13-pre6
    • Minecraft 1.11.2, Minecraft 17w18b, Minecraft 1.12 Pre-Release 1, Minecraft 1.12 Pre-Release 2, Minecraft 1.12 Pre-Release 3, Minecraft 1.12.2, Minecraft 17w47b, Minecraft 18w14a, Minecraft 18w14b, Minecraft 18w15a, Minecraft 18w21a
    • Confirmed

      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

      1. Give yourself an item with invalid enchantments
        /give @p minecraft:diamond_boots 1 0 {ench:[{id:-1s}]}
        
      2. Get another item with valid enchantments
      3. 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)
      

            Unassigned Unassigned
            decrepitdoors Sion Richards
            Votes:
            8 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: