Add potion constructor without flags, style

This commit is contained in:
themode 2021-12-20 17:30:01 +01:00 committed by TheMode
parent 064146b4fd
commit 74e00bc70c

View File

@ -8,8 +8,8 @@ import net.minestom.server.utils.binary.BinaryWriter;
import net.minestom.server.utils.binary.Writeable; import net.minestom.server.utils.binary.Writeable;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public record Potion(PotionEffect effect, byte amplifier, int duration, byte flags) public record Potion(@NotNull PotionEffect effect, byte amplifier,
implements Writeable { int duration, byte flags) implements Writeable {
/** /**
* A flag indicating that this Potion is ambient (it came from a beacon). * A flag indicating that this Potion is ambient (it came from a beacon).
* *
@ -37,6 +37,10 @@ public record Potion(PotionEffect effect, byte amplifier, int duration, byte fla
*/ */
public static final byte ICON_FLAG = 0x04; public static final byte ICON_FLAG = 0x04;
public Potion(@NotNull PotionEffect effect, byte amplifier, int duration) {
this(effect, amplifier, duration, (byte) 0);
}
public Potion(BinaryReader reader) { public Potion(BinaryReader reader) {
this(PotionEffect.fromId(reader.readVarInt()), reader.readByte(), this(PotionEffect.fromId(reader.readVarInt()), reader.readByte(),
reader.readVarInt(), reader.readByte()); reader.readVarInt(), reader.readByte());
@ -56,6 +60,7 @@ public record Potion(PotionEffect effect, byte amplifier, int duration, byte fla
/** /**
* Returns whether this Potion is ambient (it came from a beacon) or not. * Returns whether this Potion is ambient (it came from a beacon) or not.
*
* @return <code>true</code> if the Potion is ambient * @return <code>true</code> if the Potion is ambient
*/ */
public boolean isAmbient() { public boolean isAmbient() {
@ -64,6 +69,7 @@ public record Potion(PotionEffect effect, byte amplifier, int duration, byte fla
/** /**
* Returns whether this Potion has particles or not. * Returns whether this Potion has particles or not.
*
* @return <code>true</code> if the Potion has particles * @return <code>true</code> if the Potion has particles
*/ */
public boolean hasParticles() { public boolean hasParticles() {
@ -72,6 +78,7 @@ public record Potion(PotionEffect effect, byte amplifier, int duration, byte fla
/** /**
* Returns whether this Potion has an icon or not. * Returns whether this Potion has an icon or not.
*
* @return <code>true</code> if the Potion has an icon * @return <code>true</code> if the Potion has an icon
*/ */
public boolean hasIcon() { public boolean hasIcon() {