mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-28 12:07:42 +01:00
Add Potion flags (#536)
* Add Potion flags * fix wrong value * i blame my keyboard * Add methods for the flags
This commit is contained in:
parent
74aceda0ad
commit
e3f08fb6d5
@ -10,11 +10,74 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
public record Potion(PotionEffect effect, byte amplifier, int duration, byte flags)
|
public record Potion(PotionEffect effect, byte amplifier, int duration, byte flags)
|
||||||
implements Writeable {
|
implements Writeable {
|
||||||
|
/**
|
||||||
|
* A flag indicating that this Potion is ambient (it came from a beacon).
|
||||||
|
*
|
||||||
|
* @see #PARTICLES_FLAG
|
||||||
|
* @see #ICON_FLAG
|
||||||
|
* @see #flags()
|
||||||
|
*/
|
||||||
|
public static final byte AMBIENT_FLAG = 0x01;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A flag indicating that this Potion has particles.
|
||||||
|
*
|
||||||
|
* @see #AMBIENT_FLAG
|
||||||
|
* @see #ICON_FLAG
|
||||||
|
* @see #flags()
|
||||||
|
*/
|
||||||
|
public static final byte PARTICLES_FLAG = 0x02;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A flag indicating that this Potion has an icon.
|
||||||
|
*
|
||||||
|
* @see #AMBIENT_FLAG
|
||||||
|
* @see #PARTICLES_FLAG
|
||||||
|
* @see #flags()
|
||||||
|
*/
|
||||||
|
public static final byte ICON_FLAG = 0x04;
|
||||||
|
|
||||||
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());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the flags that this Potion has.
|
||||||
|
*
|
||||||
|
* @see #AMBIENT_FLAG
|
||||||
|
* @see #PARTICLES_FLAG
|
||||||
|
* @see #ICON_FLAG
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public byte flags() {
|
||||||
|
return flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether this Potion is ambient (it came from a beacon) or not.
|
||||||
|
* @return <code>true</code> if the Potion is ambient
|
||||||
|
*/
|
||||||
|
public boolean isAmbient() {
|
||||||
|
return (flags & AMBIENT_FLAG) == AMBIENT_FLAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether this Potion has particles or not.
|
||||||
|
* @return <code>true</code> if the Potion has particles
|
||||||
|
*/
|
||||||
|
public boolean hasParticles() {
|
||||||
|
return (flags & PARTICLES_FLAG) == PARTICLES_FLAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether this Potion has an icon or not.
|
||||||
|
* @return <code>true</code> if the Potion has an icon
|
||||||
|
*/
|
||||||
|
public boolean hasIcon() {
|
||||||
|
return (flags & ICON_FLAG) == ICON_FLAG;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a packet that a potion effect has been applied to the entity.
|
* Sends a packet that a potion effect has been applied to the entity.
|
||||||
* <p>
|
* <p>
|
||||||
|
Loading…
Reference in New Issue
Block a user