Trinkets (Fabric)

Trinkets (Fabric)

22M Downloads

Reference equipped stack

JessClark2755 opened this issue ยท 1 comments

commented

Hi! I'm trying to make a ring that loses durability over time if the player is wearing it. How do I reference the ring in the player's equipment slot in order to do this?

If I were depleting a helmet over time I would use this in the TrinketItem tick method: entity.getEquippedStack(EquipmentSlot.byName("head"), but if I replace "head" with "ring", "hand", or "hand/ring", it won't work. What should I do instead to reference a trinket slot?

commented

Hi, this is a vanilla method to get slots, in trinkets you can get slots from a trinket component which you can get by calling TrinketsApi.getTrinketComponent() which returns an optional you should check. in a trinket component there is the getInventory() method which returns a map of slot groups and a map of slots in these groups. In general the trinkets api and trinket components will have everything you need.