Ladysnake / PlayerAbilityLib

It's your new pal!
GNU Lesser General Public License v3.0
13 stars 8 forks source link

Show Icon for effect? #26

Open drkhodakarami opened 1 week ago

drkhodakarami commented 1 week ago

Hi When I use this code : source.grantTo(player, VanillaAbilities.ALLOW_FLYING); How can I show the flight effect icon? I have an icon in textures/mob_effect/ This texture has the same name as the identifier used for registering the effect but when I equip the item and get the ability to flight, the icon is not showing. How can I show the icon when granting the effect?

Pyrofab commented 1 week ago

Did you actually make a mob effect for this ? Because PAL does not display anything by itself.

drkhodakarami commented 1 week ago

Did you actually make a mob effect for this ? Because PAL does not display anything by itself.

Thanks for the fast reply. I solved the issue. It would be nice to have this in some example available for future: 1- I created the FlightEffect class as provided in the example mod 2- I created the StatusEffect in the ModEffects as RegistryEntry but didn't initialize it inline. 3- I register the effect in the register method of ModEffects using Registry.registerReference (not Registery.register) 3- I used the ServerEntityEvents.EQUIPMENT_CHANGE 4- In the event subscription, now I simply create a new StatusEffectInstance and assign or remove the effect as needed.

it works without a problem. The key difference compared to the provided mod example is the usage of RegistryEntry and using the registerReference here.

Pyrofab commented 1 week ago

Ah well, sounds like the readme is not quite up to date with the latest Minecraft version. Feel free to make a pull request, otherwise I will update it whenever I update the library I guess.