I was wondering how do i query for equipment slots in an inventory.
I currently have :
Inventory inv = player.getInventory().query(EquipmentSlot.class); inv.set(itemStack);
And this will set the item stack into the Boots slot but how do I query for a specific slot. I have tried adding .query(new EquipmentSlotType(EquipmentTypes.HEADWEAR)
but this doesn’t work
I also know that setHelmet(ItemStack) exist but that’s not what I am looking for.
EDIT:
I have also tried .query(new ArmorSlotType(EquipmentTypes.CHESTPLATE) this also doesn’t work
As far as I’m aware, getHelmet
and setHelmet
, and the getters/setters for all the other armors, in ArmorEquipable, are the easiest way to do this. Why are these not what you’re looking for?
Because rather than returning an optional itemstack I want the inventory (or in this case the slot)
Ahh… then I’d suggest looking through mumfey’s original PR, or even trying to get @mumfrey to answer this question himself.
I have had a quick look through but cannot seem to find how to fix my issue
I think I may have found a solution.
Try querying for EquipmentInventory
instead:
Inventory inv = player.getInventory().query(EquipmentInventory.class);
if(inv instanceof EqupmentInventory) { //Make sure its not an EmptyInventory
EquipmentInventory einv = (EquipmentInventory) inv;
Inventory headSlot = einv.getSlot(new EquipmentSlotType(EquipmentTypes.HEADWEAR));
}
After querying and casting EquipmentInventory, you can use its getSlot
methods to to what you need.
Annoyingly that didn’t work either
Doing player.getInventory().query(EquipmentInventory.class) returns an EmptyInventory (i presume)
Querying for the equipment type or equipment inventory is correct, it’s just not implemented yet. You’ll have to wait around or find an alternative way until inventory implementation is complete.
2 Likes
Just curious, no rush intended, but is this being considered to be implemented anytime soon?