Solved Player#SetFireTicks(0) not working

Discussion in 'Spigot Plugin Development' started by SirLich, Jul 4, 2018.

  1. Hey guys!
    I have an issue where I can't seem to extinguish player fire. Like at all. No effect. Here is my method:
    Code (Text):

    public void clearAllEffect(){
        Player player = this.getPlayer();
        player.setHealth(20);
        player.setFoodLevel(20);
        player.setFireTicks(0);
        player.getActivePotionEffects().clear();
    }
     
    The other items in this method (like setting health) are being done. Its just the fire-ticks that aren't working. Help?
     
  2. ScarabCoder

    ScarabCoder Retired Resource Staff
    Retired

    That's probably not supposed to happen.
    What version of Spigot are you using?
    Have you tried setting it to something other than zero?
    Can you try getting the fire ticks afterwards in case something may be setting the player on fire immediately after?
     
  3. In my experience, setting FireTicks to 0 causes it to switch to -1 at the end of the tick, and the fire does not extinguish. Try setting it to 1 and see if the problem persists.
     
  4. Adding the line:
    Code (Text):

    System.out.println(player.getFireTicks());
     
    Prints out 0 when the method is run. I have no idea whats going on....
    I might just set the block under the player to water for 1 tick. Which would be obnoxious but...
     
  5. Values I have tried: 0, 1, 3. Each time, the correct value is printed out using a getFireTicks call, and each time the fire continues for quite a few seconds.

    Possible reasons:
    Would teleporting the player quickly after have something to do with this?
    Would the fact that I used a saved player object have anything to do with it? (the player object IS correct in the sense that #setHealth works)
     
  6. A block update should be unnecessary, giving them a potion effect of fire resistance without particles for a few ticks would be far less resource intensive, and wouldn't interrupt the player's movement.
    The reason this had happened for me in the past was because the player's fireticks were set in the same tick as teleporting them, meaning they were still in the lava (which is why I was setting the fire tick myself). Because of that, the lava immediately reset their fireticks the next tick, even if they were teleported. Could you try delaying the firetick setting until after they have been teleported by a tick or two?
     
    • Informative Informative x 1
  7. Just schedule it on next tick.
     
    • Useful Useful x 1
  8. Solved!
    Duh! I should have realized the player was still in the lava!
    Many thank!