BackupCup / MCDE

Other
3 stars 7 forks source link

[1.20.1] Anvil Crash #36

Closed hammy275 closed 1 month ago

hammy275 commented 2 months ago

Under the latest version of MCDE available on CurseForge (1.6.3), placing any item without NBT (such as an anvil itself!) into either slot of an anvil crashes the game. Here is a crash report of the issue.

I haven't actually tested in a development environment, but based on the stacktrace, I'm fairly certain these lines of code are at fault. EnchantmentSlots.fromItemStack() returns an empty Optional when there's no NBT, but there's nothing stopping the aforementioned lines from trying to retrieve the value in the Optional when both are empty (if one isn't empty, then this statement runs and we return out earlier), hence the crash.

For some context, I found out about this since a user reported a crash in my Discord server understandably thinking it was my mod (ImmersiveMC), as the stacktrace was filled with mentions of it. After a while though, I did catch the Mixin from MCDE in the crash log, and have definitely confirmed this is a bug on MCDE's end, as you can reproduce this bug by following the pretty basic instructions at the top of this issue with just MCDE and Fabric API installed. ImmersiveMC was causing issues due to it setting the input slots of an anvil to ItemStack.EMPTY, which of course don't have NBT.

I can open a PR for fixing this if you want, but I figured this issue might be simple enough where you don't want to deal with the extra headache a PR requires.

Iamnotagenius commented 1 month ago

ah, sorry, im just stupid for not handling the case where no items has slots in them. You can open a PR if you really want, but this fix is easy enough so I'll do it myself later. I'll try to publish the fix this day.