Prevent damage to "Item" entity

Discussion in 'Plugin Development' started by EvilWitchdoctor, Nov 16, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    EvilWitchdoctor

    Alright, so firstly I'm going to just going to prepare you- this is a compound question.

    Basically, as part of a plugin I'm building, I need an item(s) that is invulnerable to it's surrounding conditions.
    This includes:
    fire, lava, cactus, void-falling, (and is it possible for dropped items to "suffocate"?)
    So far I've got things mostly figured out, but I'm still tied over how to prevent lava damage and cactus damage.

    EDIT: And yes, I've researched this a lot. And I'd prefer a better fix then the one in this thread: https://forums.bukkit.org/threads/how-to-keep-a-dropped-item-from-burning-burning.193971/
     
  2. Offline

    xTigerRebornx

    EvilWitchdoctor likes this.
  3. Offline

    TheCodingCat

    cant you just listen for entity death event, check if it as instance of an item and cancel the event? When items "die" I''m pretty sure they call this event
    EDIT: I forgot you can't cancel this event :p In that case listen to EntityDamageEvent and check if it will kill the item and THEN cancel the event
     
  4. Offline

    EvilWitchdoctor

    TheCodingCat EntityDamageEvent was my first thought as well, but unfortunately that event is not fired for dropped items.
    Code:java
    1. @EventHandler
    2. public void onEntityDamageEvent(EntityDamageEvent evt){
    3. if(evt.getEntity() instanceof Item) getLogger().info("item");
    4. }

    Never actually gets fired. It was a good idea though ;)

    xTigerRebornx That's actually a really great idea, I think I'll just store the item somewhere in memory and send a packet of a fake dropped item. Thank you so much for the insight. Still, it would be nice if there was a way to accomplish the same without using NMS, but ah well..
     
  5. Offline

    xTigerRebornx

    EvilWitchdoctor Considering there may not be future updates to the NMS versioning, the need to avoid using it isn't as heavy. You can do some extremely powerful things with NMS compared to the API, and updating it isn't that much of a challenge considering there may not be many updates.
     
Thread Status:
Not open for further replies.

Share This Page