stop lava from killing items

Discussion in 'Spigot Plugin Development' started by Creepermanthe3rd, Apr 24, 2017.

  1. Help! ^Title how do I stop lava from burning the items.
     
  2. I'm not at my computer but check for me if there is a entity damage event? Or entity destroy event? Cause if there is you could try cancelling the damage?
     
    • Agree Agree x 2
  3. The events all worked I tested with debugging but e.setCancled didnt stop the item from burning. Any other solutions
     
  4. Cast the entity of the event to an Item, and drop that Item's ItemStack wherever you want the item to go.

    I'm not entirely sure what you're trying to achieve - do you want the item to just sit on top of the lava rather than being destroyed by it?
    Because if you can't cancel the event, you'll have have to keep respawning the item until a player (somehow) picks it up.
     
  5. Im recreating a plugin similar to CosmicPvP's where Lava does not destory Mob spawners.
     
  6. maldahleh

    Wiki Team

    Does lava even destroy mob spawners in the first place?
     
    • Optimistic Optimistic x 1
  7. Lava destorys every dropable item
     
  8. It kills any item when dropped*

    Send us your current code, I think i know what the problem is
     
    • Agree Agree x 1
  9. Doing this is more complex than using event.setCancelled().
    Minecraft won't stop destroying items that fall in lava.
    In order to make this work you should create a new Field for exemple Field isInvulnerableItem;

    And also take into account that you only want items not to be burned when there's an explosion event involved.
    Use also ItemSpawnEvent to spawn again the items that were protected from invulnerability.
     
  10. C-can't we just make the Item entity invulnerable? Isn't that a thing anymore?
    I used to do this back when I played with just commandblocks, but I admit I've never tried with Spigot.
     
  11. NathanWolf

    Supporter

    Yes, that works. Though I think it may not work with lava.. not sure. I do both- on item spawn, set the Item entity to invulnerable, but also catch damage events and cancel them. Seems to work for me.
     
    • Informative Informative x 1