[SPIGOT-2623] Add methods that accept the EquipmentSlot enum Created: 23/Aug/16 Updated: 13/Jun/20 Resolved: 13/Jun/20 |
|
| Status: | Resolved |
| Project: | Spigot |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Minor |
| Reporter: | zombachu | Assignee: | Unassigned |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | EquipmentSlot, inventory | ||
| Description |
|
I think that it would be convenient to have EquipmentSlot versions of Inventory#clear(int), Inventory#getItem(int), Inventory#setItem(int), etc. Alternatively (or additionally), being able to get the slot index from an EquipmentSlot would be useful, though the use of EquipmentSlots in armor stands might be an issue (don't know enough about armor stands to comment on this). Another addition that would be cool to have would be something like setSlot(EquipmentSlot, ItemStack) in PlayerInventory, EntityEquipment, ArmorStand, etc. |
| Comments |
| Comment by Phoenix616 [ 17/May/19 ] |
|
Should be doable using EntityEquipment now as all Entities with equipment should have the same types of slots. |
| Comment by zombachu [ 27/Aug/16 ] |
|
@Hex You're right that it wouldn't make sense for it to be implemented in Inventory itself. I should've made it clearer what I meant: I was referring to Inventory's clear, getItem, and setItem methods (which PlayerInventory extends) only as examples of methods that have a slot index as a parameter that also would make sense to accept EquipmentSlot. Like you said, the code itself should be located in PlayerInventory. As for convolution, CraftInventoryPlayer already does some mapping to indexes with the methods that it implements from EntityEquipment (the getters and setters for the equipment itself, for example) and CraftEntityEquipment actually directly uses the NMS version of EqupmentSlot, EnumItemSlot. As I was writing this reply I realized that I forgot to ask for getSlot in those interfaces I mentioned at the bottom, and just thought of being able to get/set drop chances with an EquipmentSlot as well. Hopefully whoever reviews this issue sees this comment as well. Sorry! |
| Comment by Hex [ 27/Aug/16 ] |
|
The issue is that not all inventories have the slots that an EquipmentSlot would refer to. If it's just in PlayerInventory than it'd probably work. This would also mean that the inventory handler would have to map enum values to an integer value, which adds another layer of convolution. |