Bug onPlayerEventInventoryAdd when cancel event when pickup a small animal?

A new update (0.9.2) is available now!
Latest Hotfix: 0.9.2.1 (2026-05-12)
  • Hi


    If i cancel event PlayerInventoryAddItemEvent when i try to pickup a small animal, it's normal to animal got removed from world, even if i cancel event and in inventory not get Item of category NPC?


    Thx.


    Bamse

  • Yeah, unfortunately cancelling the PlayerInventoryAddItemEvent only prevents the item from being added to the inventory :| AFAIK this is always the case (e.g also when collecting plants, digging up ores etc)... maybe it's something I could change, but I'm afraid this won't work in all cases (e.g when digging terrain or ores, the items are added after modifying the world, because that's when the game actually knows how many items should be added to the inventory).


    However, when picking up baby animals, it should work to listen to the PlayerNpcInteractionEvent. Unfortunately this event does not provide much information... maybe it wouldn't be a bad thing to have a new event for this?


    What kind of information do you need (or what are you trying to achieve)?^^

  • I Use this code in my Admin Plugin, and it works fine:


    Maybe it'll help you

  • I tried to prevent baby animals pickup on some conditions, But i already solved with PlayerNpcInteractionEvent!


  • Thx Devidian for another posibility. But your code don't stop interaction with any animals, not just pickable? But i think that is ok because i don't see a use of interaction with animals beside pickup, yet.

    yes because my plugin checks only area and user permissions, goal is that no stranger can do any interaction with animals on a players property. In the wilderness no checks are made

Participate now!

Don’t have an account yet? Create a new account now and be part of our community!