Prevent item burning in lava

Discussion in 'Plugin Development' started by matejdro, Jul 30, 2011.

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

    matejdro

    Is there any way to prevent item from burning when item falls into lava?

    I have tried canceling onEntityDamage, but it does not seem to work.
     
  2. EntityCombust is what you are looking for, even though the reference only talks about mobs, it also works for item-entities.
     
  3. Offline

    matejdro

    Tried canceling it, but it does not work (item still get destroyed). Event indeed fires (tested by printing a line into a console), but canceling it does not do anything.
     
  4. Well, I believe "combusting" in this case is just the item being set on fire (which it is if you look closely before it actually disappears). Being destroyed by lava probably isn't handled by that.
    I didn't test it, though, but it seems logically to me.

    For a solution you would probably have to do a workaround (you do at least know when it happens), I can help you if you provide information about what you are trying to accomplish.
     
  5. Offline

    matejdro

    When item falls into specified lava block, it should survive. I have location detection already made and It's working well on players.
     
  6. Offline

    matejdro

    bump. Any other ideas, what would destroy item in lava and how to prevent it?
     
  7. Offline

    Baummann

    Code:java
    1. public void onEntityDamage(EntityDamageEvent event) {
    2. Entity e = event.getEntity();
    3. if (e instanceof Item) {
    4. if (event.getDamageCause() == DamageCause.LAVA) {
    5. event.setCancelled(true);
    6. }
    7. }
    8. }


    I'm not sure if it works but give it a try ;)
     
  8. Offline

    matejdro

    I even did this:

    Code:java
    1. public void onEntityDamage(EntityDamageEvent event) {
    2. event.setCancelled(true);
    3. }


    and it did not work. But code itself works, i did not receive damage.
     
  9. Offline

    OblivionFan

    Question: Even if you do this,and the item doesn't burn in lava, what are you going to do? Dive after it?
     
  10. Haha :p If you're desperate.
     
  11. Offline

    OblivionFan

    I'm coming for you,my precioussss...
    BTW,i love your HUGE plugin tutorial!
     
  12. Thanks, I don't play Minecraft that much but I hear diamonds etc are very precious :D
     
  13. Offline

    matejdro

    I'm trying to use lava as "orange liquid" in my plugin, so every damage to these lava blocks would be canceled.
     
  14. Offline

    OblivionFan

    So you don't want to disable only the item,but players too?
     
  15. Offline

    matejdro

    Players are already working, so I'm only looking for a way to disable items.
     
  16. Offline

    RawCode

    protected void burn(int i) {
    this.damageEntity((Entity) null, i);
    }

    public boolean damageEntity(Entity entity, int i) {
    this.af();
    this.f -= i;
    if (this.f <= 0) {
    this.die();
    }

    return false;
    }


    Sorry, no bukkit event for this, ever if you cancel damage item will burn anyway.
     
  17. Offline

    matejdro

    Alright then, i have already changed it to water. It's not orange, but better than nothing :)
     
Thread Status:
Not open for further replies.

Share This Page