WesJD / AnvilGUI

Capture user input in Minecraft through an anvil GUI in under 20 lines of code
MIT License
481 stars 114 forks source link

Fix InventoryCloseEvent firing twice #346

Closed 0dinD closed 2 months ago

0dinD commented 2 months ago

Fixes #339

It looks like the reason for the bug is a mismatch in the mappings for some of the NMS wrappers. Specifically, closeContainer was being called instead of doCloseContainer, which will lead to the InventoryCloseEvent firing an extra time (should be pretty clear if you look at the code in an IDE so you can jump between the relevant methods). The comment makes it pretty clear that doCloseContainer is what should be called, not closeContainer (in fact, if you look at the other wrappers, even all the way back to 1.8, this has always been the case). The mappings are mismatched in the 1_20_R3 wrapper and the 1_21_R1 wrapper, but not the 1_20_R4 wrapper or any other version I could find. For reference, here is the mapping history, you can search for "doCloseContainer" to find all the changes.

So basically, before this fix, on specifically Minecraft 1.20.3, 1.20.4 and 1.21, closeContainer was called instead of doCloseContainer, which caused the close event to be fired twice instead of once.

WesJD commented 2 months ago

Amazing work. Could you increment the patch version and we can merge.