Fix effect command giving 20 times as much duration

This commit is contained in:
Marcel Konrad
2019-02-26 17:04:48 +01:00
parent 47900ac9b4
commit eafef4ae54
3 changed files with 17 additions and 7 deletions

View File

@@ -36,7 +36,7 @@ public abstract class ComponentPotion implements IBuilderComponent
compound.setByte("Id", (byte) Potion.getIdFromPotion(entry.getKey()));
compound.setByte("Amplifier", (byte) (potion.getAmplifier() - 1));
compound.setInteger("Duration", potion.getDuration() > 0 ? Math.min(potion.getDuration(), 1000000) : 1000000);
compound.setInteger("Duration", potion.getDurationTicks() > 0 ? Math.min(potion.getDurationTicks(), 1000000) : 1000000);
compound.setBoolean("Ambient", potion.getAmbient());
compound.setBoolean("ShowParticles", potion.getShowParticles());

View File

@@ -88,16 +88,26 @@ public class PotionMetadata
this.ambient = ambient;
}
public int getDuration()
public int getDurationTicks()
{
return PotionMetadata.getDuration(this.seconds, this.minutes, this.hours);
return PotionMetadata.getDurationTicks(this.seconds, this.minutes, this.hours);
}
public static int getDuration(int seconds, int minutes, int hours)
public int getDurationSeconds()
{
return PotionMetadata.getDurationSeconds(this.seconds, this.minutes, this.hours);
}
public static int getDurationTicks(int seconds, int minutes, int hours)
{
return seconds * 20 + minutes * 1200 + hours * 72000;
}
public static int getDurationSeconds(int seconds, int minutes, int hours)
{
return seconds + minutes * 60 + hours * 3600;
}
public PotionMetadata withAmplifier(byte amplifier)
{
this.amplifier = amplifier;

View File

@@ -108,7 +108,7 @@ public class BuilderPotionEffect extends CommandBuilder
public void setSeconds(int seconds)
{
this.seconds = seconds;
this.setDuration(PotionMetadata.getDuration(this.seconds, this.minutes, this.hours));
this.setDuration(PotionMetadata.getDurationSeconds(this.seconds, this.minutes, this.hours));
}
public int getMinutes()
@@ -119,7 +119,7 @@ public class BuilderPotionEffect extends CommandBuilder
public void setMinutes(int minutes)
{
this.minutes = minutes;
this.setDuration(PotionMetadata.getDuration(this.seconds, this.minutes, this.hours));
this.setDuration(PotionMetadata.getDurationSeconds(this.seconds, this.minutes, this.hours));
}
public int getHours()
@@ -130,7 +130,7 @@ public class BuilderPotionEffect extends CommandBuilder
public void setHours(int hours)
{
this.hours = hours;
this.setDuration(PotionMetadata.getDuration(this.seconds, this.minutes, this.hours));
this.setDuration(PotionMetadata.getDurationSeconds(this.seconds, this.minutes, this.hours));
}
public BuilderGeneric getRemoveCommand()