mojira.dev
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

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

1.11.2\: [^crash-2017-02-02_22.13.42-client.txt]

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)

Linked issues

Attachments

Comments 10

Thank you for your report!
However, this issue has been temporarily closed as Awaiting Response.

We do not have enough information to find the cause of this issue.
Please attach the crash report (.minecraft/crash-reports/crash-<DATE>-client.txt) here.

Once attached, the report will be reopened automatically.

Quick Links:
📓 Issue Guidelines – 💬 Community Support – 📧 Customer Support – 📖 Game Wiki

Confirmed for 17w18b

I got somthing similar on my 1.8 server: if i give someone an Item with an invalid enchantment and the person opens the inventory the player gets kicked.

@unknown From what I read here in the bugtracker every now and then, outdated versions won't get bugfixes anymore, we are already in the 1.13 snapshots currently 🙂
Same goes for modded servers, despite the version they're running, bugposts for modded are always invalid.

We are in the last snapshot of 1.13. Fix this bug

Many players complain about this bug , You really need to fix this bug Please

 

confirmed for 18w20b

Can confirm for 18w21a. 

Seems to be fixed.

Probably was fixed in 1.13-pre3, due MC-130169

I reproduced using:

/give @s diamond_sword{Enchantments:[{id:"minecraft:invalid",lvl:1s}]}

and

/give @s diamond_sword{Enchantments:[{id:"minecraft:sharpness",lvl:1s}]}

EDIT:

The fix seems to be that invalid enchantments can't be added to items with valid ones:
i.e. Sharpness + Invalid = X, while Invalid + Sharpness = Just Sharpness

EDIT 2: Was fixed due to the fix to MC-130169.

This issue is related to MC-132818, a new bug I created about anvils not maintaining custom enchantment ids.

Sion Richards

(Unassigned)

Confirmed

anvil, enchantment, item

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 17w47b, Minecraft 18w14a, Minecraft 18w14b, Minecraft 18w15a, Minecraft 18w21a

Minecraft 1.13-pre6

Retrieved