Extinguishing a Burning Player

Discussion in 'Plugin Development' started by Timberjaw, Feb 2, 2011.

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

    Timberjaw

    I'm trying to figure out how to extinguish a burning player. There doesn't seem to be a Bukkit-friendly way to do it. The Ignite plugin appears to be getting the root entity handle via a CraftEntity cast and then modifying the fireTicks value directly.

    When I try this, however, the fire is not put out. Setting fireTicks to a new value appears to have no effect on the actual duration of the fire, and once the burn damage stops, the fire effect is stuck in the client view (just the visual) until reconnect.

    Code:
    // Extinguish player if they are burning
    CraftEntity ce = (CraftEntity)p;
    if(ce.getHandle().fireTicks > 0)
    {
        SpawnControl.log.info("FireTicks: " + ce.getHandle().fireTicks + " | MaxFireTicks: "+ce.getHandle().maxFireTicks);
        ce.getHandle().fireTicks = 0;
        ce.getHandle().maxFireTicks = 1;
    }
    Note that the handle seems to be ok. I can check the fireTicks value (seems to be 300 or 600 at time of death, -20 otherwise). I've tried various combinations of 0, -20, 1, etc. After setting the value, the entity shows the correct updated value, but the player continues to take damage and the fire effect doesn't go away.

    Any suggestions? I hope I'm just making this way harder than it needs to be.
     
  2. Offline

    xpansive

    Your code works perfectly for me.
    I don't think you even need to set maxFireTicks.

    Edit: In fact, all you really need is p.getHandle().fireTicks = 0;
     
  3. Offline

    Timberjaw

    @xpansive
    I must be doing something else wrong then. Basically, I'm jumping into a lava pit, and at the moment when I would normally die, I have it cancel the last damage event and teleport them away. Right after the teleport, I set fireTicks. I just continue to burn though.

    Tried it using CraftPlayer (p was actually a Player instance in this case, which doesn't have getHandle) with the same result. The weird client glitch doesn't seem to happen if I'm not messing with maxFireTicks.

    Maybe the warp is too slow and I'm just catching fire again in the transition.
     
Thread Status:
Not open for further replies.

Share This Page