Fixed potion effect restoring wrong time

This commit is contained in:
isokissa3 2018-04-12 23:24:02 +03:00
parent 75be12e7db
commit f2e1dc8f61
2 changed files with 4 additions and 4 deletions

View file

@ -16,13 +16,13 @@ public class PotionEffectDetails
@Getter private final boolean particles; @Getter private final boolean particles;
@Getter private final Color color; @Getter private final Color color;
public double getTimeLeft() public long getTimeLeft()
{ {
return (this.endTime - System.nanoTime()) / TimeUnit.MICROSECONDS.toNanos(50L); return (this.endTime - System.nanoTime());
} }
public int getTimeLeftInTicks() public int getTimeLeftInTicks()
{ {
return (int)(this.getTimeLeft() / 0.05); return (int)(this.getTimeLeft() / TimeUnit.MILLISECONDS.toNanos(50L));
} }
} }

View file

@ -88,7 +88,7 @@ public class GiveEffectsFlagHandler extends Handler
if (this.givenEffects.add(effect.getType()) && effect_ != null) if (this.givenEffects.add(effect.getType()) && effect_ != null)
{ {
this.removedEffects.put(effect_.getType(), new PotionEffectDetails(System.nanoTime() + (long)(effect.getDuration() / 20D * TimeUnit.SECONDS.toNanos(1L)), effect_.getAmplifier(), effect_.isAmbient(), effect_.hasParticles(), SupportedFeatures.isMobEffectColorsSupported() ? effect_.getColor() : null)); this.removedEffects.put(effect_.getType(), new PotionEffectDetails(System.nanoTime() + (long)(effect_.getDuration() / 20D * TimeUnit.SECONDS.toNanos(1L)), effect_.getAmplifier(), effect_.isAmbient(), effect_.hasParticles(), SupportedFeatures.isMobEffectColorsSupported() ? effect_.getColor() : null));
player.removePotionEffect(effect_.getType()); player.removePotionEffect(effect_.getType());
} }