Potion times don't correspond to ticks

Discussion in 'Spigot Plugin Development' started by xBallisticBlazex, Jul 20, 2017.

  1. Hi.
    I have been trying to apply potion effect times but they don't correspond to ticks!
    Code (Text):
     hurt.addPotionEffect(PotionEffectType.POISON.createEffect(duration[i] * 20, 0));
            System.out.println(duration[i] * 20);
    The system out prints 100, but the potion effect doesn't last 5 seconds! I've noticed when I set the ticks to 800 I get 9 seconds but I have no idea where to go from here. Any help is appreciated.
    #1 xBallisticBlazex, Jul 20, 2017
    Last edited: Jul 20, 2017
    • Like Like x 1
  2. I dont know where your error could be. did you try to calculate the duration before you use it?

    Thats quite confusing... 800 ticks should be 40 seconds... not 9
  3. Actually when you set a tick to a potion effect for example 100 it lasts 4 seconds and not five and you set it to 120, You probably might doing something wrong. Or something might cause this in your full code.
    Try changing to:
    Code (Text):
    hurt.addPotionEffect(new PotionEffect(PotionEffectType.POISON, <time>, <level>));
  4. He already wrote this dude. I dont see any error there. Dont know why
    this doesnt work..
  5. Well if i use it right now it will work fine for me
  6. Thanks for the replies, I'm firing this code in the entity damage by entity event. Would that make a difference? I don't understand what's wrong...
  7. Try actually creating a new instance of the PotionType that works for me. Also when working with potions even though 100 ticks says 4 seconds it's still 5 because I think they count 0 I'm not sure though