Add a method on InventoryView to get the MenuType#12193
Conversation
Y2Kwastaken
left a comment
There was a problem hiding this comment.
In order to ensure the API functions properly, some adjustments are needed. I’ve tested it, and currently, the API throws an error for any menu that doesn’t have a MenuType. This is an issue in scenarios like the player’s inventory or with animals, where a MenuType is not applicable. In these cases, it results in an UnsupportedOperationException. If you’re aiming for this to be merged, I’d recommend modifying the behavior to return null instead of throwing the exception. Otherwise, everything else seems fine. I'm not in love with the CraftContainer impl, but I think its pretty much unavoidable at this point sadly.
@Y2Kwastaken does it also throw in |
The naive conversion for Inventory's is fine and won't throw that exception to see why its thrown see AbstractContainerMenu#getType. This goes back to what I explained earlier where not every Menu has a MenuType sadly. |
Y2Kwastaken
left a comment
There was a problem hiding this comment.
This is a lot better thank you, From my testing it works as you'd expect.
It is possible to get the
InventoryType, but notMenuType.Since there is a new (better) way to create views for players using
MenuType, it would be nice to also be able to get it back fromInventoryViewafter creating.