Closed GoldenStack closed 8 months ago
Seems interesting I will try to review tomorrow
I remain a bit unconvinced about switching to protocol slots. Being able to iterate over the inner inventory slots and get just the inventory is a pretty useful property in some cases.
i probably don't understand what you're saying but im pretty sure this PR doesn't impede that?
Also, you mention that special slots are not implemented. I think this is fine, but it would be nice to have a little documentation of what the path is to implement those post-this PR. They will have to be implemented at some point, so I would like to ensure it is possible after this PR without another major change.
:+1:
I need to think a bit about removing
InventoryCondition
. I have used it successfully a few times and want to confirm in my head that I agree its redundant.
You can replace InventoryCondition with a InventoryClickEvent handler (they can do the exact same stuff), and you can use the event filters to make sure it's the right inventory.
Regarding protocol slots, the following code snippet (currently) will return the items in the players hotbar and 3 rows of inventory:
for (int i = 0; i < PlayerInventory.INNER_INVENTORY_SIZE; i++) {
var item = player.getInventory().getItemStack(i);
}
After this PR, it will return the crafting grid, armor slots, and 3 rows of inventory.
Generally I believe the protocol slots make no sense and the remapping that Minestom currently does is a significant improvement. Also not unprecedented, spigot also remaps slots (although with a significantly stranger mapping).
that's a fair point. Though I feel like this now puts the spotlight on the fact that accessing specific inventory regions is quite annoying, regardless of how player inventory slot IDs are assigned.
I would suggest features similar to something out of my library Window (that allows you to do stuff like Views120.player().contents()
instead of raw slot IDs) but I think they feel a bit too much like a utility, rather than something that would actually be included in base Minestom. What do you think about this?
Otherwise I can just re-add the inventory mappings.
Ill look some more later.
P.S. tests are failing
Rework of the Inventory system.
Main changes:
Notes:
Changes: