Extended Drawers

Extended Drawers

145k Downloads

[Bug 1.18.2] Crash when placing enchanted sword in drawer

itsdinkd opened this issue ยท 7 comments

commented

Description of the issue

Occuring on Another Quality Modpack 2.

Looks like there is a coxinha utilities wooden hopper also involved that the player is using associated with a extended drawer.

image

Reproduction steps

Put an enchanted sword into a drawer
Crash

Mod version

1.2.1

Operating System

linux

Minecraft version

1.18.2

Other mods

see crash report

Server

Happens

Client

Not tested

Logs

https://gist.github.com/itsdinkd/c8d4c5829a95e5098f51eb7214987029

Extra Context

No response

commented

Yes @AlexIIL is right here, variants should never be compared with ==.

As for crashing, it's probably better to silently void items, but crashing is rare enough atm that it's fine.

commented

Seems like the LibBlockAttributes transfer api compat is broken. Will ask the if they know anything about this.

commented

From a brief look, it might be caused by the identity check here:


As far as I'm aware, transfer API doesn't cache ItemVariants that have NBT [1], so you'd need to use .equals() here rather than an identity check.

[1]: https://github.com/FabricMC/fabric/blob/d78c70fcbb5ccb10a51a6728a3565e04ee86d1c7/fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/impl/transfer/item/ItemVariantImpl.java#L36-L45

commented

For context, LBA (like forge) is simulation based, which means it needs to simulate the extraction before actually extracting it - there's two methods in LBA relevant here (ItemInvUtil.move(4 args), and TransferItemApiCompat.Transfer2Lba.attemptExtraction())

1: It passes the ItemVariant that it found in the inventory back to the inventory (so it can extract successfully the first time)
2: It then creates a new ItemVariant based on the exact ItemStack found - for enchanted tools this will have NBT, and so won't be the same object - which will probably fail the identity check in ExtendedDrawers.

commented

That does indeed seem to be the issue. I'd suggest maybe not crashing when that happens, but I will fix it on my end in a few days when I have time.

commented

Could you check if this version fixes it?

commented

Closing this now. If the issue persists please reopen