Skip to content

Fix a bug where a CustomInventory cannot handle inventory events#1544

Merged
Zidane merged 1 commit into
SpongePowered:bleedingfrom
ustc-zzzz:bleeding
Oct 20, 2017
Merged

Fix a bug where a CustomInventory cannot handle inventory events#1544
Zidane merged 1 commit into
SpongePowered:bleedingfrom
ustc-zzzz:bleeding

Conversation

@ustc-zzzz
Copy link
Copy Markdown
Contributor

@ustc-zzzz ustc-zzzz commented Sep 29, 2017

In the old version of the implementation, the CustomInventoryListener checks if the target inventory is CustomContainer. However, a CustomInventory does not always create a CustomContainer as its container (See CustomInventory.java), and the condition will usually return false, then the events won't be fired.

There is a new way to detect if the target container does contain our custom inventory. All of the slots will be iterated, and if one of the slots belongs to our inventory, all of those related events will be fired and everything works well.

I'm the author of a chest menu plugin (ustc-zzzz/VirtualChest), and I'm trying to port my plugin to 1.12.x. It was not working until I made this commit and built a new jar for testing.

@kashike kashike added system: inventory type: bug Something isn't working labels Sep 29, 2017
@Zidane Zidane merged commit b22c02d into SpongePowered:bleeding Oct 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

system: inventory type: bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants