Stopping items from being destroyed by explosions

Discussion in 'Plugin Development' started by Intangir, Aug 26, 2014.

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

    Intangir

    I don't know how it didn't seem to get noticed before, but it seems like far more regularly, dropped items are being destroyed by TNT or creepers

    so i did some checking and noticed that explosions blow up any nearby items..

    i really want to disable this but i can't seem to figure out how

    it doesn't fire an EntityDamageEvent or EntityCombustEvent

    ItemDespawnEvent is for something else

    there doesn't seem to be any event type for ItemDestroyedEvent

    im surprised more people don't seem to be complaining about this, if two creepers blow up at the same time for example, people are losing all of their stuff

    also on my server we have enhanced explosions which sets off multiple explosions at once (used to not cause a problem now suddenly it is destroying everything that is blown up, even the drops, even player drops if people die)


    need a way to prevent dropped items from getting blown up, if it also protects them from burning, or melting in lava too, that would be a nice bonus
     
  2. Offline

    _LB

    Tried EntityDamageByEntity?
     
  3. Offline

    Intangir

    Ya i tried every relevant sounding event

    right now im rigging up some NMS sort of thing to try and do it

    bukkit doesn't seem to provide an event for this

    heres how i did it, everything is included in this git change
    a couple other minor irrelevant things but you can see the important bits in the Tweak changes, and the Protect changes

    basically it sets an internal flag that is apparently checked before and item is destroyed, which makes it invulnerable, its not exposed by the API, but you can manage with access to some craftbukkit methods, and net.minecraft.server variables using the java reflection api


    https://github.com/intangir/Tweaks/commit/dd60d05b7e8e3ea501515be0197f2bd6c58c7bd1

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 10, 2016
Thread Status:
Not open for further replies.

Share This Page