mirror of
https://github.com/Minestom/Minestom.git
synced 2025-02-11 09:51:35 +01:00
Rewritten all EntityMeta classes to use MetadataDef (#2471)
* Rewritten all EntityMeta classes to use MetadataDef * fix MetadataHolder.set * remove getIndex and setIndex from SheepMeta * MetadataDef.Wolf.VARIANT * removed MetadataHolder.getIndex and MetadataHolder.setIndex * Added "FLAGS" to all MetadataDef with flags * made bitMask byte instead of int * renamed ALIGNMENT_LEFT and ALIGNMENT_RIGHT to ALIGN_LEFT and ALIGN_RIGHT * ByteMask type and fixed Sheep.COLOR_ID
This commit is contained in:
parent
de83afc8d8
commit
f4b32eddcf
@ -5,9 +5,11 @@ import net.kyori.adventure.nbt.CompoundBinaryTag;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minestom.server.coordinate.Point;
|
||||
import net.minestom.server.coordinate.Vec;
|
||||
import net.minestom.server.entity.metadata.animal.ArmadilloMeta;
|
||||
import net.minestom.server.entity.metadata.animal.FrogMeta;
|
||||
import net.minestom.server.entity.metadata.animal.SnifferMeta;
|
||||
import net.minestom.server.entity.metadata.animal.tameable.CatMeta;
|
||||
import net.minestom.server.entity.metadata.animal.tameable.WolfMeta;
|
||||
import net.minestom.server.entity.metadata.other.PaintingMeta;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
@ -16,11 +18,11 @@ import net.minestom.server.registry.DynamicRegistry;
|
||||
import net.minestom.server.utils.Direction;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
|
||||
import static net.minestom.server.entity.MetadataDefImpl.index;
|
||||
import static net.minestom.server.entity.MetadataDefImpl.mask;
|
||||
import static net.minestom.server.entity.MetadataDefImpl.*;
|
||||
|
||||
/**
|
||||
* List of all entity metadata.
|
||||
@ -29,14 +31,15 @@ import static net.minestom.server.entity.MetadataDefImpl.mask;
|
||||
*/
|
||||
@SuppressWarnings({"unused", "SpellCheckingInspection"})
|
||||
public sealed class MetadataDef {
|
||||
public static final Entry<Boolean> IS_ON_FIRE = mask(0, 0x01, false);
|
||||
public static final Entry<Boolean> IS_CROUCHING = mask(0, 0x02, false);
|
||||
public static final Entry<Boolean> UNUSED_RIDING = mask(0, 0x04, false);
|
||||
public static final Entry<Boolean> IS_SPRINTING = mask(0, 0x08, false);
|
||||
public static final Entry<Boolean> IS_SWIMMING = mask(0, 0x10, false);
|
||||
public static final Entry<Boolean> IS_INVISIBLE = mask(0, 0x20, false);
|
||||
public static final Entry<Boolean> HAS_GLOWING_EFFECT = mask(0, 0x40, false);
|
||||
public static final Entry<Boolean> IS_FLYING_WITH_ELYTRA = mask(0, 0x80, false);
|
||||
public static final Entry<Byte> ENTITY_FLAGS = index(0, Metadata::Byte, (byte) 0);
|
||||
public static final Entry<Boolean> IS_ON_FIRE = bitMask(0, (byte) 0x01, false);
|
||||
public static final Entry<Boolean> IS_CROUCHING = bitMask(0, (byte) 0x02, false);
|
||||
public static final Entry<Boolean> UNUSED_RIDING = bitMask(0, (byte) 0x04, false);
|
||||
public static final Entry<Boolean> IS_SPRINTING = bitMask(0, (byte) 0x08, false);
|
||||
public static final Entry<Boolean> IS_SWIMMING = bitMask(0, (byte) 0x10, false);
|
||||
public static final Entry<Boolean> IS_INVISIBLE = bitMask(0, (byte) 0x20, false);
|
||||
public static final Entry<Boolean> HAS_GLOWING_EFFECT = bitMask(0, (byte) 0x40, false);
|
||||
public static final Entry<Boolean> IS_FLYING_WITH_ELYTRA = bitMask(0, (byte) 0x80, false);
|
||||
public static final Entry<Integer> AIR_TICKS = index(1, Metadata::VarInt, 300);
|
||||
public static final Entry<@Nullable Component> CUSTOM_NAME = index(2, Metadata::OptChat, null);
|
||||
public static final Entry<Boolean> CUSTOM_NAME_VISIBLE = index(3, Metadata::Boolean, false);
|
||||
@ -83,10 +86,13 @@ public sealed class MetadataDef {
|
||||
public static final Entry<Integer> LINE_WIDTH = index(1, Metadata::VarInt, 200);
|
||||
public static final Entry<Integer> BACKGROUND_COLOR = index(2, Metadata::VarInt, 0x40000000);
|
||||
public static final Entry<Byte> TEXT_OPACITY = index(3, Metadata::Byte, (byte) -1);
|
||||
public static final Entry<Boolean> HAS_SHADOW = mask(4, 0x01, false);
|
||||
public static final Entry<Boolean> IS_SEE_THROUGH = mask(4, 0x02, false);
|
||||
public static final Entry<Boolean> USE_DEFAULT_BACKGROUND_COLOR = mask(4, 0x04, false);
|
||||
public static final Entry<Boolean> ALIGNMENT = mask(4, 0x08, false);
|
||||
public static final Entry<Byte> TEXT_DISPLAY_FLAGS = index(4, Metadata::Byte, (byte) 0);
|
||||
public static final Entry<Boolean> HAS_SHADOW = bitMask(4, (byte) 0x01, false);
|
||||
public static final Entry<Boolean> IS_SEE_THROUGH = bitMask(4, (byte) 0x02, false);
|
||||
public static final Entry<Boolean> USE_DEFAULT_BACKGROUND_COLOR = bitMask(4, (byte) 0x04, false);
|
||||
public static final Entry<Byte> ALIGNMENT = byteMask(4, (byte) 0x18, 3, (byte) 0);
|
||||
public static final Entry<Boolean> ALIGN_LEFT = bitMask(4, (byte) 0x08, false);
|
||||
public static final Entry<Boolean> ALIGN_RIGHT = bitMask(4, (byte) 0x10, false);
|
||||
}
|
||||
|
||||
public static final class ThrownItemProjectile extends MetadataDef {
|
||||
@ -114,8 +120,9 @@ public sealed class MetadataDef {
|
||||
}
|
||||
|
||||
public static sealed class AbstractArrow extends MetadataDef {
|
||||
public static final Entry<Boolean> IS_CRITICAL = mask(0, 0x01, false);
|
||||
public static final Entry<Boolean> IS_NO_CLIP = mask(0, 0x02, false);
|
||||
public static final Entry<Byte> ARROW_FLAGS = index(0, Metadata::Byte, (byte) 0);
|
||||
public static final Entry<Boolean> IS_CRITICAL = bitMask(0, (byte) 0x01, false);
|
||||
public static final Entry<Boolean> IS_NO_CLIP = bitMask(0, (byte) 0x02, false);
|
||||
public static final Entry<Byte> PIERCING_LEVEL = index(1, Metadata::Byte, (byte) 0);
|
||||
}
|
||||
|
||||
@ -175,7 +182,7 @@ public sealed class MetadataDef {
|
||||
|
||||
public static final class FireworkRocketEntity extends MetadataDef {
|
||||
public static final Entry<ItemStack> ITEM = index(0, Metadata::ItemStack, ItemStack.AIR);
|
||||
public static final Entry<@Nullable Integer> ENTITY_ID = index(1, Metadata::OptVarInt, null);
|
||||
public static final Entry<@Nullable Integer> SHOOTER_ENTITY_ID = index(1, Metadata::OptVarInt, null);
|
||||
public static final Entry<Boolean> IS_SHOT_AT_ANGLE = index(2, Metadata::Boolean, false);
|
||||
}
|
||||
|
||||
@ -185,7 +192,7 @@ public sealed class MetadataDef {
|
||||
}
|
||||
|
||||
public static final class Painting extends MetadataDef {
|
||||
public static final Entry<DynamicRegistry.Key<PaintingMeta.Variant>> ITEM = index(0, Metadata::PaintingVariant, PaintingMeta.Variant.KEBAB);
|
||||
public static final Entry<DynamicRegistry.Key<PaintingMeta.Variant>> VARIANT = index(0, Metadata::PaintingVariant, PaintingMeta.Variant.KEBAB);
|
||||
}
|
||||
|
||||
public static final class ItemEntity extends MetadataDef {
|
||||
@ -193,11 +200,12 @@ public sealed class MetadataDef {
|
||||
}
|
||||
|
||||
public static sealed class LivingEntity extends MetadataDef {
|
||||
public static final Entry<Boolean> IS_HAND_ACTIVE = mask(0, 0x01, false);
|
||||
public static final Entry<Boolean> ACTIVE_HAND = mask(0, 0x02, false);
|
||||
public static final Entry<Boolean> IS_RIPTIDE_SPIN_ATTACK = mask(0, 0x04, false);
|
||||
public static final Entry<Byte> LIVING_ENTITY_FLAGS = index(0, Metadata::Byte, (byte) 0);
|
||||
public static final Entry<Boolean> IS_HAND_ACTIVE = bitMask(0, (byte) 0x01, false);
|
||||
public static final Entry<Boolean> ACTIVE_HAND = bitMask(0, (byte) 0x02, false);
|
||||
public static final Entry<Boolean> IS_RIPTIDE_SPIN_ATTACK = bitMask(0, (byte) 0x04, false);
|
||||
public static final Entry<Float> HEALTH = index(1, Metadata::Float, 1f);
|
||||
public static final Entry<Integer> POTION_EFFECT_COLOR = index(2, Metadata::VarInt, 0);
|
||||
public static final Entry<List<Particle>> POTION_EFFECT_PARTICLES = index(2, Metadata::ParticleList, List.of());
|
||||
public static final Entry<Boolean> IS_POTION_EFFECT_AMBIANT = index(3, Metadata::Boolean, false);
|
||||
public static final Entry<Integer> NUMBER_OF_ARROWS = index(4, Metadata::VarInt, 0);
|
||||
public static final Entry<Integer> NUMBER_OF_BEE_STINGERS = index(5, Metadata::VarInt, 0);
|
||||
@ -207,14 +215,25 @@ public sealed class MetadataDef {
|
||||
public static final class Player extends LivingEntity {
|
||||
public static final Entry<Float> ADDITIONAL_HEARTS = index(0, Metadata::Float, 1f);
|
||||
public static final Entry<Integer> SCORE = index(1, Metadata::VarInt, 0);
|
||||
public static final Entry<Byte> DISLAYED_SKIN_PARTS = index(2, Metadata::Byte, (byte) 0);
|
||||
public static final Entry<Byte> DISPLAYED_SKIN_PARTS_FLAGS = index(2, Metadata::Byte, (byte) 0);
|
||||
public static final Entry<Boolean> IS_CAPE_ENABLED = bitMask(2, (byte) 0x01, false);
|
||||
public static final Entry<Boolean> IS_JACKET_ENABLED = bitMask(2, (byte) 0x02, false);
|
||||
public static final Entry<Boolean> IS_LEFT_SLEEVE_ENABLED = bitMask(2, (byte) 0x04, false);
|
||||
public static final Entry<Boolean> IS_RIGHT_SLEEVE_ENABLED = bitMask(2, (byte) 0x08, false);
|
||||
public static final Entry<Boolean> IS_LEFT_PANTS_LEG_ENABLED = bitMask(2, (byte) 0x10, false);
|
||||
public static final Entry<Boolean> IS_RIGHT_PANTS_LEG_ENABLED = bitMask(2, (byte) 0x20, false);
|
||||
public static final Entry<Boolean> IS_HAT_ENABLED = bitMask(2, (byte) 0x40, false);
|
||||
public static final Entry<Byte> MAIN_HAND = index(3, Metadata::Byte, (byte) 1);
|
||||
public static final Entry<BinaryTag> LEFT_SHOULDER_ENTITY_DATA = index(4, Metadata::NBT, CompoundBinaryTag.empty());
|
||||
public static final Entry<BinaryTag> RIGHT_SHOULDER_ENTITY_DATA = index(5, Metadata::NBT, CompoundBinaryTag.empty());
|
||||
}
|
||||
|
||||
public static final class ArmorStand extends LivingEntity {
|
||||
public static final Entry<Byte> SIZE = index(0, Metadata::Byte, (byte) 0);
|
||||
public static final Entry<Byte> ARMOR_STAND_FLAGS = index(0, Metadata::Byte, (byte) 0);
|
||||
public static final Entry<Boolean> IS_SMALL = bitMask(0, (byte) 0x01, false);
|
||||
public static final Entry<Boolean> HAS_ARMS = bitMask(0, (byte) 0x04, false);
|
||||
public static final Entry<Boolean> HAS_NO_BASE_PLATE = bitMask(0, (byte) 0x08, false);
|
||||
public static final Entry<Boolean> IS_MARKER = bitMask(0, (byte) 0x10, false);
|
||||
public static final Entry<Point> HEAD_ROTATION = index(1, Metadata::Rotation, Vec.ZERO);
|
||||
public static final Entry<Point> BODY_ROTATION = index(2, Metadata::Rotation, Vec.ZERO);
|
||||
public static final Entry<Point> LEFT_ARM_ROTATION = index(3, Metadata::Rotation, new Vec(-10, 0, -10));
|
||||
@ -224,13 +243,24 @@ public sealed class MetadataDef {
|
||||
}
|
||||
|
||||
public static sealed class Mob extends LivingEntity {
|
||||
public static final Entry<Boolean> NO_AI = mask(0, 0x01, false);
|
||||
public static final Entry<Boolean> IS_LEFT_HANDED = mask(0, 0x02, false);
|
||||
public static final Entry<Boolean> IS_AGGRESSIVE = mask(0, 0x04, false);
|
||||
public static final Entry<Byte> MOB_FLAGS = index(0, Metadata::Byte, (byte) 0);
|
||||
public static final Entry<Boolean> NO_AI = bitMask(0, (byte) 0x01, false);
|
||||
public static final Entry<Boolean> IS_LEFT_HANDED = bitMask(0, (byte) 0x02, false);
|
||||
public static final Entry<Boolean> IS_AGGRESSIVE = bitMask(0, (byte) 0x04, false);
|
||||
}
|
||||
|
||||
public static final class Allay extends Mob {
|
||||
public static final Entry<Boolean> IS_DANCING = index(0, Metadata::Boolean, false);
|
||||
public static final Entry<Boolean> CAN_DUPLICATE = index(1, Metadata::Boolean, true);
|
||||
}
|
||||
|
||||
public static final class Armadillo extends Mob {
|
||||
public static final Entry<ArmadilloMeta.State> STATE = index(0, Metadata::ArmadilloState, ArmadilloMeta.State.IDLE);
|
||||
}
|
||||
|
||||
public static final class Bat extends Mob {
|
||||
public static final Entry<Boolean> IS_HANGING = mask(0, 0x01, false);
|
||||
public static final Entry<Byte> BAT_FLAGS = index(0, Metadata::Byte, (byte) 0);
|
||||
public static final Entry<Boolean> IS_HANGING = bitMask(0, (byte) 0x01, false);
|
||||
}
|
||||
|
||||
public static final class Dolphin extends Mob {
|
||||
@ -247,6 +277,10 @@ public sealed class MetadataDef {
|
||||
public static final Entry<Integer> PUFF_STATE = index(0, Metadata::VarInt, 0);
|
||||
}
|
||||
|
||||
public static final class Salmon extends AbstractFish {
|
||||
public static final Entry<String> VARIANT = index(0, Metadata::String, "");
|
||||
}
|
||||
|
||||
public static final class TropicalFish extends AbstractFish {
|
||||
public static final Entry<Integer> VARIANT = index(0, Metadata::VarInt, 0);
|
||||
}
|
||||
@ -256,18 +290,19 @@ public sealed class MetadataDef {
|
||||
}
|
||||
|
||||
public static final class Sniffer extends AgeableMob {
|
||||
public static final Entry<SnifferMeta.State> IS_BABY = index(0, Metadata::SnifferState, SnifferMeta.State.IDLING);
|
||||
public static final Entry<SnifferMeta.State> STATE = index(0, Metadata::SnifferState, SnifferMeta.State.IDLING);
|
||||
public static final Entry<Integer> DROP_SEED_AT_TICK = index(1, Metadata::VarInt, 0);
|
||||
}
|
||||
|
||||
public static sealed class AbstractHorse extends AgeableMob {
|
||||
public static final Entry<Boolean> UNUSED = mask(0, 0x01, false);
|
||||
public static final Entry<Boolean> IS_TAME = mask(0, 0x02, false);
|
||||
public static final Entry<Boolean> IS_SADDLED = mask(0, 0x04, false);
|
||||
public static final Entry<Boolean> HAS_BRED = mask(0, 0x08, false);
|
||||
public static final Entry<Boolean> IS_EATING = mask(0, 0x10, false);
|
||||
public static final Entry<Boolean> IS_REARING = mask(0, 0x20, false);
|
||||
public static final Entry<Boolean> IS_MOUTH_OPEN = mask(0, 0x40, false);
|
||||
public static final Entry<Byte> ABSTRACT_HORSE_FLAGS = index(0, Metadata::Byte, (byte) 0);
|
||||
public static final Entry<Boolean> UNUSED = bitMask(0, (byte) 0x01, false);
|
||||
public static final Entry<Boolean> IS_TAME = bitMask(0, (byte) 0x02, false);
|
||||
public static final Entry<Boolean> IS_SADDLED = bitMask(0, (byte) 0x04, false);
|
||||
public static final Entry<Boolean> HAS_BRED = bitMask(0, (byte) 0x08, false);
|
||||
public static final Entry<Boolean> IS_EATING = bitMask(0, (byte) 0x10, false);
|
||||
public static final Entry<Boolean> IS_REARING = bitMask(0, (byte) 0x20, false);
|
||||
public static final Entry<Boolean> IS_MOUTH_OPEN = bitMask(0, (byte) 0x40, false);
|
||||
}
|
||||
|
||||
public static final class Horse extends AbstractHorse {
|
||||
@ -276,7 +311,7 @@ public sealed class MetadataDef {
|
||||
|
||||
public static final class Camel extends AbstractHorse {
|
||||
public static final Entry<Boolean> DASHING = index(0, Metadata::Boolean, false);
|
||||
public static final Entry<Long> VARIANT = index(1, Metadata::VarLong, 0L);
|
||||
public static final Entry<Long> LAST_POSE_CHANGE_TICK = index(1, Metadata::VarLong, 0L);
|
||||
}
|
||||
|
||||
public static sealed class ChestedHorse extends AbstractHorse {
|
||||
@ -291,28 +326,32 @@ public sealed class MetadataDef {
|
||||
|
||||
public static final class Axolotl extends AgeableMob {
|
||||
public static final Entry<Integer> VARIANT = index(0, Metadata::VarInt, 0);
|
||||
public static final Entry<Boolean> PLAYING_DEAD = index(1, Metadata::Boolean, false);
|
||||
public static final Entry<Boolean> SPAWNED_FROM_BUCKET = index(2, Metadata::Boolean, false);
|
||||
public static final Entry<Boolean> IS_PLAYING_DEAD = index(1, Metadata::Boolean, false);
|
||||
public static final Entry<Boolean> IS_FROM_BUCKET = index(2, Metadata::Boolean, false);
|
||||
}
|
||||
|
||||
public static final class Bee extends AgeableMob {
|
||||
public static final Entry<Boolean> UNUSED = mask(0, 0x01, false);
|
||||
public static final Entry<Boolean> IS_ANGRY = mask(0, 0x02, false);
|
||||
public static final Entry<Boolean> HAS_STUNG = mask(0, 0x04, false);
|
||||
public static final Entry<Boolean> HAS_NECTAR = mask(0, 0x08, false);
|
||||
public static final Entry<Byte> BEE_FLAGS = index(0, Metadata::Byte, (byte) 0);
|
||||
public static final Entry<Boolean> IS_ANGRY = bitMask(0, (byte) 0x02, false);
|
||||
public static final Entry<Boolean> HAS_STUNG = bitMask(0, (byte) 0x04, false);
|
||||
public static final Entry<Boolean> HAS_NECTAR = bitMask(0, (byte) 0x08, false);
|
||||
public static final Entry<Integer> ANGER_TIME_TICKS = index(1, Metadata::VarInt, 0);
|
||||
}
|
||||
|
||||
public static final class GlowSquid extends AgeableMob {
|
||||
public static final Entry<Integer> DARK_TICKS_REMAINING = index(0, Metadata::VarInt, 0);
|
||||
}
|
||||
|
||||
public static final class Fox extends AgeableMob {
|
||||
public static final Entry<Integer> TYPE = index(0, Metadata::VarInt, 0);
|
||||
public static final Entry<Boolean> IS_SITTING = mask(1, 0x01, false);
|
||||
public static final Entry<Boolean> UNUSED = mask(1, 0x02, false);
|
||||
public static final Entry<Boolean> IS_CROUCHING = mask(1, 0x04, false);
|
||||
public static final Entry<Boolean> IS_INTERESTED = mask(1, 0x08, false);
|
||||
public static final Entry<Boolean> IS_POUNCING = mask(1, 0x10, false);
|
||||
public static final Entry<Boolean> IS_SLEEPING = mask(1, 0x20, false);
|
||||
public static final Entry<Boolean> IS_FACEPLANTED = mask(1, 0x40, false);
|
||||
public static final Entry<Boolean> IS_DEFENDING = mask(1, 0x80, false);
|
||||
public static final Entry<Byte> FOX_FLAGS = index(1, Metadata::Byte, (byte) 0);
|
||||
public static final Entry<Boolean> IS_SITTING = bitMask(1, (byte) 0x01, false);
|
||||
public static final Entry<Boolean> IS_CROUCHING = bitMask(1, (byte) 0x04, false);
|
||||
public static final Entry<Boolean> IS_INTERESTED = bitMask(1, (byte) 0x08, false);
|
||||
public static final Entry<Boolean> IS_POUNCING = bitMask(1, (byte) 0x10, false);
|
||||
public static final Entry<Boolean> IS_SLEEPING = bitMask(1, (byte) 0x20, false);
|
||||
public static final Entry<Boolean> IS_FACEPLANTED = bitMask(1, (byte) 0x40, false);
|
||||
public static final Entry<Boolean> IS_DEFENDING = bitMask(1, (byte) 0x80, false);
|
||||
public static final Entry<@Nullable UUID> FIRST_UUID = index(2, Metadata::OptUUID, null);
|
||||
public static final Entry<@Nullable UUID> SECOND_UUID = index(3, Metadata::OptUUID, null);
|
||||
}
|
||||
@ -332,11 +371,11 @@ public sealed class MetadataDef {
|
||||
public static final Entry<Integer> EAT_TIMER = index(2, Metadata::VarInt, 0);
|
||||
public static final Entry<Byte> MAIN_GENE = index(3, Metadata::Byte, (byte) 0);
|
||||
public static final Entry<Byte> HIDDEN_GENE = index(4, Metadata::Byte, (byte) 0);
|
||||
public static final Entry<Boolean> UNUSED = mask(5, 0x01, false);
|
||||
public static final Entry<Boolean> IS_SNEEZING = mask(5, 0x02, false);
|
||||
public static final Entry<Boolean> IS_ROLLING = mask(5, 0x04, false);
|
||||
public static final Entry<Boolean> IS_SITTING = mask(5, 0x08, false);
|
||||
public static final Entry<Boolean> IS_ON_BACK = mask(5, 0x10, false);
|
||||
public static final Entry<Byte> PANDA_FLAGS = index(5, Metadata::Byte, (byte) 0);
|
||||
public static final Entry<Boolean> IS_SNEEZING = bitMask(5, (byte) 0x02, false);
|
||||
public static final Entry<Boolean> IS_ROLLING = bitMask(5, (byte) 0x04, false);
|
||||
public static final Entry<Boolean> IS_SITTING = bitMask(5, (byte) 0x08, false);
|
||||
public static final Entry<Boolean> IS_ON_BACK = bitMask(5, (byte) 0x10, false);
|
||||
}
|
||||
|
||||
public static final class Pig extends AgeableMob {
|
||||
@ -362,7 +401,7 @@ public sealed class MetadataDef {
|
||||
}
|
||||
|
||||
public static final class Mooshroom extends AgeableMob {
|
||||
public static final Entry<String> IS_STANDING_UP = index(0, Metadata::String, "red");
|
||||
public static final Entry<String> VARIANT = index(0, Metadata::String, "red");
|
||||
}
|
||||
|
||||
public static final class Hoglin extends AgeableMob {
|
||||
@ -370,9 +409,9 @@ public sealed class MetadataDef {
|
||||
}
|
||||
|
||||
public static final class Sheep extends AgeableMob {
|
||||
// TODO: color is 4 bits
|
||||
public static final Entry<Boolean> COLOR_ID = mask(0, 0x0F, false);
|
||||
public static final Entry<Boolean> IS_SHEARED = mask(0, 0x10, false);
|
||||
public static final Entry<Byte> SHEEP_FLAGS = index(0, Metadata::Byte, (byte) 0);
|
||||
public static final Entry<Byte> COLOR_ID = byteMask(0, (byte) 0x0F, 0, (byte) 0);
|
||||
public static final Entry<Boolean> IS_SHEARED = bitMask(0, (byte) 0x10, false);
|
||||
}
|
||||
|
||||
public static final class Strider extends AgeableMob {
|
||||
@ -388,14 +427,15 @@ public sealed class MetadataDef {
|
||||
}
|
||||
|
||||
public static sealed class TameableAnimal extends AgeableMob {
|
||||
public static final Entry<Boolean> IS_SITTING = mask(0, 0x01, false);
|
||||
public static final Entry<Boolean> UNUSED = mask(0, 0x02, false);
|
||||
public static final Entry<Boolean> IS_TAMED = mask(0, 0x04, false);
|
||||
public static final Entry<Byte> TAMEABLE_ANIMAL_FLAGS = index(0, Metadata::Byte, (byte) 0);
|
||||
public static final Entry<Boolean> IS_SITTING = bitMask(0, (byte) 0x01, false);
|
||||
public static final Entry<Boolean> UNUSED = bitMask(0, (byte) 0x02, false);
|
||||
public static final Entry<Boolean> IS_TAMED = bitMask(0, (byte) 0x04, false);
|
||||
public static final Entry<@Nullable UUID> OWNER = index(1, Metadata::OptUUID, null);
|
||||
}
|
||||
|
||||
public static final class Cat extends TameableAnimal {
|
||||
public static final Entry<CatMeta.Variant> FUNGUS_BOOST = index(0, Metadata::CatVariant, CatMeta.Variant.BLACK);
|
||||
public static final Entry<CatMeta.Variant> VARIANT = index(0, Metadata::CatVariant, CatMeta.Variant.BLACK);
|
||||
public static final Entry<Boolean> IS_LYING = index(2, Metadata::Boolean, false);
|
||||
public static final Entry<Boolean> IS_RELAXED = index(3, Metadata::Boolean, false);
|
||||
public static final Entry<Integer> COLLAR_COLOR = index(4, Metadata::VarInt, 14);
|
||||
@ -405,6 +445,7 @@ public sealed class MetadataDef {
|
||||
public static final Entry<Boolean> IS_BEGGING = index(0, Metadata::Boolean, false);
|
||||
public static final Entry<Integer> COLLAR_COLOR = index(1, Metadata::VarInt, 14);
|
||||
public static final Entry<Integer> ANGER_TIME = index(2, Metadata::VarInt, 0);
|
||||
public static final Entry<DynamicRegistry.Key<WolfMeta.Variant>> VARIANT = index(3, Metadata::WolfVariant, WolfMeta.Variant.PALE);
|
||||
}
|
||||
|
||||
public static final class Parrot extends TameableAnimal {
|
||||
@ -420,12 +461,13 @@ public sealed class MetadataDef {
|
||||
}
|
||||
|
||||
public static final class IronGolem extends Mob {
|
||||
public static final Entry<Boolean> IS_PLAYER_CREATED = mask(0, 0x01, false);
|
||||
public static final Entry<Byte> IRON_GOLEM_FLAGS = index(0, Metadata::Byte, (byte) 0);
|
||||
public static final Entry<Boolean> IS_PLAYER_CREATED = bitMask(0, (byte) 0x01, false);
|
||||
}
|
||||
|
||||
public static final class SnowGolem extends Mob {
|
||||
public static final Entry<Boolean> NO_PUMPKIN_HAT = mask(0, 0x01, false);
|
||||
public static final Entry<Boolean> PUMPKIN_HAT = mask(0, 0x10, true);
|
||||
public static final Entry<Byte> SNOW_GOLEM_FLAGS = index(0, Metadata::Byte, (byte) 0);
|
||||
public static final Entry<Boolean> PUMPKIN_HAT = bitMask(0, (byte) 0x10, true);
|
||||
}
|
||||
|
||||
public static final class Shulker extends Mob {
|
||||
@ -445,7 +487,17 @@ public sealed class MetadataDef {
|
||||
}
|
||||
|
||||
public static final class Blaze extends Mob {
|
||||
public static final Entry<Boolean> IS_ON_FIRE = mask(0, 0x01, false);
|
||||
public static final Entry<Byte> BLAZE_FLAGS = index(0, Metadata::Byte, (byte) 0);
|
||||
public static final Entry<Boolean> IS_ON_FIRE = bitMask(0, (byte) 0x01, false);
|
||||
}
|
||||
|
||||
public static final class Bogged extends Mob {
|
||||
public static final Entry<Boolean> IS_SHEARED = index(0, Metadata::Boolean, false);
|
||||
}
|
||||
|
||||
public static final class Creaking extends Mob {
|
||||
public static final Entry<Boolean> CAN_MOVE = index(0, Metadata::Boolean, false);
|
||||
public static final Entry<Boolean> IS_ACTIVE = index(1, Metadata::Boolean, false);
|
||||
}
|
||||
|
||||
public static final class Creeper extends Mob {
|
||||
@ -472,11 +524,17 @@ public sealed class MetadataDef {
|
||||
}
|
||||
|
||||
public static final class Witch extends Raider {
|
||||
public static final Entry<Boolean> IS_ATTACKING = mask(0, 0x01, false);
|
||||
public static final Entry<Boolean> IS_DRINKING_POTION = index(0, Metadata::Boolean, false);
|
||||
}
|
||||
|
||||
public static final class Spider extends Mob {
|
||||
public static final Entry<Boolean> IS_CLIMBING = mask(0, 0x01, false);
|
||||
public static final Entry<Byte> SPIDER_FLAGS = index(0, Metadata::Byte, (byte) 0);
|
||||
public static final Entry<Boolean> IS_CLIMBING = bitMask(0, (byte) 0x01, false);
|
||||
}
|
||||
|
||||
public static final class Vex extends Mob {
|
||||
public static final Entry<Byte> VEX_FLAGS = index(0, Metadata::Byte, (byte) 0);
|
||||
public static final Entry<Boolean> IS_ATTACKING = bitMask(0, (byte) 0x01, false);
|
||||
}
|
||||
|
||||
public static final class Warden extends Mob {
|
||||
@ -531,6 +589,10 @@ public sealed class MetadataDef {
|
||||
public static final Entry<Integer> FUSE_TIME = index(0, Metadata::VarInt, 80);
|
||||
}
|
||||
|
||||
public static final class OminousItemSpawner extends MetadataDef {
|
||||
public static final Entry<ItemStack> ITEM = index(0, Metadata::ItemStack, ItemStack.AIR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of metadata entries for a specific class.
|
||||
* <p>
|
||||
@ -548,7 +610,10 @@ public sealed class MetadataDef {
|
||||
record Index<T>(int index, Function<T, Metadata.Entry<T>> function, T defaultValue) implements Entry<T> {
|
||||
}
|
||||
|
||||
record Mask(int index, int bitMask, Boolean defaultValue) implements Entry<Boolean> {
|
||||
record BitMask(int index, byte bitMask, Boolean defaultValue) implements Entry<Boolean> {
|
||||
}
|
||||
|
||||
record ByteMask(int index, byte byteMask, int offset, Byte defaultValue) implements Entry<Byte> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,11 +14,18 @@ final class MetadataDefImpl {
|
||||
return new MetadataDef.Entry.Index<>(superIndex + index, function, defaultValue);
|
||||
}
|
||||
|
||||
static MetadataDef.Entry.Mask mask(int index, int bitMask, boolean defaultValue) {
|
||||
static MetadataDef.Entry.BitMask bitMask(int index, byte bitMask, boolean defaultValue) {
|
||||
final String caller = caller();
|
||||
storeMaxIndex(caller, index);
|
||||
final int superIndex = findSuperIndex(caller);
|
||||
return new MetadataDef.Entry.Mask(superIndex + index, bitMask, defaultValue);
|
||||
return new MetadataDef.Entry.BitMask(superIndex + index, bitMask, defaultValue);
|
||||
}
|
||||
|
||||
static MetadataDef.Entry.ByteMask byteMask(int index, byte byteMask, int offset, byte defaultValue) {
|
||||
final String caller = caller();
|
||||
storeMaxIndex(caller, index);
|
||||
final int superIndex = findSuperIndex(caller);
|
||||
return new MetadataDef.Entry.ByteMask(superIndex + index, byteMask, offset, defaultValue);
|
||||
}
|
||||
|
||||
static <T extends MetadataDef> int count(Class<T> clazz) {
|
||||
|
@ -1,5 +1,7 @@
|
||||
package net.minestom.server.entity;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import net.minestom.server.entity.metadata.EntityMeta;
|
||||
import net.minestom.server.entity.metadata.PlayerMeta;
|
||||
import net.minestom.server.entity.metadata.ambient.BatMeta;
|
||||
@ -40,7 +42,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.invoke.VarHandle;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiFunction;
|
||||
@ -57,8 +58,7 @@ public final class MetadataHolder {
|
||||
}
|
||||
|
||||
private final Entity entity;
|
||||
private volatile Metadata.Entry<?>[] entries = new Metadata.Entry<?>[0];
|
||||
private volatile Map<Integer, Metadata.Entry<?>> entryMap = null;
|
||||
private final Int2ObjectMap<Metadata.Entry<?>> entries = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
@SuppressWarnings("FieldMayBeFinal")
|
||||
private volatile boolean notifyAboutChanges = true;
|
||||
@ -68,36 +68,72 @@ public final class MetadataHolder {
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getIndex(int index, @Nullable T defaultValue) {
|
||||
final Metadata.Entry<?>[] entries = this.entries;
|
||||
if (index < 0 || index >= entries.length) return defaultValue;
|
||||
final Metadata.Entry<?> entry = entries[index];
|
||||
return entry != null ? (T) entry.value() : defaultValue;
|
||||
public <T> T get(MetadataDef.@NotNull Entry<T> entry) {
|
||||
final int id = entry.index();
|
||||
|
||||
final Metadata.Entry<?> value = this.entries.get(id);
|
||||
if (value == null) return entry.defaultValue();
|
||||
return switch (entry) {
|
||||
case MetadataDef.Entry.Index<T> v -> (T) value.value();
|
||||
case MetadataDef.Entry.BitMask bitMask -> {
|
||||
final byte maskValue = (byte) value.value();
|
||||
yield (T) ((Boolean) getMaskBit(maskValue, bitMask.bitMask()));
|
||||
}
|
||||
case MetadataDef.Entry.ByteMask byteMask -> {
|
||||
final byte maskValue = (byte) value.value();
|
||||
yield (T) ((Byte) getMaskByte(maskValue, byteMask.byteMask(), byteMask.offset()));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void setIndex(int index, @NotNull Metadata.Entry<?> entry) {
|
||||
Metadata.Entry<?>[] entries = this.entries;
|
||||
// Resize array if necessary
|
||||
if (index >= entries.length) {
|
||||
final int newLength = Math.max(entries.length * 2, index + 1);
|
||||
this.entries = entries = Arrays.copyOf(entries, newLength);
|
||||
}
|
||||
entries[index] = entry;
|
||||
this.entryMap = null;
|
||||
// Send metadata packet to update viewers and self
|
||||
public <T> void set(MetadataDef.@NotNull Entry<T> entry, T value) {
|
||||
final int id = entry.index();
|
||||
|
||||
Metadata.Entry<?> result = switch (entry) {
|
||||
case MetadataDef.Entry.Index<T> v -> v.function().apply(value);
|
||||
case MetadataDef.Entry.BitMask bitMask -> {
|
||||
Metadata.Entry<?> currentEntry = this.entries.get(id);
|
||||
byte maskValue = currentEntry != null ? (byte) currentEntry.value() : 0;
|
||||
maskValue = setMaskBit(maskValue, bitMask.bitMask(), (Boolean) value);
|
||||
yield Metadata.Byte(maskValue);
|
||||
}
|
||||
case MetadataDef.Entry.ByteMask byteMask -> {
|
||||
Metadata.Entry<?> currentEntry = this.entries.get(id);
|
||||
byte maskValue = currentEntry != null ? (byte) currentEntry.value() : 0;
|
||||
maskValue = setMaskByte(maskValue, byteMask.byteMask(), byteMask.offset(), (Byte) value);
|
||||
yield Metadata.Byte(maskValue);
|
||||
}
|
||||
};
|
||||
|
||||
this.entries.put(id, result);
|
||||
final Entity entity = this.entity;
|
||||
if (entity != null && entity.isActive()) {
|
||||
if (!this.notifyAboutChanges) {
|
||||
synchronized (this.notNotifiedChanges) {
|
||||
this.notNotifiedChanges.put(index, entry);
|
||||
this.notNotifiedChanges.put(id, result);
|
||||
}
|
||||
} else {
|
||||
entity.sendPacketToViewersAndSelf(new EntityMetaDataPacket(entity.getEntityId(), Map.of(index, entry)));
|
||||
entity.sendPacketToViewersAndSelf(new EntityMetaDataPacket(entity.getEntityId(), Map.of(id, result)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean getMaskBit(byte maskValue, byte bit) {
|
||||
return (maskValue & bit) == bit;
|
||||
}
|
||||
|
||||
private byte setMaskBit(byte mask, byte bit, boolean value) {
|
||||
return value ? (byte) (mask | bit) : (byte) (mask & ~bit);
|
||||
}
|
||||
|
||||
private byte getMaskByte(byte data, byte byteMask, int offset) {
|
||||
return (byte) ((data & byteMask) >> offset);
|
||||
}
|
||||
|
||||
private byte setMaskByte(byte data, byte byteMask, int offset, byte newValue) {
|
||||
return (byte) ((data & ~byteMask) | ((newValue << offset) & byteMask));
|
||||
}
|
||||
|
||||
public void setNotifyAboutChanges(boolean notifyAboutChanges) {
|
||||
if (!NOTIFIED_CHANGES.compareAndSet(this, !notifyAboutChanges, notifyAboutChanges))
|
||||
return;
|
||||
@ -118,17 +154,7 @@ public final class MetadataHolder {
|
||||
}
|
||||
|
||||
public @NotNull Map<Integer, Metadata.Entry<?>> getEntries() {
|
||||
Map<Integer, Metadata.Entry<?>> map = entryMap;
|
||||
if (map == null) {
|
||||
map = new HashMap<>();
|
||||
final Metadata.Entry<?>[] entries = this.entries;
|
||||
for (int i = 0; i < entries.length; i++) {
|
||||
final Metadata.Entry<?> entry = entries[i];
|
||||
if (entry != null) map.put(i, entry);
|
||||
}
|
||||
this.entryMap = Map.copyOf(map);
|
||||
}
|
||||
return map;
|
||||
return Map.copyOf(this.entries);
|
||||
}
|
||||
|
||||
static final Map<String, BiFunction<Entity, MetadataHolder, EntityMeta>> ENTITY_META_SUPPLIER = createMetaMap();
|
||||
|
@ -1,40 +1,36 @@
|
||||
package net.minestom.server.entity.metadata;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AbstractVehicleMeta extends EntityMeta {
|
||||
|
||||
public static final byte OFFSET = EntityMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 3;
|
||||
|
||||
public AbstractVehicleMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public int getShakingTicks() {
|
||||
return super.metadata.getIndex(OFFSET, 0);
|
||||
return metadata.get(MetadataDef.AbstractVehicle.SHAKING_POWER);
|
||||
}
|
||||
|
||||
public void setShakingTicks(int value) {
|
||||
super.metadata.setIndex(OFFSET, Metadata.VarInt(value));
|
||||
metadata.set(MetadataDef.AbstractVehicle.SHAKING_POWER, value);
|
||||
}
|
||||
|
||||
public int getShakingDirection() {
|
||||
return super.metadata.getIndex(OFFSET + 1, 1);
|
||||
return metadata.get(MetadataDef.AbstractVehicle.SHAKING_DIRECTION);
|
||||
}
|
||||
|
||||
public void setShakingDirection(int value) {
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.VarInt(value));
|
||||
metadata.set(MetadataDef.AbstractVehicle.SHAKING_DIRECTION, value);
|
||||
}
|
||||
|
||||
public float getShakingMultiplier() {
|
||||
return super.metadata.getIndex(OFFSET + 2, 0);
|
||||
return metadata.get(MetadataDef.AbstractVehicle.SHAKING_MULTIPLIER);
|
||||
}
|
||||
|
||||
public void setShakingMultiplier(float value) {
|
||||
super.metadata.setIndex(OFFSET + 2, Metadata.Float(value));
|
||||
metadata.set(MetadataDef.AbstractVehicle.SHAKING_MULTIPLIER, value);
|
||||
}
|
||||
}
|
||||
|
@ -2,20 +2,17 @@ package net.minestom.server.entity.metadata;
|
||||
|
||||
import net.minestom.server.collision.BoundingBox;
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AgeableMobMeta extends PathfinderMobMeta {
|
||||
public static final byte OFFSET = PathfinderMobMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
protected AgeableMobMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean isBaby() {
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
return metadata.get(MetadataDef.AgeableMob.IS_BABY);
|
||||
}
|
||||
|
||||
public void setBaby(boolean value) {
|
||||
@ -32,7 +29,7 @@ public class AgeableMobMeta extends PathfinderMobMeta {
|
||||
entity.setBoundingBox(width, bb.height() * 2, width);
|
||||
}
|
||||
});
|
||||
super.metadata.setIndex(OFFSET, Metadata.Boolean(value));
|
||||
metadata.set(MetadataDef.AgeableMob.IS_BABY, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package net.minestom.server.entity.metadata;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.EntityPose;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@ -12,17 +12,6 @@ import java.lang.ref.WeakReference;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class EntityMeta {
|
||||
public static final byte OFFSET = 0;
|
||||
public static final byte MAX_OFFSET = OFFSET + 8;
|
||||
|
||||
private final static byte ON_FIRE_BIT = 0x01;
|
||||
private final static byte CROUCHING_BIT = 0x02;
|
||||
private final static byte SPRINTING_BIT = 0x08;
|
||||
private final static byte SWIMMING_BIT = 0x10;
|
||||
private final static byte INVISIBLE_BIT = 0x20;
|
||||
private final static byte HAS_GLOWING_EFFECT_BIT = 0x40;
|
||||
private final static byte FLYING_WITH_ELYTRA_BIT = (byte) 0x80;
|
||||
|
||||
private final WeakReference<Entity> entityRef;
|
||||
protected final MetadataHolder metadata;
|
||||
|
||||
@ -49,141 +38,117 @@ public class EntityMeta {
|
||||
}
|
||||
|
||||
public boolean isOnFire() {
|
||||
return getMaskBit(OFFSET, ON_FIRE_BIT);
|
||||
return metadata.get(MetadataDef.IS_ON_FIRE);
|
||||
}
|
||||
|
||||
public void setOnFire(boolean value) {
|
||||
setMaskBit(OFFSET, ON_FIRE_BIT, value);
|
||||
metadata.set(MetadataDef.IS_ON_FIRE, value);
|
||||
}
|
||||
|
||||
public boolean isSneaking() {
|
||||
return getMaskBit(OFFSET, CROUCHING_BIT);
|
||||
return metadata.get(MetadataDef.IS_CROUCHING);
|
||||
}
|
||||
|
||||
public void setSneaking(boolean value) {
|
||||
setMaskBit(OFFSET, CROUCHING_BIT, value);
|
||||
metadata.set(MetadataDef.IS_CROUCHING, value);
|
||||
}
|
||||
|
||||
public boolean isSprinting() {
|
||||
return getMaskBit(OFFSET, SPRINTING_BIT);
|
||||
return metadata.get(MetadataDef.IS_SPRINTING);
|
||||
}
|
||||
|
||||
public void setSprinting(boolean value) {
|
||||
setMaskBit(OFFSET, SPRINTING_BIT, value);
|
||||
metadata.set(MetadataDef.IS_SPRINTING, value);
|
||||
}
|
||||
|
||||
public boolean isSwimming() {
|
||||
return getMaskBit(OFFSET, SWIMMING_BIT);
|
||||
return metadata.get(MetadataDef.IS_SWIMMING);
|
||||
}
|
||||
|
||||
public void setSwimming(boolean value) {
|
||||
setMaskBit(OFFSET, SWIMMING_BIT, value);
|
||||
metadata.set(MetadataDef.IS_SWIMMING, value);
|
||||
}
|
||||
|
||||
public boolean isInvisible() {
|
||||
return getMaskBit(OFFSET, INVISIBLE_BIT);
|
||||
return metadata.get(MetadataDef.IS_INVISIBLE);
|
||||
}
|
||||
|
||||
public void setInvisible(boolean value) {
|
||||
setMaskBit(OFFSET, INVISIBLE_BIT, value);
|
||||
metadata.set(MetadataDef.IS_INVISIBLE, value);
|
||||
}
|
||||
|
||||
public boolean isHasGlowingEffect() {
|
||||
return getMaskBit(OFFSET, HAS_GLOWING_EFFECT_BIT);
|
||||
return metadata.get(MetadataDef.HAS_GLOWING_EFFECT);
|
||||
}
|
||||
|
||||
public void setHasGlowingEffect(boolean value) {
|
||||
setMaskBit(OFFSET, HAS_GLOWING_EFFECT_BIT, value);
|
||||
metadata.set(MetadataDef.HAS_GLOWING_EFFECT, value);
|
||||
}
|
||||
|
||||
public boolean isFlyingWithElytra() {
|
||||
return getMaskBit(OFFSET, FLYING_WITH_ELYTRA_BIT);
|
||||
return metadata.get(MetadataDef.IS_FLYING_WITH_ELYTRA);
|
||||
}
|
||||
|
||||
public void setFlyingWithElytra(boolean value) {
|
||||
setMaskBit(OFFSET, FLYING_WITH_ELYTRA_BIT, value);
|
||||
metadata.set(MetadataDef.IS_FLYING_WITH_ELYTRA, value);
|
||||
}
|
||||
|
||||
public int getAirTicks() {
|
||||
return this.metadata.getIndex(OFFSET + 1, 300);
|
||||
return metadata.get(MetadataDef.AIR_TICKS);
|
||||
}
|
||||
|
||||
public void setAirTicks(int value) {
|
||||
this.metadata.setIndex(OFFSET + 1, Metadata.VarInt(value));
|
||||
metadata.set(MetadataDef.AIR_TICKS, value);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Component getCustomName() {
|
||||
return this.metadata.getIndex(OFFSET + 2, null);
|
||||
return metadata.get(MetadataDef.CUSTOM_NAME);
|
||||
}
|
||||
|
||||
public void setCustomName(Component value) {
|
||||
this.metadata.setIndex(OFFSET + 2, Metadata.OptChat(value));
|
||||
public void setCustomName(@Nullable Component value) {
|
||||
metadata.set(MetadataDef.CUSTOM_NAME, value);
|
||||
}
|
||||
|
||||
public boolean isCustomNameVisible() {
|
||||
return this.metadata.getIndex(OFFSET + 3, false);
|
||||
return metadata.get(MetadataDef.CUSTOM_NAME_VISIBLE);
|
||||
}
|
||||
|
||||
public void setCustomNameVisible(boolean value) {
|
||||
this.metadata.setIndex(OFFSET + 3, Metadata.Boolean(value));
|
||||
metadata.set(MetadataDef.CUSTOM_NAME_VISIBLE, value);
|
||||
}
|
||||
|
||||
public boolean isSilent() {
|
||||
return this.metadata.getIndex(OFFSET + 4, false);
|
||||
return metadata.get(MetadataDef.IS_SILENT);
|
||||
}
|
||||
|
||||
public void setSilent(boolean value) {
|
||||
this.metadata.setIndex(OFFSET + 4, Metadata.Boolean(value));
|
||||
metadata.set(MetadataDef.IS_SILENT, value);
|
||||
}
|
||||
|
||||
public boolean isHasNoGravity() {
|
||||
return this.metadata.getIndex(OFFSET + 5, false);
|
||||
return metadata.get(MetadataDef.HAS_NO_GRAVITY);
|
||||
}
|
||||
|
||||
public void setHasNoGravity(boolean value) {
|
||||
this.metadata.setIndex(OFFSET + 5, Metadata.Boolean(value));
|
||||
metadata.set(MetadataDef.HAS_NO_GRAVITY, value);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public EntityPose getPose() {
|
||||
return this.metadata.getIndex(OFFSET + 6, EntityPose.STANDING);
|
||||
return metadata.get(MetadataDef.POSE);
|
||||
}
|
||||
|
||||
public void setPose(EntityPose value) {
|
||||
this.metadata.setIndex(OFFSET + 6, Metadata.Pose(value));
|
||||
public void setPose(@NotNull EntityPose value) {
|
||||
metadata.set(MetadataDef.POSE, value);
|
||||
}
|
||||
|
||||
public int getTickFrozen() {
|
||||
return this.metadata.getIndex(OFFSET + 7, 0);
|
||||
return metadata.get(MetadataDef.TICKS_FROZEN);
|
||||
}
|
||||
|
||||
public void setTickFrozen(int tickFrozen) {
|
||||
this.metadata.setIndex(OFFSET + 7, Metadata.VarInt(tickFrozen));
|
||||
}
|
||||
|
||||
protected byte getMask(int index) {
|
||||
return this.metadata.getIndex(index, (byte) 0);
|
||||
}
|
||||
|
||||
protected void setMask(int index, byte mask) {
|
||||
this.metadata.setIndex(index, Metadata.Byte(mask));
|
||||
}
|
||||
|
||||
protected boolean getMaskBit(int index, byte bit) {
|
||||
return (getMask(index) & bit) == bit;
|
||||
}
|
||||
|
||||
protected void setMaskBit(int index, byte bit, boolean value) {
|
||||
byte mask = getMask(index);
|
||||
boolean currentValue = (mask & bit) == bit;
|
||||
if (currentValue == value) {
|
||||
return;
|
||||
}
|
||||
if (value) {
|
||||
mask |= bit;
|
||||
} else {
|
||||
mask &= ~bit;
|
||||
}
|
||||
setMask(index, mask);
|
||||
metadata.set(MetadataDef.TICKS_FROZEN, tickFrozen);
|
||||
}
|
||||
|
||||
protected void consumeEntity(Consumer<Entity> consumer) {
|
||||
|
@ -2,7 +2,7 @@ package net.minestom.server.entity.metadata;
|
||||
|
||||
import net.minestom.server.coordinate.Point;
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import net.minestom.server.entity.PlayerHand;
|
||||
import net.minestom.server.particle.Particle;
|
||||
@ -12,72 +12,65 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class LivingEntityMeta extends EntityMeta {
|
||||
public static final byte OFFSET = EntityMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 7;
|
||||
|
||||
private final static byte IS_HAND_ACTIVE_BIT = 0x01;
|
||||
private final static byte ACTIVE_HAND_BIT = 0x02;
|
||||
private final static byte IS_IN_SPIN_ATTACK_BIT = 0x04;
|
||||
|
||||
protected LivingEntityMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean isHandActive() {
|
||||
return getMaskBit(OFFSET, IS_HAND_ACTIVE_BIT);
|
||||
return metadata.get(MetadataDef.LivingEntity.IS_HAND_ACTIVE);
|
||||
}
|
||||
|
||||
public void setHandActive(boolean value) {
|
||||
setMaskBit(OFFSET, IS_HAND_ACTIVE_BIT, value);
|
||||
metadata.set(MetadataDef.LivingEntity.IS_HAND_ACTIVE, value);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public PlayerHand getActiveHand() {
|
||||
return getMaskBit(OFFSET, ACTIVE_HAND_BIT) ? PlayerHand.OFF : PlayerHand.MAIN;
|
||||
return metadata.get(MetadataDef.LivingEntity.ACTIVE_HAND) ? PlayerHand.OFF : PlayerHand.MAIN;
|
||||
}
|
||||
|
||||
public void setActiveHand(@NotNull PlayerHand hand) {
|
||||
setMaskBit(OFFSET, ACTIVE_HAND_BIT, hand == PlayerHand.OFF);
|
||||
metadata.set(MetadataDef.LivingEntity.ACTIVE_HAND, hand == PlayerHand.OFF);
|
||||
}
|
||||
|
||||
public boolean isInRiptideSpinAttack() {
|
||||
return getMaskBit(OFFSET, IS_IN_SPIN_ATTACK_BIT);
|
||||
return metadata.get(MetadataDef.LivingEntity.IS_RIPTIDE_SPIN_ATTACK);
|
||||
}
|
||||
|
||||
public void setInRiptideSpinAttack(boolean value) {
|
||||
setMaskBit(OFFSET, IS_IN_SPIN_ATTACK_BIT, value);
|
||||
metadata.set(MetadataDef.LivingEntity.IS_RIPTIDE_SPIN_ATTACK, value);
|
||||
}
|
||||
|
||||
public float getHealth() {
|
||||
return super.metadata.getIndex(OFFSET + 1, 1F);
|
||||
return metadata.get(MetadataDef.LivingEntity.HEALTH);
|
||||
}
|
||||
|
||||
public void setHealth(float value) {
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.Float(value));
|
||||
metadata.set(MetadataDef.LivingEntity.HEALTH, value);
|
||||
}
|
||||
|
||||
public @NotNull List<Particle> getEffectParticles() {
|
||||
return super.metadata.getIndex(OFFSET + 2, List.of());
|
||||
return metadata.get(MetadataDef.LivingEntity.POTION_EFFECT_PARTICLES);
|
||||
}
|
||||
|
||||
public void setEffectParticles(@NotNull List<Particle> value) {
|
||||
super.metadata.setIndex(OFFSET + 2, Metadata.ParticleList(value));
|
||||
metadata.set(MetadataDef.LivingEntity.POTION_EFFECT_PARTICLES, value);
|
||||
}
|
||||
|
||||
public boolean isPotionEffectAmbient() {
|
||||
return super.metadata.getIndex(OFFSET + 3, false);
|
||||
return metadata.get(MetadataDef.LivingEntity.IS_POTION_EFFECT_AMBIANT);
|
||||
}
|
||||
|
||||
public void setPotionEffectAmbient(boolean value) {
|
||||
super.metadata.setIndex(OFFSET + 3, Metadata.Boolean(value));
|
||||
metadata.set(MetadataDef.LivingEntity.IS_POTION_EFFECT_AMBIANT, value);
|
||||
}
|
||||
|
||||
public int getArrowCount() {
|
||||
return super.metadata.getIndex(OFFSET + 4, 0);
|
||||
return metadata.get(MetadataDef.LivingEntity.NUMBER_OF_ARROWS);
|
||||
}
|
||||
|
||||
public void setArrowCount(int value) {
|
||||
super.metadata.setIndex(OFFSET + 4, Metadata.VarInt(value));
|
||||
metadata.set(MetadataDef.LivingEntity.NUMBER_OF_ARROWS, value);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -86,7 +79,7 @@ public class LivingEntityMeta extends EntityMeta {
|
||||
* @return The amount of bee stingers
|
||||
*/
|
||||
public int getBeeStingerCount() {
|
||||
return super.metadata.getIndex(OFFSET + 5, 0);
|
||||
return metadata.get(MetadataDef.LivingEntity.NUMBER_OF_BEE_STINGERS);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -95,16 +88,16 @@ public class LivingEntityMeta extends EntityMeta {
|
||||
* @param value The amount of bee stingers to set, use 0 to clear all stingers
|
||||
*/
|
||||
public void setBeeStingerCount(int value) {
|
||||
super.metadata.setIndex(OFFSET + 5, Metadata.VarInt(value));
|
||||
metadata.set(MetadataDef.LivingEntity.NUMBER_OF_BEE_STINGERS, value);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Point getBedInWhichSleepingPosition() {
|
||||
return super.metadata.getIndex(OFFSET + 6, null);
|
||||
return metadata.get(MetadataDef.LivingEntity.LOCATION_OF_BED);
|
||||
}
|
||||
|
||||
public void setBedInWhichSleepingPosition(@Nullable Point value) {
|
||||
super.metadata.setIndex(OFFSET + 6, Metadata.OptBlockPosition(value));
|
||||
metadata.set(MetadataDef.LivingEntity.LOCATION_OF_BED, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,43 +1,37 @@
|
||||
package net.minestom.server.entity.metadata;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MobMeta extends LivingEntityMeta {
|
||||
public static final byte OFFSET = LivingEntityMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
private final static byte NO_AI_BIT = 0x01;
|
||||
private final static byte IS_LEFT_HANDED_BIT = 0x02;
|
||||
private final static byte IS_AGGRESSIVE_BIT = 0x04;
|
||||
|
||||
protected MobMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean isNoAi() {
|
||||
return getMaskBit(OFFSET, NO_AI_BIT);
|
||||
return metadata.get(MetadataDef.Mob.NO_AI);
|
||||
}
|
||||
|
||||
public void setNoAi(boolean value) {
|
||||
setMaskBit(OFFSET, NO_AI_BIT, value);
|
||||
metadata.set(MetadataDef.Mob.NO_AI, value);
|
||||
}
|
||||
|
||||
public boolean isLeftHanded() {
|
||||
return getMaskBit(OFFSET, IS_LEFT_HANDED_BIT);
|
||||
return metadata.get(MetadataDef.Mob.IS_LEFT_HANDED);
|
||||
}
|
||||
|
||||
public void setLeftHanded(boolean value) {
|
||||
setMaskBit(OFFSET, IS_LEFT_HANDED_BIT, value);
|
||||
metadata.set(MetadataDef.Mob.IS_LEFT_HANDED, value);
|
||||
}
|
||||
|
||||
public boolean isAggressive() {
|
||||
return getMaskBit(OFFSET, IS_AGGRESSIVE_BIT);
|
||||
return metadata.get(MetadataDef.Mob.IS_AGGRESSIVE);
|
||||
}
|
||||
|
||||
public void setAggressive(boolean value) {
|
||||
setMaskBit(OFFSET, IS_AGGRESSIVE_BIT, value);
|
||||
metadata.set(MetadataDef.Mob.IS_AGGRESSIVE, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,9 +5,6 @@ import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PathfinderMobMeta extends MobMeta {
|
||||
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
protected PathfinderMobMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
@ -3,131 +3,124 @@ package net.minestom.server.entity.metadata;
|
||||
import net.kyori.adventure.nbt.BinaryTag;
|
||||
import net.kyori.adventure.nbt.CompoundBinaryTag;
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class PlayerMeta extends LivingEntityMeta {
|
||||
public static final byte OFFSET = LivingEntityMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 5;
|
||||
|
||||
private final static byte CAPE_BIT = 0x01;
|
||||
private final static byte JACKET_BIT = 0x02;
|
||||
private final static byte LEFT_SLEEVE_BIT = 0x04;
|
||||
private final static byte RIGHT_SLEEVE_BIT = 0x08;
|
||||
private final static byte LEFT_LEG_BIT = 0x10;
|
||||
private final static byte RIGHT_LEG_BIT = 0x20;
|
||||
private final static byte HAT_BIT = 0x40;
|
||||
|
||||
public PlayerMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public float getAdditionalHearts() {
|
||||
return super.metadata.getIndex(OFFSET, 0F);
|
||||
return metadata.get(MetadataDef.Player.ADDITIONAL_HEARTS);
|
||||
}
|
||||
|
||||
public void setAdditionalHearts(float value) {
|
||||
super.metadata.setIndex(OFFSET, Metadata.Float(value));
|
||||
metadata.set(MetadataDef.Player.ADDITIONAL_HEARTS, value);
|
||||
}
|
||||
|
||||
public int getScore() {
|
||||
return super.metadata.getIndex(OFFSET + 1, 0);
|
||||
return metadata.get(MetadataDef.Player.SCORE);
|
||||
}
|
||||
|
||||
public void setScore(int value) {
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.VarInt(value));
|
||||
metadata.set(MetadataDef.Player.SCORE, value);
|
||||
}
|
||||
|
||||
public boolean isCapeEnabled() {
|
||||
return getMaskBit(OFFSET + 2, CAPE_BIT);
|
||||
return metadata.get(MetadataDef.Player.IS_CAPE_ENABLED);
|
||||
}
|
||||
|
||||
public void setCapeEnabled(boolean value) {
|
||||
setMaskBit(OFFSET + 2, CAPE_BIT, value);
|
||||
metadata.set(MetadataDef.Player.IS_CAPE_ENABLED, value);
|
||||
}
|
||||
|
||||
public boolean isJacketEnabled() {
|
||||
return getMaskBit(OFFSET + 2, JACKET_BIT);
|
||||
return metadata.get(MetadataDef.Player.IS_JACKET_ENABLED);
|
||||
}
|
||||
|
||||
public void setJacketEnabled(boolean value) {
|
||||
setMaskBit(OFFSET + 2, JACKET_BIT, value);
|
||||
metadata.set(MetadataDef.Player.IS_JACKET_ENABLED, value);
|
||||
}
|
||||
|
||||
public boolean isLeftSleeveEnabled() {
|
||||
return getMaskBit(OFFSET + 2, LEFT_SLEEVE_BIT);
|
||||
return metadata.get(MetadataDef.Player.IS_LEFT_SLEEVE_ENABLED);
|
||||
}
|
||||
|
||||
public void setLeftSleeveEnabled(boolean value) {
|
||||
setMaskBit(OFFSET + 2, LEFT_SLEEVE_BIT, value);
|
||||
metadata.set(MetadataDef.Player.IS_LEFT_SLEEVE_ENABLED, value);
|
||||
}
|
||||
|
||||
public boolean isRightSleeveEnabled() {
|
||||
return getMaskBit(OFFSET + 2, RIGHT_SLEEVE_BIT);
|
||||
return metadata.get(MetadataDef.Player.IS_RIGHT_SLEEVE_ENABLED);
|
||||
}
|
||||
|
||||
public void setRightSleeveEnabled(boolean value) {
|
||||
setMaskBit(OFFSET + 2, RIGHT_SLEEVE_BIT, value);
|
||||
metadata.set(MetadataDef.Player.IS_RIGHT_SLEEVE_ENABLED, value);
|
||||
}
|
||||
|
||||
public boolean isLeftLegEnabled() {
|
||||
return getMaskBit(OFFSET + 2, LEFT_LEG_BIT);
|
||||
return metadata.get(MetadataDef.Player.IS_LEFT_PANTS_LEG_ENABLED);
|
||||
}
|
||||
|
||||
public void setLeftLegEnabled(boolean value) {
|
||||
setMaskBit(OFFSET + 2, LEFT_LEG_BIT, value);
|
||||
metadata.set(MetadataDef.Player.IS_LEFT_PANTS_LEG_ENABLED, value);
|
||||
}
|
||||
|
||||
public boolean isRightLegEnabled() {
|
||||
return getMaskBit(OFFSET + 2, RIGHT_LEG_BIT);
|
||||
return metadata.get(MetadataDef.Player.IS_RIGHT_PANTS_LEG_ENABLED);
|
||||
}
|
||||
|
||||
public void setRightLegEnabled(boolean value) {
|
||||
setMaskBit(OFFSET + 2, RIGHT_LEG_BIT, value);
|
||||
metadata.set(MetadataDef.Player.IS_RIGHT_PANTS_LEG_ENABLED, value);
|
||||
}
|
||||
|
||||
public boolean isHatEnabled() {
|
||||
return getMaskBit(OFFSET + 2, HAT_BIT);
|
||||
return metadata.get(MetadataDef.Player.IS_HAT_ENABLED);
|
||||
}
|
||||
|
||||
public void setHatEnabled(boolean value) {
|
||||
setMaskBit(OFFSET + 2, HAT_BIT, value);
|
||||
metadata.set(MetadataDef.Player.IS_HAT_ENABLED, value);
|
||||
}
|
||||
|
||||
public byte getDisplayedSkinParts() {
|
||||
return metadata.get(MetadataDef.Player.DISPLAYED_SKIN_PARTS_FLAGS);
|
||||
}
|
||||
|
||||
public void setDisplayedSkinParts(byte skinDisplayByte) {
|
||||
super.metadata.setIndex(OFFSET + 2, Metadata.Byte(skinDisplayByte));
|
||||
metadata.set(MetadataDef.Player.DISPLAYED_SKIN_PARTS_FLAGS, skinDisplayByte);
|
||||
}
|
||||
|
||||
public boolean isRightMainHand() {
|
||||
return super.metadata.getIndex(OFFSET + 3, (byte) 1) == (byte) 1;
|
||||
return metadata.get(MetadataDef.Player.MAIN_HAND) == (byte) 1;
|
||||
}
|
||||
|
||||
public void setRightMainHand(boolean value) {
|
||||
super.metadata.setIndex(OFFSET + 3, Metadata.Byte(value ? (byte) 1 : (byte) 0));
|
||||
metadata.set(MetadataDef.Player.MAIN_HAND, value ? (byte) 1 : (byte) 0);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@NotNull
|
||||
public BinaryTag getLeftShoulderEntityData() {
|
||||
return super.metadata.getIndex(OFFSET + 4, null);
|
||||
return metadata.get(MetadataDef.Player.LEFT_SHOULDER_ENTITY_DATA);
|
||||
}
|
||||
|
||||
public void setLeftShoulderEntityData(@Nullable BinaryTag value) {
|
||||
if (value == null) value = CompoundBinaryTag.empty();
|
||||
|
||||
super.metadata.setIndex(OFFSET + 4, Metadata.NBT(value));
|
||||
metadata.set(MetadataDef.Player.LEFT_SHOULDER_ENTITY_DATA, value);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@NotNull
|
||||
public BinaryTag getRightShoulderEntityData() {
|
||||
return super.metadata.getIndex(OFFSET + 5, null);
|
||||
return metadata.get(MetadataDef.Player.RIGHT_SHOULDER_ENTITY_DATA);
|
||||
}
|
||||
|
||||
public void setRightShoulderEntityData(@Nullable BinaryTag value) {
|
||||
if (value == null) value = CompoundBinaryTag.empty();
|
||||
|
||||
super.metadata.setIndex(OFFSET + 5, Metadata.NBT(value));
|
||||
metadata.set(MetadataDef.Player.RIGHT_SHOULDER_ENTITY_DATA, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,9 +6,6 @@ import net.minestom.server.entity.metadata.MobMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AmbientCreatureMeta extends MobMeta {
|
||||
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
protected AmbientCreatureMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
@ -1,25 +1,21 @@
|
||||
package net.minestom.server.entity.metadata.ambient;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class BatMeta extends AmbientCreatureMeta {
|
||||
public static final byte OFFSET = AmbientCreatureMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
private final static byte IS_HANGING_BIT = 0x01;
|
||||
|
||||
public BatMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean isHanging() {
|
||||
return getMaskBit(OFFSET, IS_HANGING_BIT);
|
||||
return metadata.get(MetadataDef.Bat.IS_HANGING);
|
||||
}
|
||||
|
||||
public void setHanging(boolean value) {
|
||||
setMaskBit(OFFSET, IS_HANGING_BIT, value);
|
||||
metadata.set(MetadataDef.Bat.IS_HANGING, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,70 +1,61 @@
|
||||
package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AbstractHorseMeta extends AnimalMeta {
|
||||
public static final byte OFFSET = AnimalMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
private final static byte TAMED_BIT = 0x02;
|
||||
private final static byte SADDLED_BIT = 0x04;
|
||||
private final static byte HAS_BRED_BIT = 0x08;
|
||||
private final static byte EATING_BIT = 0x10;
|
||||
private final static byte REARING_BIT = 0x20;
|
||||
private final static byte MOUTH_OPEN_BIT = 0x40;
|
||||
|
||||
protected AbstractHorseMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean isTamed() {
|
||||
return getMaskBit(OFFSET, TAMED_BIT);
|
||||
return metadata.get(MetadataDef.AbstractHorse.IS_TAME);
|
||||
}
|
||||
|
||||
public void setTamed(boolean value) {
|
||||
setMaskBit(OFFSET, TAMED_BIT, value);
|
||||
metadata.set(MetadataDef.AbstractHorse.IS_TAME, value);
|
||||
}
|
||||
|
||||
public boolean isSaddled() {
|
||||
return getMaskBit(OFFSET, SADDLED_BIT);
|
||||
return metadata.get(MetadataDef.AbstractHorse.IS_SADDLED);
|
||||
}
|
||||
|
||||
public void setSaddled(boolean value) {
|
||||
setMaskBit(OFFSET, SADDLED_BIT, value);
|
||||
metadata.set(MetadataDef.AbstractHorse.IS_SADDLED, value);
|
||||
}
|
||||
|
||||
public boolean isHasBred() {
|
||||
return getMaskBit(OFFSET, HAS_BRED_BIT);
|
||||
return metadata.get(MetadataDef.AbstractHorse.HAS_BRED);
|
||||
}
|
||||
|
||||
public void setHasBred(boolean value) {
|
||||
setMaskBit(OFFSET, HAS_BRED_BIT, value);
|
||||
metadata.set(MetadataDef.AbstractHorse.HAS_BRED, value);
|
||||
}
|
||||
|
||||
public boolean isEating() {
|
||||
return getMaskBit(OFFSET, EATING_BIT);
|
||||
return metadata.get(MetadataDef.AbstractHorse.IS_EATING);
|
||||
}
|
||||
|
||||
public void setEating(boolean value) {
|
||||
setMaskBit(OFFSET, EATING_BIT, value);
|
||||
metadata.set(MetadataDef.AbstractHorse.IS_EATING, value);
|
||||
}
|
||||
|
||||
public boolean isRearing() {
|
||||
return getMaskBit(OFFSET, REARING_BIT);
|
||||
return metadata.get(MetadataDef.AbstractHorse.IS_REARING);
|
||||
}
|
||||
|
||||
public void setRearing(boolean value) {
|
||||
setMaskBit(OFFSET, REARING_BIT, value);
|
||||
metadata.set(MetadataDef.AbstractHorse.IS_REARING, value);
|
||||
}
|
||||
|
||||
public boolean isMouthOpen() {
|
||||
return getMaskBit(OFFSET, MOUTH_OPEN_BIT);
|
||||
return metadata.get(MetadataDef.AbstractHorse.IS_MOUTH_OPEN);
|
||||
}
|
||||
|
||||
public void setMouthOpen(boolean value) {
|
||||
setMaskBit(OFFSET, MOUTH_OPEN_BIT, value);
|
||||
metadata.set(MetadataDef.AbstractHorse.IS_MOUTH_OPEN, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,9 +6,6 @@ import net.minestom.server.entity.metadata.AgeableMobMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AnimalMeta extends AgeableMobMeta {
|
||||
public static final byte OFFSET = AgeableMobMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
protected AnimalMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
@ -1,26 +1,23 @@
|
||||
package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ArmadilloMeta extends AnimalMeta {
|
||||
public static final byte OFFSET = AnimalMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public ArmadilloMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public State getState() {
|
||||
return super.metadata.getIndex(OFFSET, State.IDLE);
|
||||
return metadata.get(MetadataDef.Armadillo.STATE);
|
||||
}
|
||||
|
||||
public void setState(@NotNull State value) {
|
||||
super.metadata.setIndex(OFFSET, Metadata.ArmadilloState(value));
|
||||
metadata.set(MetadataDef.Armadillo.STATE, value);
|
||||
}
|
||||
|
||||
public enum State {
|
||||
|
@ -1,52 +1,45 @@
|
||||
package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class BeeMeta extends AnimalMeta {
|
||||
public static final byte OFFSET = AnimalMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 2;
|
||||
|
||||
private final static byte ANGRY_BIT = 0x02;
|
||||
private final static byte HAS_STUNG_BIT = 0x04;
|
||||
private final static byte HAS_NECTAR_BIT = 0x08;
|
||||
|
||||
public BeeMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean isAngry() {
|
||||
return getMaskBit(OFFSET, ANGRY_BIT);
|
||||
return metadata.get(MetadataDef.Bee.IS_ANGRY);
|
||||
}
|
||||
|
||||
public void setAngry(boolean value) {
|
||||
setMaskBit(OFFSET, ANGRY_BIT, value);
|
||||
metadata.set(MetadataDef.Bee.IS_ANGRY, value);
|
||||
}
|
||||
|
||||
public boolean isHasStung() {
|
||||
return getMaskBit(OFFSET, HAS_STUNG_BIT);
|
||||
return metadata.get(MetadataDef.Bee.HAS_STUNG);
|
||||
}
|
||||
|
||||
public void setHasStung(boolean value) {
|
||||
setMaskBit(OFFSET, HAS_STUNG_BIT, value);
|
||||
metadata.set(MetadataDef.Bee.HAS_STUNG, value);
|
||||
}
|
||||
|
||||
public boolean isHasNectar() {
|
||||
return getMaskBit(OFFSET, HAS_NECTAR_BIT);
|
||||
return metadata.get(MetadataDef.Bee.HAS_NECTAR);
|
||||
}
|
||||
|
||||
public void setHasNectar(boolean value) {
|
||||
setMaskBit(OFFSET, HAS_NECTAR_BIT, value);
|
||||
metadata.set(MetadataDef.Bee.HAS_NECTAR, value);
|
||||
}
|
||||
|
||||
public int getAngerTicks() {
|
||||
return super.metadata.getIndex(OFFSET + 1, 0);
|
||||
return metadata.get(MetadataDef.Bee.ANGER_TIME_TICKS);
|
||||
}
|
||||
|
||||
public void setAngerTicks(int value) {
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.VarInt(value));
|
||||
metadata.set(MetadataDef.Bee.ANGER_TIME_TICKS, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,31 +1,28 @@
|
||||
package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CamelMeta extends AbstractHorseMeta {
|
||||
public static final byte OFFSET = AbstractHorseMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public CamelMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean isDashing() {
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
return metadata.get(MetadataDef.Camel.DASHING);
|
||||
}
|
||||
|
||||
public void setDashing(boolean value) {
|
||||
super.metadata.setIndex(OFFSET, Metadata.Boolean(value));
|
||||
metadata.set(MetadataDef.Camel.DASHING, value);
|
||||
}
|
||||
|
||||
public long getLastPoseChangeTick() {
|
||||
return super.metadata.getIndex(OFFSET + 1, 0L);
|
||||
return metadata.get(MetadataDef.Camel.LAST_POSE_CHANGE_TICK);
|
||||
}
|
||||
|
||||
public void setLastPoseChangeTick(long value) {
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.VarLong(value));
|
||||
metadata.set(MetadataDef.Camel.LAST_POSE_CHANGE_TICK, value);
|
||||
}
|
||||
}
|
||||
|
@ -1,24 +1,21 @@
|
||||
package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ChestedHorseMeta extends AbstractHorseMeta {
|
||||
public static final byte OFFSET = AbstractHorseMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
protected ChestedHorseMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean isHasChest() {
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
return metadata.get(MetadataDef.ChestedHorse.HAS_CHEST);
|
||||
}
|
||||
|
||||
public void setHasChest(boolean value) {
|
||||
super.metadata.setIndex(OFFSET, Metadata.Boolean(value));
|
||||
metadata.set(MetadataDef.ChestedHorse.HAS_CHEST, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,9 +5,6 @@ import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ChickenMeta extends AnimalMeta {
|
||||
public static final byte OFFSET = AnimalMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public ChickenMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
@ -5,9 +5,6 @@ import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CowMeta extends AnimalMeta {
|
||||
public static final byte OFFSET = AnimalMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public CowMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
@ -5,9 +5,6 @@ import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class DonkeyMeta extends ChestedHorseMeta {
|
||||
public static final byte OFFSET = AnimalMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public DonkeyMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@ -9,102 +9,91 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.util.UUID;
|
||||
|
||||
public class FoxMeta extends AnimalMeta {
|
||||
public static final byte OFFSET = AnimalMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 4;
|
||||
|
||||
private final static byte SITTING_BIT = 0x01;
|
||||
private final static byte CROUCHING_BIT = 0x04;
|
||||
private final static byte INTERESTED_BIT = 0x08;
|
||||
private final static byte POUNCING_BIT = 0x10;
|
||||
private final static byte SLEEPING_BIT = 0x20;
|
||||
private final static byte FACEPLANTED_BIT = 0x40;
|
||||
private final static byte DEFENDING_BIT = (byte) 0x80;
|
||||
|
||||
public FoxMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Type getType() {
|
||||
return Type.VALUES[super.metadata.getIndex(OFFSET, 0)];
|
||||
return Type.VALUES[metadata.get(MetadataDef.Fox.TYPE)];
|
||||
}
|
||||
|
||||
public void setType(@NotNull Type type) {
|
||||
super.metadata.setIndex(OFFSET, Metadata.VarInt(type.ordinal()));
|
||||
metadata.set(MetadataDef.Fox.TYPE, type.ordinal());
|
||||
}
|
||||
|
||||
public boolean isSitting() {
|
||||
return getMaskBit(OFFSET + 1, SITTING_BIT);
|
||||
return metadata.get(MetadataDef.Fox.IS_SITTING);
|
||||
}
|
||||
|
||||
public void setSitting(boolean value) {
|
||||
setMaskBit(OFFSET + 1, SITTING_BIT, value);
|
||||
metadata.set(MetadataDef.Fox.IS_SITTING, value);
|
||||
}
|
||||
|
||||
public boolean isFoxSneaking() {
|
||||
return getMaskBit(OFFSET + 1, CROUCHING_BIT);
|
||||
return metadata.get(MetadataDef.Fox.IS_SITTING);
|
||||
}
|
||||
|
||||
public void setFoxSneaking(boolean value) {
|
||||
setMaskBit(OFFSET + 1, CROUCHING_BIT, value);
|
||||
metadata.set(MetadataDef.Fox.IS_SITTING, value);
|
||||
}
|
||||
|
||||
public boolean isInterested() {
|
||||
return getMaskBit(OFFSET + 1, INTERESTED_BIT);
|
||||
return metadata.get(MetadataDef.Fox.IS_INTERESTED);
|
||||
}
|
||||
|
||||
public void setInterested(boolean value) {
|
||||
setMaskBit(OFFSET + 1, INTERESTED_BIT, value);
|
||||
metadata.set(MetadataDef.Fox.IS_INTERESTED, value);
|
||||
}
|
||||
|
||||
public boolean isPouncing() {
|
||||
return getMaskBit(OFFSET + 1, POUNCING_BIT);
|
||||
return metadata.get(MetadataDef.Fox.IS_POUNCING);
|
||||
}
|
||||
|
||||
public void setPouncing(boolean value) {
|
||||
setMaskBit(OFFSET + 1, POUNCING_BIT, value);
|
||||
metadata.set(MetadataDef.Fox.IS_POUNCING, value);
|
||||
}
|
||||
|
||||
public boolean isSleeping() {
|
||||
return getMaskBit(OFFSET + 1, SLEEPING_BIT);
|
||||
return metadata.get(MetadataDef.Fox.IS_SLEEPING);
|
||||
}
|
||||
|
||||
public void setSleeping(boolean value) {
|
||||
setMaskBit(OFFSET + 1, SLEEPING_BIT, value);
|
||||
metadata.set(MetadataDef.Fox.IS_SLEEPING, value);
|
||||
}
|
||||
|
||||
public boolean isFaceplanted() {
|
||||
return getMaskBit(OFFSET + 1, FACEPLANTED_BIT);
|
||||
return metadata.get(MetadataDef.Fox.IS_FACEPLANTED);
|
||||
}
|
||||
|
||||
public void setFaceplanted(boolean value) {
|
||||
setMaskBit(OFFSET + 1, FACEPLANTED_BIT, value);
|
||||
metadata.set(MetadataDef.Fox.IS_FACEPLANTED, value);
|
||||
}
|
||||
|
||||
public boolean isDefending() {
|
||||
return getMaskBit(OFFSET + 1, DEFENDING_BIT);
|
||||
return metadata.get(MetadataDef.Fox.IS_DEFENDING);
|
||||
}
|
||||
|
||||
public void setDefending(boolean value) {
|
||||
setMaskBit(OFFSET + 1, DEFENDING_BIT, value);
|
||||
metadata.set(MetadataDef.Fox.IS_DEFENDING, value);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public UUID getFirstUUID() {
|
||||
return super.metadata.getIndex(OFFSET + 2, null);
|
||||
return metadata.get(MetadataDef.Fox.FIRST_UUID);
|
||||
}
|
||||
|
||||
public void setFirstUUID(@Nullable UUID value) {
|
||||
super.metadata.setIndex(OFFSET + 2, Metadata.OptUUID(value));
|
||||
metadata.set(MetadataDef.Fox.FIRST_UUID, value);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public UUID getSecondUUID() {
|
||||
return super.metadata.getIndex(OFFSET + 3, null);
|
||||
return metadata.get(MetadataDef.Fox.SECOND_UUID);
|
||||
}
|
||||
|
||||
public void setSecondUUID(@Nullable UUID value) {
|
||||
super.metadata.setIndex(OFFSET + 3, Metadata.OptUUID(value));
|
||||
metadata.set(MetadataDef.Fox.SECOND_UUID, value);
|
||||
}
|
||||
|
||||
public enum Type {
|
||||
|
@ -1,38 +1,33 @@
|
||||
package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class FrogMeta extends AnimalMeta {
|
||||
public static final byte OFFSET = AnimalMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 2;
|
||||
|
||||
public FrogMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public Variant getVariant() {
|
||||
return super.metadata.getIndex(OFFSET, Variant.TEMPERATE);
|
||||
return metadata.get(MetadataDef.Frog.VARIANT);
|
||||
}
|
||||
|
||||
public void setVariant(@NotNull Variant value) {
|
||||
super.metadata.setIndex(OFFSET, Metadata.FrogVariant(value));
|
||||
metadata.set(MetadataDef.Frog.VARIANT, value);
|
||||
}
|
||||
|
||||
public @Nullable Integer getTongueTarget() {
|
||||
return super.metadata.getIndex(OFFSET + 1, null);
|
||||
return metadata.get(MetadataDef.Frog.TONGUE_TARGET);
|
||||
}
|
||||
|
||||
|
||||
public void setTongueTarget(@Nullable Integer value) {
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.OptVarInt(value));
|
||||
metadata.set(MetadataDef.Frog.TONGUE_TARGET, value);
|
||||
}
|
||||
|
||||
|
||||
public enum Variant {
|
||||
TEMPERATE,
|
||||
WARM,
|
||||
|
@ -1,39 +1,36 @@
|
||||
package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class GoatMeta extends AnimalMeta {
|
||||
public static final byte OFFSET = AnimalMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 3;
|
||||
|
||||
public GoatMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean isScreaming() {
|
||||
return metadata.getIndex(OFFSET, false);
|
||||
return metadata.get(MetadataDef.Goat.IS_SCREAMING_GOAT);
|
||||
}
|
||||
|
||||
public void setScreaming(boolean screaming) {
|
||||
metadata.setIndex(OFFSET, Metadata.Boolean(screaming));
|
||||
metadata.set(MetadataDef.Goat.IS_SCREAMING_GOAT, screaming);
|
||||
}
|
||||
|
||||
public boolean hasLeftHorn() {
|
||||
return metadata.getIndex(OFFSET + 1, true);
|
||||
return metadata.get(MetadataDef.Goat.HAS_LEFT_HORN);
|
||||
}
|
||||
|
||||
public void setLeftHorn(boolean leftHorn) {
|
||||
metadata.setIndex(OFFSET + 1, Metadata.Boolean(leftHorn));
|
||||
metadata.set(MetadataDef.Goat.HAS_LEFT_HORN, leftHorn);
|
||||
}
|
||||
|
||||
public boolean hasRightHorn() {
|
||||
return metadata.getIndex(OFFSET + 2, true);
|
||||
return metadata.get(MetadataDef.Goat.HAS_RIGHT_HORN);
|
||||
}
|
||||
|
||||
public void setRightHorn(boolean rightHorn) {
|
||||
metadata.setIndex(OFFSET + 2, Metadata.Boolean(rightHorn));
|
||||
metadata.set(MetadataDef.Goat.HAS_RIGHT_HORN, rightHorn);
|
||||
}
|
||||
}
|
||||
|
@ -1,24 +1,21 @@
|
||||
package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class HoglinMeta extends AnimalMeta {
|
||||
public static final byte OFFSET = AnimalMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public HoglinMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean isImmuneToZombification() {
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
return metadata.get(MetadataDef.Hoglin.IMMUNE_ZOMBIFICATION);
|
||||
}
|
||||
|
||||
public void setImmuneToZombification(boolean value) {
|
||||
super.metadata.setIndex(OFFSET, Metadata.Boolean(value));
|
||||
metadata.set(MetadataDef.Hoglin.IMMUNE_ZOMBIFICATION, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,24 +1,21 @@
|
||||
package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class HorseMeta extends AbstractHorseMeta {
|
||||
public static final byte OFFSET = AbstractHorseMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public HorseMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public Variant getVariant() {
|
||||
return getVariantFromID(super.metadata.getIndex(OFFSET, 0));
|
||||
return getVariantFromID(metadata.get(MetadataDef.Horse.VARIANT));
|
||||
}
|
||||
|
||||
public void setVariant(Variant variant) {
|
||||
super.metadata.setIndex(OFFSET, Metadata.VarInt(getVariantID(variant.marking, variant.color)));
|
||||
metadata.set(MetadataDef.Horse.VARIANT, getVariantID(variant.marking, variant.color));
|
||||
}
|
||||
|
||||
public static int getVariantID(@NotNull Marking marking, @NotNull Color color) {
|
||||
|
@ -1,40 +1,37 @@
|
||||
package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class LlamaMeta extends ChestedHorseMeta {
|
||||
public static final byte OFFSET = ChestedHorseMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 3;
|
||||
|
||||
public LlamaMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public int getStrength() {
|
||||
return super.metadata.getIndex(OFFSET, 0);
|
||||
return metadata.get(MetadataDef.Llama.STRENGTH);
|
||||
}
|
||||
|
||||
public void setStrength(int value) {
|
||||
super.metadata.setIndex(OFFSET, Metadata.VarInt(value));
|
||||
metadata.set(MetadataDef.Llama.STRENGTH, value);
|
||||
}
|
||||
|
||||
public int getCarpetColor() {
|
||||
return super.metadata.getIndex(OFFSET + 1, -1);
|
||||
return metadata.get(MetadataDef.Llama.CARPET_COLOR);
|
||||
}
|
||||
|
||||
public void setCarpetColor(int value) {
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.VarInt(value));
|
||||
metadata.set(MetadataDef.Llama.CARPET_COLOR, value);
|
||||
}
|
||||
|
||||
public Variant getVariant() {
|
||||
return Variant.VALUES[super.metadata.getIndex(OFFSET + 2, 0)];
|
||||
return Variant.VALUES[metadata.get(MetadataDef.Llama.VARIANT)];
|
||||
}
|
||||
|
||||
public void setVariant(Variant value) {
|
||||
super.metadata.setIndex(OFFSET + 2, Metadata.VarInt(value.ordinal()));
|
||||
metadata.set(MetadataDef.Llama.VARIANT, value.ordinal());
|
||||
}
|
||||
|
||||
public enum Variant {
|
||||
|
@ -1,27 +1,24 @@
|
||||
package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class MooshroomMeta extends CowMeta {
|
||||
public static final byte OFFSET = CowMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public MooshroomMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Variant getVariant() {
|
||||
return Variant.valueOf(super.metadata.getIndex(OFFSET, "red").toUpperCase(Locale.ROOT));
|
||||
return Variant.valueOf(metadata.get(MetadataDef.Mooshroom.VARIANT).toUpperCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
public void setVariant(@NotNull Variant value) {
|
||||
super.metadata.setIndex(OFFSET, Metadata.String(value.name().toLowerCase(Locale.ROOT)));
|
||||
metadata.set(MetadataDef.Mooshroom.VARIANT, value.name().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
public enum Variant {
|
||||
|
@ -5,9 +5,6 @@ import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MuleMeta extends ChestedHorseMeta {
|
||||
public static final byte OFFSET = ChestedHorseMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public MuleMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
@ -1,24 +1,21 @@
|
||||
package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class OcelotMeta extends AnimalMeta {
|
||||
public static final byte OFFSET = AnimalMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public OcelotMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean isTrusting() {
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
return metadata.get(MetadataDef.Ocelot.IS_TRUSTING);
|
||||
}
|
||||
|
||||
public void setTrusting(boolean value) {
|
||||
super.metadata.setIndex(OFFSET, Metadata.Boolean(value));
|
||||
metadata.set(MetadataDef.Ocelot.IS_TRUSTING, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,95 +1,87 @@
|
||||
package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PandaMeta extends AnimalMeta {
|
||||
public static final byte OFFSET = AnimalMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 6;
|
||||
|
||||
private final static byte SNEEZING_BIT = 0x02;
|
||||
private final static byte ROLLING_BIT = 0x04;
|
||||
private final static byte SITTING_BIT = 0x08;
|
||||
private final static byte ON_BACK_BIT = 0x10;
|
||||
|
||||
public PandaMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public int getBreedTimer() {
|
||||
return super.metadata.getIndex(OFFSET, 0);
|
||||
return metadata.get(MetadataDef.Panda.BREED_TIMER);
|
||||
}
|
||||
|
||||
public void setBreedTimer(int value) {
|
||||
super.metadata.setIndex(OFFSET, Metadata.VarInt(value));
|
||||
metadata.set(MetadataDef.Panda.BREED_TIMER, value);
|
||||
}
|
||||
|
||||
public int getSneezeTimer() {
|
||||
return super.metadata.getIndex(OFFSET + 1, 0);
|
||||
return metadata.get(MetadataDef.Panda.SNEEZE_TIMER);
|
||||
}
|
||||
|
||||
public void setSneezeTimer(int value) {
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.VarInt(value));
|
||||
metadata.set(MetadataDef.Panda.SNEEZE_TIMER, value);
|
||||
}
|
||||
|
||||
public int getEatTimer() {
|
||||
return super.metadata.getIndex(OFFSET + 2, 0);
|
||||
return metadata.get(MetadataDef.Panda.EAT_TIMER);
|
||||
}
|
||||
|
||||
public void setEatTimer(int value) {
|
||||
super.metadata.setIndex(OFFSET + 2, Metadata.VarInt(value));
|
||||
metadata.set(MetadataDef.Panda.EAT_TIMER, value);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Gene getMainGene() {
|
||||
return Gene.VALUES[super.metadata.getIndex(OFFSET + 3, (byte) 0)];
|
||||
return Gene.VALUES[metadata.get(MetadataDef.Panda.MAIN_GENE)];
|
||||
}
|
||||
|
||||
public void setMainGene(@NotNull Gene value) {
|
||||
super.metadata.setIndex(OFFSET + 3, Metadata.Byte((byte) value.ordinal()));
|
||||
metadata.set(MetadataDef.Panda.MAIN_GENE, (byte) value.ordinal());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Gene getHiddenGene() {
|
||||
return Gene.VALUES[super.metadata.getIndex(OFFSET + 4, (byte) 0)];
|
||||
return Gene.VALUES[metadata.get(MetadataDef.Panda.HIDDEN_GENE)];
|
||||
}
|
||||
|
||||
public void setHiddenGene(@NotNull Gene value) {
|
||||
super.metadata.setIndex(OFFSET + 4, Metadata.Byte((byte) value.ordinal()));
|
||||
metadata.set(MetadataDef.Panda.HIDDEN_GENE, (byte) value.ordinal());
|
||||
}
|
||||
|
||||
public boolean isSneezing() {
|
||||
return getMaskBit(OFFSET + 5, SNEEZING_BIT);
|
||||
return metadata.get(MetadataDef.Panda.IS_SNEEZING);
|
||||
}
|
||||
|
||||
public void setSneezing(boolean value) {
|
||||
setMaskBit(OFFSET + 5, SNEEZING_BIT, value);
|
||||
metadata.set(MetadataDef.Panda.IS_SNEEZING, value);
|
||||
}
|
||||
|
||||
public boolean isRolling() {
|
||||
return getMaskBit(OFFSET + 5, ROLLING_BIT);
|
||||
return metadata.get(MetadataDef.Panda.IS_ROLLING);
|
||||
}
|
||||
|
||||
public void setRolling(boolean value) {
|
||||
setMaskBit(OFFSET + 5, ROLLING_BIT, value);
|
||||
metadata.set(MetadataDef.Panda.IS_ROLLING, value);
|
||||
}
|
||||
|
||||
public boolean isSitting() {
|
||||
return getMaskBit(OFFSET + 5, SITTING_BIT);
|
||||
return metadata.get(MetadataDef.Panda.IS_SITTING);
|
||||
}
|
||||
|
||||
public void setSitting(boolean value) {
|
||||
setMaskBit(OFFSET + 5, SITTING_BIT, value);
|
||||
metadata.set(MetadataDef.Panda.IS_SITTING, value);
|
||||
}
|
||||
|
||||
public boolean isOnBack() {
|
||||
return getMaskBit(OFFSET + 5, ON_BACK_BIT);
|
||||
return metadata.get(MetadataDef.Panda.IS_ON_BACK);
|
||||
}
|
||||
|
||||
public void setOnBack(boolean value) {
|
||||
setMaskBit(OFFSET + 5, ON_BACK_BIT, value);
|
||||
metadata.set(MetadataDef.Panda.IS_ON_BACK, value);
|
||||
}
|
||||
|
||||
public enum Gene {
|
||||
|
@ -1,32 +1,29 @@
|
||||
package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PigMeta extends AnimalMeta {
|
||||
public static final byte OFFSET = AnimalMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 2;
|
||||
|
||||
public PigMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean isHasSaddle() {
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
return metadata.get(MetadataDef.Pig.HAS_SADDLE);
|
||||
}
|
||||
|
||||
public void setHasSaddle(boolean value) {
|
||||
super.metadata.setIndex(OFFSET, Metadata.Boolean(value));
|
||||
metadata.set(MetadataDef.Pig.HAS_SADDLE, value);
|
||||
}
|
||||
|
||||
public int getTimeToBoost() {
|
||||
return super.metadata.getIndex(OFFSET + 1, 0);
|
||||
return metadata.get(MetadataDef.Pig.BOOST_TIME);
|
||||
}
|
||||
|
||||
public void setTimeToBoost(int value) {
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.VarInt(value));
|
||||
metadata.set(MetadataDef.Pig.BOOST_TIME, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,24 +1,21 @@
|
||||
package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PolarBearMeta extends AnimalMeta {
|
||||
public static final byte OFFSET = AnimalMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public PolarBearMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean isStandingUp() {
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
return metadata.get(MetadataDef.PolarBear.IS_STANDING_UP);
|
||||
}
|
||||
|
||||
public void setStandingUp(boolean value) {
|
||||
super.metadata.setIndex(OFFSET, Metadata.Boolean(value));
|
||||
metadata.set(MetadataDef.PolarBear.IS_STANDING_UP, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,21 +1,18 @@
|
||||
package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class RabbitMeta extends AnimalMeta {
|
||||
public static final byte OFFSET = AnimalMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public RabbitMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Type getType() {
|
||||
int id = super.metadata.getIndex(OFFSET, 0);
|
||||
int id = metadata.get(MetadataDef.Rabbit.TYPE);
|
||||
if (id == 99) {
|
||||
return Type.KILLER_BUNNY;
|
||||
}
|
||||
@ -24,7 +21,7 @@ public class RabbitMeta extends AnimalMeta {
|
||||
|
||||
public void setType(@NotNull Type value) {
|
||||
int id = value == Type.KILLER_BUNNY ? 99 : value.ordinal();
|
||||
super.metadata.setIndex(OFFSET, Metadata.VarInt(id));
|
||||
metadata.set(MetadataDef.Rabbit.TYPE, id);
|
||||
}
|
||||
|
||||
public enum Type {
|
||||
|
@ -1,40 +1,29 @@
|
||||
package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SheepMeta extends AnimalMeta {
|
||||
public static final byte OFFSET = AnimalMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
private final static byte COLOR_BITS = 0x0F;
|
||||
private final static byte SHEARED_BIT = 0x10;
|
||||
|
||||
public SheepMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return getMask(OFFSET) & COLOR_BITS;
|
||||
return metadata.get(MetadataDef.Sheep.COLOR_ID);
|
||||
}
|
||||
|
||||
public void setColor(byte color) {
|
||||
byte before = getMask(OFFSET);
|
||||
byte mask = before;
|
||||
mask &= ~COLOR_BITS;
|
||||
mask |= (color & COLOR_BITS);
|
||||
if (mask != before) {
|
||||
setMask(OFFSET, mask);
|
||||
}
|
||||
metadata.set(MetadataDef.Sheep.COLOR_ID, color);
|
||||
}
|
||||
|
||||
public boolean isSheared() {
|
||||
return getMaskBit(OFFSET, SHEARED_BIT);
|
||||
return metadata.get(MetadataDef.Sheep.IS_SHEARED);
|
||||
}
|
||||
|
||||
public void setSheared(boolean value) {
|
||||
setMaskBit(OFFSET, SHEARED_BIT, value);
|
||||
metadata.set(MetadataDef.Sheep.IS_SHEARED, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,9 +5,6 @@ import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SkeletonHorseMeta extends AbstractHorseMeta {
|
||||
public static final byte OFFSET = AbstractHorseMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public SkeletonHorseMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
@ -1,34 +1,30 @@
|
||||
package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SnifferMeta extends AnimalMeta {
|
||||
|
||||
public static final byte OFFSET = AnimalMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 2;
|
||||
|
||||
public SnifferMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public @NotNull State getState() {
|
||||
return super.metadata.getIndex(OFFSET, State.IDLING);
|
||||
return metadata.get(MetadataDef.Sniffer.STATE);
|
||||
}
|
||||
|
||||
public void setState(@NotNull State value) {
|
||||
super.metadata.setIndex(OFFSET, Metadata.SnifferState(value));
|
||||
metadata.set(MetadataDef.Sniffer.STATE, value);
|
||||
}
|
||||
|
||||
public int getDropSeedAtTick() {
|
||||
return super.metadata.getIndex(OFFSET + 1, 0);
|
||||
return metadata.get(MetadataDef.Sniffer.DROP_SEED_AT_TICK);
|
||||
}
|
||||
|
||||
public void setDropSeedAtTick(int value) {
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.VarInt(value));
|
||||
metadata.set(MetadataDef.Sniffer.DROP_SEED_AT_TICK, value);
|
||||
}
|
||||
|
||||
public enum State {
|
||||
|
@ -1,40 +1,37 @@
|
||||
package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class StriderMeta extends AnimalMeta {
|
||||
public static final byte OFFSET = AnimalMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 3;
|
||||
|
||||
public StriderMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public int getTimeToBoost() {
|
||||
return super.metadata.getIndex(OFFSET, 0);
|
||||
return metadata.get(MetadataDef.Strider.FUNGUS_BOOST);
|
||||
}
|
||||
|
||||
public void setTimeToBoost(int value) {
|
||||
super.metadata.setIndex(OFFSET, Metadata.VarInt(value));
|
||||
metadata.set(MetadataDef.Strider.FUNGUS_BOOST, value);
|
||||
}
|
||||
|
||||
public boolean isShaking() {
|
||||
return super.metadata.getIndex(OFFSET + 1, false);
|
||||
return metadata.get(MetadataDef.Strider.IS_SHAKING);
|
||||
}
|
||||
|
||||
public void setShaking(boolean value) {
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.Boolean(value));
|
||||
metadata.set(MetadataDef.Strider.IS_SHAKING, value);
|
||||
}
|
||||
|
||||
public boolean isHasSaddle() {
|
||||
return super.metadata.getIndex(OFFSET + 2, false);
|
||||
return metadata.get(MetadataDef.Strider.HAS_SADDLE);
|
||||
}
|
||||
|
||||
public void setHasSaddle(boolean value) {
|
||||
super.metadata.setIndex(OFFSET + 2, Metadata.Boolean(value));
|
||||
metadata.set(MetadataDef.Strider.HAS_SADDLE, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,66 +1,62 @@
|
||||
package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.coordinate.Point;
|
||||
import net.minestom.server.coordinate.Vec;
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class TurtleMeta extends AnimalMeta {
|
||||
public static final byte OFFSET = AnimalMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 6;
|
||||
|
||||
public TurtleMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public @NotNull Point getHomePosition() {
|
||||
return super.metadata.getIndex(OFFSET, Vec.ZERO);
|
||||
return metadata.get(MetadataDef.Turtle.HOME_POS);
|
||||
}
|
||||
|
||||
public void setBlockPosition(@NotNull Point value) {
|
||||
super.metadata.setIndex(OFFSET, Metadata.BlockPosition(value));
|
||||
metadata.set(MetadataDef.Turtle.HOME_POS, value);
|
||||
}
|
||||
|
||||
public boolean isHasEgg() {
|
||||
return super.metadata.getIndex(OFFSET + 1, false);
|
||||
return metadata.get(MetadataDef.Turtle.HAS_EGG);
|
||||
}
|
||||
|
||||
public void setHasEgg(boolean value) {
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.Boolean(value));
|
||||
metadata.set(MetadataDef.Turtle.HAS_EGG, value);
|
||||
}
|
||||
|
||||
public boolean isLayingEgg() {
|
||||
return super.metadata.getIndex(OFFSET + 2, false);
|
||||
return metadata.get(MetadataDef.Turtle.IS_LAYING_EGG);
|
||||
}
|
||||
|
||||
public void setLayingEgg(boolean value) {
|
||||
super.metadata.setIndex(OFFSET + 2, Metadata.Boolean(value));
|
||||
metadata.set(MetadataDef.Turtle.IS_LAYING_EGG, value);
|
||||
}
|
||||
|
||||
public @NotNull Point getTravelPosition() {
|
||||
return super.metadata.getIndex(OFFSET + 3, Vec.ZERO);
|
||||
return metadata.get(MetadataDef.Turtle.TRAVEL_POS);
|
||||
}
|
||||
|
||||
public void setTravelPosition(@NotNull Point value) {
|
||||
super.metadata.setIndex(OFFSET + 3, Metadata.BlockPosition(value));
|
||||
metadata.set(MetadataDef.Turtle.TRAVEL_POS, value);
|
||||
}
|
||||
|
||||
public boolean isGoingHome() {
|
||||
return super.metadata.getIndex(OFFSET + 4, false);
|
||||
return metadata.get(MetadataDef.Turtle.IS_GOING_HOME);
|
||||
}
|
||||
|
||||
public void setGoingHome(boolean value) {
|
||||
super.metadata.setIndex(OFFSET + 4, Metadata.Boolean(value));
|
||||
metadata.set(MetadataDef.Turtle.IS_GOING_HOME, value);
|
||||
}
|
||||
|
||||
public boolean isTravelling() {
|
||||
return super.metadata.getIndex(OFFSET + 5, false);
|
||||
return metadata.get(MetadataDef.Turtle.IS_TRAVELING);
|
||||
}
|
||||
|
||||
public void setTravelling(boolean value) {
|
||||
super.metadata.setIndex(OFFSET + 5, Metadata.Boolean(value));
|
||||
metadata.set(MetadataDef.Turtle.IS_TRAVELING, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,9 +5,6 @@ import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ZombieHorseMeta extends AbstractHorseMeta {
|
||||
public static final byte OFFSET = AbstractHorseMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public ZombieHorseMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
@ -2,15 +2,12 @@ package net.minestom.server.entity.metadata.animal.tameable;
|
||||
|
||||
import net.minestom.server.color.DyeColor;
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CatMeta extends TameableAnimalMeta {
|
||||
public static final byte OFFSET = TameableAnimalMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 4;
|
||||
|
||||
private static final DyeColor[] DYE_VALUES = DyeColor.values();
|
||||
|
||||
public CatMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
@ -19,35 +16,35 @@ public class CatMeta extends TameableAnimalMeta {
|
||||
|
||||
@NotNull
|
||||
public CatMeta.Variant getVariant() {
|
||||
return super.metadata.getIndex(OFFSET, Variant.BLACK);
|
||||
return metadata.get(MetadataDef.Cat.VARIANT);
|
||||
}
|
||||
|
||||
public void setVariant(@NotNull CatMeta.Variant value) {
|
||||
super.metadata.setIndex(OFFSET, Metadata.CatVariant(value));
|
||||
metadata.set(MetadataDef.Cat.VARIANT, value);
|
||||
}
|
||||
|
||||
public boolean isLying() {
|
||||
return super.metadata.getIndex(OFFSET + 1, false);
|
||||
return metadata.get(MetadataDef.Cat.IS_LYING);
|
||||
}
|
||||
|
||||
public void setLying(boolean value) {
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.Boolean(value));
|
||||
metadata.set(MetadataDef.Cat.IS_LYING, value);
|
||||
}
|
||||
|
||||
public boolean isRelaxed() {
|
||||
return super.metadata.getIndex(OFFSET + 2, false);
|
||||
return metadata.get(MetadataDef.Cat.IS_RELAXED);
|
||||
}
|
||||
|
||||
public void setRelaxed(boolean value) {
|
||||
super.metadata.setIndex(OFFSET + 2, Metadata.Boolean(value));
|
||||
metadata.set(MetadataDef.Cat.IS_RELAXED, value);
|
||||
}
|
||||
|
||||
public @NotNull DyeColor getCollarColor() {
|
||||
return DYE_VALUES[super.metadata.getIndex(OFFSET + 3, DyeColor.RED.ordinal())];
|
||||
return DYE_VALUES[metadata.get(MetadataDef.Cat.COLLAR_COLOR)];
|
||||
}
|
||||
|
||||
public void setCollarColor(@NotNull DyeColor value) {
|
||||
super.metadata.setIndex(OFFSET + 3, Metadata.VarInt(value.ordinal()));
|
||||
metadata.set(MetadataDef.Cat.COLLAR_COLOR, value.ordinal());
|
||||
}
|
||||
|
||||
public enum Variant {
|
||||
|
@ -1,25 +1,22 @@
|
||||
package net.minestom.server.entity.metadata.animal.tameable;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ParrotMeta extends TameableAnimalMeta {
|
||||
public static final byte OFFSET = TameableAnimalMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public ParrotMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Color getColor() {
|
||||
return Color.VALUES[super.metadata.getIndex(OFFSET, 0)];
|
||||
return Color.VALUES[metadata.get(MetadataDef.Parrot.VARIANT)];
|
||||
}
|
||||
|
||||
public void setColor(@NotNull Color value) {
|
||||
super.metadata.setIndex(OFFSET, Metadata.VarInt(value.ordinal()));
|
||||
metadata.set(MetadataDef.Parrot.VARIANT, value.ordinal());
|
||||
}
|
||||
|
||||
public enum Color {
|
||||
|
@ -1,47 +1,42 @@
|
||||
package net.minestom.server.entity.metadata.animal.tameable;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import net.minestom.server.entity.metadata.animal.AnimalMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class TameableAnimalMeta extends AnimalMeta {
|
||||
public static final byte OFFSET = AnimalMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 2;
|
||||
|
||||
private final static byte SITTING_BIT = 0x01;
|
||||
private final static byte TAMED_BIT = 0x04;
|
||||
|
||||
protected TameableAnimalMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean isSitting() {
|
||||
return getMaskBit(OFFSET, SITTING_BIT);
|
||||
return metadata.get(MetadataDef.TameableAnimal.IS_SITTING);
|
||||
}
|
||||
|
||||
public void setSitting(boolean value) {
|
||||
setMaskBit(OFFSET, SITTING_BIT, value);
|
||||
metadata.set(MetadataDef.TameableAnimal.IS_SITTING, value);
|
||||
}
|
||||
|
||||
public boolean isTamed() {
|
||||
return getMaskBit(OFFSET, TAMED_BIT);
|
||||
return metadata.get(MetadataDef.TameableAnimal.IS_TAMED);
|
||||
}
|
||||
|
||||
public void setTamed(boolean value) {
|
||||
setMaskBit(OFFSET, TAMED_BIT, value);
|
||||
metadata.set(MetadataDef.TameableAnimal.IS_TAMED, value);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Nullable
|
||||
public UUID getOwner() {
|
||||
return super.metadata.getIndex(OFFSET + 1, null);
|
||||
return metadata.get(MetadataDef.TameableAnimal.OWNER);
|
||||
}
|
||||
|
||||
public void setOwner(@NotNull UUID value) {
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.OptUUID(value));
|
||||
public void setOwner(@Nullable UUID value) {
|
||||
metadata.set(MetadataDef.TameableAnimal.OWNER, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import net.kyori.adventure.nbt.BinaryTag;
|
||||
import net.kyori.adventure.nbt.CompoundBinaryTag;
|
||||
import net.kyori.adventure.nbt.StringBinaryTag;
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import net.minestom.server.network.NetworkBuffer;
|
||||
import net.minestom.server.registry.DynamicRegistry;
|
||||
@ -21,43 +21,40 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class WolfMeta extends TameableAnimalMeta {
|
||||
public static final byte OFFSET = TameableAnimalMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 4;
|
||||
|
||||
public WolfMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean isBegging() {
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
return metadata.get(MetadataDef.Wolf.IS_BEGGING);
|
||||
}
|
||||
|
||||
public void setBegging(boolean value) {
|
||||
super.metadata.setIndex(OFFSET, Metadata.Boolean(value));
|
||||
metadata.set(MetadataDef.Wolf.IS_BEGGING, value);
|
||||
}
|
||||
|
||||
public int getCollarColor() {
|
||||
return super.metadata.getIndex(OFFSET + 1, 14);
|
||||
return metadata.get(MetadataDef.Wolf.COLLAR_COLOR);
|
||||
}
|
||||
|
||||
public void setCollarColor(int value) {
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.VarInt(value));
|
||||
metadata.set(MetadataDef.Wolf.COLLAR_COLOR, value);
|
||||
}
|
||||
|
||||
public int getAngerTime() {
|
||||
return super.metadata.getIndex(OFFSET + 2, 0);
|
||||
return metadata.get(MetadataDef.Wolf.ANGER_TIME);
|
||||
}
|
||||
|
||||
public void setAngerTime(int value) {
|
||||
super.metadata.setIndex(OFFSET + 2, Metadata.VarInt(value));
|
||||
metadata.set(MetadataDef.Wolf.ANGER_TIME, value);
|
||||
}
|
||||
|
||||
public @NotNull DynamicRegistry.Key<Variant> getVariant() {
|
||||
return super.metadata.getIndex(OFFSET + 3, Variant.PALE);
|
||||
return metadata.get(MetadataDef.Wolf.VARIANT);
|
||||
}
|
||||
|
||||
public void setVariant(@NotNull DynamicRegistry.Key<Variant> value) {
|
||||
super.metadata.setIndex(OFFSET + 3, Metadata.WolfVariant(value));
|
||||
metadata.set(MetadataDef.Wolf.VARIANT, value);
|
||||
}
|
||||
|
||||
public sealed interface Variant extends ProtocolObject, WolfVariants permits VariantImpl {
|
||||
|
@ -3,140 +3,136 @@ package net.minestom.server.entity.metadata.display;
|
||||
import net.minestom.server.coordinate.Point;
|
||||
import net.minestom.server.coordinate.Vec;
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import net.minestom.server.entity.metadata.EntityMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AbstractDisplayMeta extends EntityMeta {
|
||||
|
||||
public static final byte OFFSET = EntityMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 15;
|
||||
|
||||
protected AbstractDisplayMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public int getTransformationInterpolationStartDelta() {
|
||||
return super.metadata.getIndex(OFFSET, 0);
|
||||
return metadata.get(MetadataDef.Display.INTERPOLATION_DELAY);
|
||||
}
|
||||
|
||||
public void setTransformationInterpolationStartDelta(int value) {
|
||||
super.metadata.setIndex(OFFSET, Metadata.VarInt(value));
|
||||
metadata.set(MetadataDef.Display.INTERPOLATION_DELAY, value);
|
||||
}
|
||||
|
||||
public int getTransformationInterpolationDuration() {
|
||||
return super.metadata.getIndex(OFFSET + 1, 0);
|
||||
return metadata.get(MetadataDef.Display.TRANSFORMATION_INTERPOLATION_DURATION);
|
||||
}
|
||||
|
||||
public void setTransformationInterpolationDuration(int value) {
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.VarInt(value));
|
||||
metadata.set(MetadataDef.Display.TRANSFORMATION_INTERPOLATION_DURATION, value);
|
||||
}
|
||||
|
||||
public int getPosRotInterpolationDuration() {
|
||||
return super.metadata.getIndex(OFFSET + 2, 0);
|
||||
return metadata.get(MetadataDef.Display.POSITION_ROTATION_INTERPOLATION_DURATION);
|
||||
}
|
||||
|
||||
public void setPosRotInterpolationDuration(int value) {
|
||||
super.metadata.setIndex(OFFSET + 2, Metadata.VarInt(value));
|
||||
metadata.set(MetadataDef.Display.POSITION_ROTATION_INTERPOLATION_DURATION, value);
|
||||
}
|
||||
|
||||
public @NotNull Point getTranslation() {
|
||||
return super.metadata.getIndex(OFFSET + 3, Vec.ZERO);
|
||||
return metadata.get(MetadataDef.Display.TRANSLATION);
|
||||
}
|
||||
|
||||
public void setTranslation(@NotNull Point value) {
|
||||
super.metadata.setIndex(OFFSET + 3, Metadata.Vector3(value));
|
||||
metadata.set(MetadataDef.Display.TRANSLATION, value);
|
||||
}
|
||||
|
||||
public @NotNull Vec getScale() {
|
||||
return super.metadata.getIndex(OFFSET + 4, Vec.ONE);
|
||||
return Vec.fromPoint(metadata.get(MetadataDef.Display.SCALE));
|
||||
}
|
||||
|
||||
public void setScale(@NotNull Vec value) {
|
||||
super.metadata.setIndex(OFFSET + 4, Metadata.Vector3(value));
|
||||
metadata.set(MetadataDef.Display.SCALE, value);
|
||||
}
|
||||
|
||||
public float @NotNull[] getLeftRotation() {
|
||||
//todo replace with actual quaternion type
|
||||
return super.metadata.getIndex(OFFSET + 5, new float[] {0, 0, 0, 1});
|
||||
return metadata.get(MetadataDef.Display.ROTATION_LEFT);
|
||||
}
|
||||
|
||||
public void setLeftRotation(float @NotNull[] value) {
|
||||
super.metadata.setIndex(OFFSET + 5, Metadata.Quaternion(value));
|
||||
metadata.set(MetadataDef.Display.ROTATION_LEFT, value);
|
||||
}
|
||||
|
||||
public float @NotNull[] getRightRotation() {
|
||||
//todo replace with actual quaternion type
|
||||
return super.metadata.getIndex(OFFSET + 6, new float[] {0, 0, 0, 1});
|
||||
return metadata.get(MetadataDef.Display.ROTATION_RIGHT);
|
||||
}
|
||||
|
||||
public void setRightRotation(float @NotNull[] value) {
|
||||
super.metadata.setIndex(OFFSET + 6, Metadata.Quaternion(value));
|
||||
metadata.set(MetadataDef.Display.ROTATION_RIGHT, value);
|
||||
}
|
||||
|
||||
public @NotNull BillboardConstraints getBillboardRenderConstraints() {
|
||||
return BillboardConstraints.VALUES[super.metadata.getIndex(OFFSET + 7, (byte) 0)];
|
||||
return BillboardConstraints.VALUES[metadata.get(MetadataDef.Display.BILLBOARD_CONSTRAINTS)];
|
||||
}
|
||||
|
||||
public void setBillboardRenderConstraints(@NotNull BillboardConstraints value) {
|
||||
super.metadata.setIndex(OFFSET + 7, Metadata.Byte((byte) value.ordinal()));
|
||||
metadata.set(MetadataDef.Display.BILLBOARD_CONSTRAINTS, (byte) value.ordinal());
|
||||
}
|
||||
|
||||
public int getBrightnessOverride() {
|
||||
return super.metadata.getIndex(OFFSET + 8, -1);
|
||||
return metadata.get(MetadataDef.Display.BRIGHTNESS_OVERRIDE);
|
||||
}
|
||||
|
||||
public void setBrightnessOverride(int value) {
|
||||
super.metadata.setIndex(OFFSET + 8, Metadata.VarInt(value));
|
||||
metadata.set(MetadataDef.Display.BRIGHTNESS_OVERRIDE, value);
|
||||
}
|
||||
|
||||
public float getViewRange() {
|
||||
return super.metadata.getIndex(OFFSET + 9, 1.0F);
|
||||
return metadata.get(MetadataDef.Display.VIEW_RANGE);
|
||||
}
|
||||
|
||||
public void setViewRange(float value) {
|
||||
super.metadata.setIndex(OFFSET + 9, Metadata.Float(value));
|
||||
metadata.set(MetadataDef.Display.VIEW_RANGE, value);
|
||||
}
|
||||
|
||||
public float getShadowRadius() {
|
||||
return super.metadata.getIndex(OFFSET + 10, 0.0F);
|
||||
return metadata.get(MetadataDef.Display.SHADOW_RADIUS);
|
||||
}
|
||||
|
||||
public void setShadowRadius(float value) {
|
||||
super.metadata.setIndex(OFFSET + 10, Metadata.Float(value));
|
||||
metadata.set(MetadataDef.Display.SHADOW_RADIUS, value);
|
||||
}
|
||||
|
||||
public float getShadowStrength() {
|
||||
return super.metadata.getIndex(OFFSET + 11, 1.0F);
|
||||
return metadata.get(MetadataDef.Display.SHADOW_STRENGTH);
|
||||
}
|
||||
|
||||
public void setShadowStrength(float value) {
|
||||
super.metadata.setIndex(OFFSET + 11, Metadata.Float(value));
|
||||
metadata.set(MetadataDef.Display.SHADOW_STRENGTH, value);
|
||||
}
|
||||
|
||||
public float getWidth() {
|
||||
return super.metadata.getIndex(OFFSET + 12, 0.0F);
|
||||
return metadata.get(MetadataDef.Display.WIDTH);
|
||||
}
|
||||
|
||||
public void setWidth(float value) {
|
||||
super.metadata.setIndex(OFFSET + 12, Metadata.Float(value));
|
||||
metadata.set(MetadataDef.Display.WIDTH, value);
|
||||
}
|
||||
|
||||
public float getHeight() {
|
||||
return super.metadata.getIndex(OFFSET + 13, 0.0F);
|
||||
return metadata.get(MetadataDef.Display.HEIGHT);
|
||||
}
|
||||
|
||||
public void setHeight(float value) {
|
||||
super.metadata.setIndex(OFFSET + 13, Metadata.Float(value));
|
||||
metadata.set(MetadataDef.Display.HEIGHT, value);
|
||||
}
|
||||
|
||||
public int getGlowColorOverride() {
|
||||
return super.metadata.getIndex(OFFSET + 14, 0);
|
||||
return metadata.get(MetadataDef.Display.GLOW_COLOR_OVERRIDE);
|
||||
}
|
||||
|
||||
public void setGlowColorOverride(int value) {
|
||||
super.metadata.setIndex(OFFSET + 14, Metadata.VarInt(value));
|
||||
metadata.set(MetadataDef.Display.GLOW_COLOR_OVERRIDE, value);
|
||||
}
|
||||
|
||||
public enum BillboardConstraints {
|
||||
|
@ -1,24 +1,21 @@
|
||||
package net.minestom.server.entity.metadata.display;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class BlockDisplayMeta extends AbstractDisplayMeta {
|
||||
public static final byte OFFSET = AbstractDisplayMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public BlockDisplayMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public @NotNull Block getBlockStateId() {
|
||||
return super.metadata.getIndex(OFFSET, Block.AIR);
|
||||
return metadata.get(MetadataDef.BlockDisplay.DISPLAYED_BLOCK_STATE);
|
||||
}
|
||||
|
||||
public void setBlockState(@NotNull Block value) {
|
||||
super.metadata.setIndex(OFFSET, Metadata.BlockState(value));
|
||||
metadata.set(MetadataDef.BlockDisplay.DISPLAYED_BLOCK_STATE, value);
|
||||
}
|
||||
}
|
||||
|
@ -1,33 +1,30 @@
|
||||
package net.minestom.server.entity.metadata.display;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ItemDisplayMeta extends AbstractDisplayMeta {
|
||||
public static final byte OFFSET = AbstractDisplayMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 2;
|
||||
|
||||
public ItemDisplayMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public @NotNull ItemStack getItemStack() {
|
||||
return super.metadata.getIndex(OFFSET, ItemStack.AIR);
|
||||
return metadata.get(MetadataDef.ItemDisplay.DISPLAYED_ITEM);
|
||||
}
|
||||
|
||||
public void setItemStack(@NotNull ItemStack value) {
|
||||
super.metadata.setIndex(OFFSET, Metadata.ItemStack(value));
|
||||
metadata.set(MetadataDef.ItemDisplay.DISPLAYED_ITEM, value);
|
||||
}
|
||||
|
||||
public @NotNull DisplayContext getDisplayContext() {
|
||||
return DisplayContext.VALUES[super.metadata.getIndex(OFFSET + 1, (byte) 0)];
|
||||
return DisplayContext.VALUES[metadata.get(MetadataDef.ItemDisplay.DISPLAY_TYPE)];
|
||||
}
|
||||
|
||||
public void setDisplayContext(@NotNull DisplayContext value) {
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.Byte((byte) value.ordinal()));
|
||||
metadata.set(MetadataDef.ItemDisplay.DISPLAY_TYPE, (byte) value.ordinal());
|
||||
}
|
||||
|
||||
public enum DisplayContext {
|
||||
|
@ -2,93 +2,108 @@ package net.minestom.server.entity.metadata.display;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class TextDisplayMeta extends AbstractDisplayMeta {
|
||||
public static final byte OFFSET = AbstractDisplayMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 5;
|
||||
|
||||
private static final byte SHADOW = 1;
|
||||
private static final byte SEE_THROUGH = 2;
|
||||
private static final byte USE_DEFAULT_BACKGROUND = 4;
|
||||
private static final byte ALIGN_LEFT = 8;
|
||||
private static final byte ALIGN_RIGHT = 16;
|
||||
|
||||
public TextDisplayMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public @NotNull Component getText() {
|
||||
return super.metadata.getIndex(OFFSET, Component.empty());
|
||||
return metadata.get(MetadataDef.TextDisplay.TEXT);
|
||||
}
|
||||
|
||||
public void setText(@NotNull Component value) {
|
||||
super.metadata.setIndex(OFFSET, Metadata.Chat(value));
|
||||
metadata.set(MetadataDef.TextDisplay.TEXT, value);
|
||||
}
|
||||
|
||||
public int getLineWidth() {
|
||||
return super.metadata.getIndex(OFFSET + 1, 200);
|
||||
return metadata.get(MetadataDef.TextDisplay.LINE_WIDTH);
|
||||
}
|
||||
|
||||
public void setLineWidth(int value) {
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.VarInt(value));
|
||||
metadata.set(MetadataDef.TextDisplay.LINE_WIDTH, value);
|
||||
}
|
||||
|
||||
public int getBackgroundColor() {
|
||||
return super.metadata.getIndex(OFFSET + 2, 1073741824);
|
||||
return metadata.get(MetadataDef.TextDisplay.BACKGROUND_COLOR);
|
||||
}
|
||||
|
||||
public void setBackgroundColor(int value) {
|
||||
super.metadata.setIndex(OFFSET + 2, Metadata.VarInt(value));
|
||||
metadata.set(MetadataDef.TextDisplay.BACKGROUND_COLOR, value);
|
||||
}
|
||||
|
||||
public byte getTextOpacity() {
|
||||
return super.metadata.getIndex(OFFSET + 3, (byte) -1);
|
||||
return metadata.get(MetadataDef.TextDisplay.TEXT_OPACITY);
|
||||
}
|
||||
|
||||
public void setTextOpacity(byte value) {
|
||||
super.metadata.setIndex(OFFSET + 3, Metadata.Byte(value));
|
||||
metadata.set(MetadataDef.TextDisplay.TEXT_OPACITY, value);
|
||||
}
|
||||
|
||||
public boolean isShadow() {
|
||||
return getMaskBit(OFFSET + 4, SHADOW);
|
||||
return metadata.get(MetadataDef.TextDisplay.HAS_SHADOW);
|
||||
}
|
||||
|
||||
public void setShadow(boolean value) {
|
||||
setMaskBit(OFFSET + 4, SHADOW, value);
|
||||
metadata.set(MetadataDef.TextDisplay.HAS_SHADOW, value);
|
||||
}
|
||||
|
||||
public boolean isSeeThrough() {
|
||||
return getMaskBit(OFFSET + 4, SEE_THROUGH);
|
||||
return metadata.get(MetadataDef.TextDisplay.IS_SEE_THROUGH);
|
||||
}
|
||||
|
||||
public void setSeeThrough(boolean value) {
|
||||
setMaskBit(OFFSET + 4, SEE_THROUGH, value);
|
||||
metadata.set(MetadataDef.TextDisplay.IS_SEE_THROUGH, value);
|
||||
}
|
||||
|
||||
public boolean isUseDefaultBackground() {
|
||||
return getMaskBit(OFFSET + 4, USE_DEFAULT_BACKGROUND);
|
||||
return metadata.get(MetadataDef.TextDisplay.USE_DEFAULT_BACKGROUND_COLOR);
|
||||
}
|
||||
|
||||
public void setUseDefaultBackground(boolean value) {
|
||||
setMaskBit(OFFSET + 4, USE_DEFAULT_BACKGROUND, value);
|
||||
metadata.set(MetadataDef.TextDisplay.USE_DEFAULT_BACKGROUND_COLOR, value);
|
||||
}
|
||||
|
||||
public boolean isAlignLeft() {
|
||||
return getMaskBit(OFFSET + 4, ALIGN_LEFT);
|
||||
return metadata.get(MetadataDef.TextDisplay.ALIGN_LEFT);
|
||||
}
|
||||
|
||||
public void setAlignLeft(boolean value) {
|
||||
setMaskBit(OFFSET + 4, ALIGN_LEFT, value);
|
||||
metadata.set(MetadataDef.TextDisplay.ALIGN_LEFT, value);
|
||||
}
|
||||
|
||||
public boolean isAlignRight() {
|
||||
return getMaskBit(OFFSET + 4, ALIGN_RIGHT);
|
||||
return metadata.get(MetadataDef.TextDisplay.ALIGN_RIGHT);
|
||||
}
|
||||
|
||||
public void setAlignRight(boolean value) {
|
||||
setMaskBit(OFFSET + 4, ALIGN_RIGHT, value);
|
||||
metadata.set(MetadataDef.TextDisplay.ALIGN_RIGHT, value);
|
||||
}
|
||||
|
||||
public Alignment getAlignment() {
|
||||
return Alignment.fromId(metadata.get(MetadataDef.TextDisplay.ALIGNMENT));
|
||||
}
|
||||
|
||||
public void setAlignment(Alignment value) {
|
||||
metadata.set(MetadataDef.TextDisplay.ALIGNMENT, (byte) value.ordinal());
|
||||
}
|
||||
|
||||
public enum Alignment {
|
||||
CENTER,
|
||||
LEFT,
|
||||
RIGHT;
|
||||
|
||||
private final static Alignment[] VALUES = values();
|
||||
|
||||
private static Alignment fromId(int id) {
|
||||
if (id >= 0 && id < VALUES.length) {
|
||||
return VALUES[id];
|
||||
}
|
||||
return CENTER;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,9 +6,6 @@ import net.minestom.server.entity.metadata.MobMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class FlyingMeta extends MobMeta {
|
||||
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
protected FlyingMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
@ -1,24 +1,21 @@
|
||||
package net.minestom.server.entity.metadata.flying;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class GhastMeta extends FlyingMeta {
|
||||
public static final byte OFFSET = FlyingMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public GhastMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean isAttacking() {
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
return metadata.get(MetadataDef.Ghast.IS_ATTACKING);
|
||||
}
|
||||
|
||||
public void setAttacking(boolean value) {
|
||||
super.metadata.setIndex(OFFSET, Metadata.Boolean(value));
|
||||
metadata.set(MetadataDef.Ghast.IS_ATTACKING, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,24 +1,21 @@
|
||||
package net.minestom.server.entity.metadata.flying;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PhantomMeta extends FlyingMeta {
|
||||
public static final byte OFFSET = FlyingMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public PhantomMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return super.metadata.getIndex(OFFSET, 0);
|
||||
return metadata.get(MetadataDef.Phantom.SIZE);
|
||||
}
|
||||
|
||||
public void setSize(int value) {
|
||||
super.metadata.setIndex(OFFSET, Metadata.VarInt(value));
|
||||
metadata.set(MetadataDef.Phantom.SIZE, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,9 +6,6 @@ import net.minestom.server.entity.metadata.PathfinderMobMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AbstractGolemMeta extends PathfinderMobMeta {
|
||||
public static final byte OFFSET = PathfinderMobMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
protected AbstractGolemMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
@ -1,25 +1,21 @@
|
||||
package net.minestom.server.entity.metadata.golem;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class IronGolemMeta extends AbstractGolemMeta {
|
||||
public static final byte OFFSET = AbstractGolemMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
private final static byte PLAYER_CREATED_BIT = 0x01;
|
||||
|
||||
public IronGolemMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean isPlayerCreated() {
|
||||
return getMaskBit(OFFSET, PLAYER_CREATED_BIT);
|
||||
return metadata.get(MetadataDef.IronGolem.IS_PLAYER_CREATED);
|
||||
}
|
||||
|
||||
public void setPlayerCreated(boolean value) {
|
||||
setMaskBit(OFFSET, PLAYER_CREATED_BIT, value);
|
||||
metadata.set(MetadataDef.IronGolem.IS_PLAYER_CREATED, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,41 +1,38 @@
|
||||
package net.minestom.server.entity.metadata.golem;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import net.minestom.server.utils.Direction;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ShulkerMeta extends AbstractGolemMeta {
|
||||
public static final byte OFFSET = AbstractGolemMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 3;
|
||||
|
||||
public ShulkerMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public Direction getAttachFace() {
|
||||
return super.metadata.getIndex(OFFSET, Direction.DOWN);
|
||||
return metadata.get(MetadataDef.Shulker.ATTACH_FACE);
|
||||
}
|
||||
|
||||
public void setAttachFace(Direction value) {
|
||||
super.metadata.setIndex(OFFSET, Metadata.Direction(value));
|
||||
metadata.set(MetadataDef.Shulker.ATTACH_FACE, value);
|
||||
}
|
||||
|
||||
public byte getShieldHeight() {
|
||||
return super.metadata.getIndex(OFFSET + 1, (byte) 0);
|
||||
return metadata.get(MetadataDef.Shulker.SHIELD_HEIGHT);
|
||||
}
|
||||
|
||||
public void setShieldHeight(byte value) {
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.Byte(value));
|
||||
metadata.set(MetadataDef.Shulker.SHIELD_HEIGHT, value);
|
||||
}
|
||||
|
||||
public byte getColor() {
|
||||
return super.metadata.getIndex(OFFSET + 2, (byte) 10);
|
||||
return metadata.get(MetadataDef.Shulker.COLOR);
|
||||
}
|
||||
|
||||
public void setColor(byte value) {
|
||||
super.metadata.setIndex(OFFSET + 2, Metadata.Byte(value));
|
||||
metadata.set(MetadataDef.Shulker.COLOR, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,24 +1,21 @@
|
||||
package net.minestom.server.entity.metadata.golem;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SnowGolemMeta extends AbstractGolemMeta {
|
||||
public static final byte OFFSET = AbstractGolemMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public SnowGolemMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean isHasPumpkinHat() {
|
||||
return super.metadata.getIndex(OFFSET, (byte) 0x10) == (byte) 0x10;
|
||||
return metadata.get(MetadataDef.SnowGolem.PUMPKIN_HAT);
|
||||
}
|
||||
|
||||
public void setHasPumpkinHat(boolean value) {
|
||||
super.metadata.setIndex(OFFSET, Metadata.Byte(value ? (byte) 0x10 : (byte) 0x00));
|
||||
metadata.set(MetadataDef.SnowGolem.PUMPKIN_HAT, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,15 +2,11 @@ package net.minestom.server.entity.metadata.item;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import net.minestom.server.item.Material;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EyeOfEnderMeta extends ItemContainingMeta {
|
||||
public static final byte OFFSET = ItemContainingMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public class EyeOfEnderMeta extends ThrownItemProjectileMeta {
|
||||
public EyeOfEnderMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata, Material.ENDER_EYE);
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,21 +1,29 @@
|
||||
package net.minestom.server.entity.metadata.item;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import net.minestom.server.entity.metadata.EntityMeta;
|
||||
import net.minestom.server.entity.metadata.ObjectDataProvider;
|
||||
import net.minestom.server.entity.metadata.projectile.ProjectileMeta;
|
||||
import net.minestom.server.item.Material;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class FireballMeta extends ItemContainingMeta implements ObjectDataProvider, ProjectileMeta {
|
||||
public static final byte OFFSET = ItemContainingMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public class FireballMeta extends EntityMeta implements ObjectDataProvider, ProjectileMeta {
|
||||
private Entity shooter;
|
||||
|
||||
public FireballMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata, Material.AIR);
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ItemStack getItem() {
|
||||
return metadata.get(MetadataDef.Fireball.ITEM);
|
||||
}
|
||||
|
||||
public void setItem(@NotNull ItemStack value) {
|
||||
metadata.set(MetadataDef.Fireball.ITEM, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,31 +0,0 @@
|
||||
package net.minestom.server.entity.metadata.item;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import net.minestom.server.entity.metadata.EntityMeta;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import net.minestom.server.item.Material;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
class ItemContainingMeta extends EntityMeta {
|
||||
public static final byte OFFSET = EntityMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
private final ItemStack defaultItem;
|
||||
|
||||
protected ItemContainingMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata, @NotNull Material defaultItemMaterial) {
|
||||
super(entity, metadata);
|
||||
this.defaultItem = ItemStack.of(defaultItemMaterial);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ItemStack getItem() {
|
||||
return super.metadata.getIndex(OFFSET, this.defaultItem);
|
||||
}
|
||||
|
||||
public void setItem(@NotNull ItemStack item) {
|
||||
super.metadata.setIndex(OFFSET, Metadata.ItemStack(item));
|
||||
}
|
||||
|
||||
}
|
@ -1,17 +1,25 @@
|
||||
package net.minestom.server.entity.metadata.item;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import net.minestom.server.entity.metadata.EntityMeta;
|
||||
import net.minestom.server.entity.metadata.ObjectDataProvider;
|
||||
import net.minestom.server.item.Material;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ItemEntityMeta extends ItemContainingMeta implements ObjectDataProvider {
|
||||
public static final byte OFFSET = ItemContainingMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public class ItemEntityMeta extends EntityMeta implements ObjectDataProvider {
|
||||
public ItemEntityMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata, Material.AIR);
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ItemStack getItem() {
|
||||
return metadata.get(MetadataDef.ItemEntity.ITEM);
|
||||
}
|
||||
|
||||
public void setItem(@NotNull ItemStack value) {
|
||||
metadata.set(MetadataDef.ItemEntity.ITEM, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,21 +1,29 @@
|
||||
package net.minestom.server.entity.metadata.item;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import net.minestom.server.entity.metadata.EntityMeta;
|
||||
import net.minestom.server.entity.metadata.ObjectDataProvider;
|
||||
import net.minestom.server.entity.metadata.projectile.ProjectileMeta;
|
||||
import net.minestom.server.item.Material;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class SmallFireballMeta extends ItemContainingMeta implements ObjectDataProvider, ProjectileMeta {
|
||||
public static final byte OFFSET = ItemContainingMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public class SmallFireballMeta extends EntityMeta implements ObjectDataProvider, ProjectileMeta {
|
||||
private Entity shooter;
|
||||
|
||||
public SmallFireballMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata, Material.FIRE_CHARGE);
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ItemStack getItem() {
|
||||
return metadata.get(MetadataDef.SmartFireball.ITEM);
|
||||
}
|
||||
|
||||
public void setItem(@NotNull ItemStack item) {
|
||||
metadata.set(MetadataDef.SmartFireball.ITEM, item);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2,15 +2,11 @@ package net.minestom.server.entity.metadata.item;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import net.minestom.server.item.Material;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SnowballMeta extends ItemContainingMeta {
|
||||
public static final byte OFFSET = ItemContainingMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public class SnowballMeta extends ThrownItemProjectileMeta {
|
||||
public SnowballMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata, Material.SNOWBALL);
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,15 +2,11 @@ package net.minestom.server.entity.metadata.item;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import net.minestom.server.item.Material;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ThrownEggMeta extends ItemContainingMeta {
|
||||
public static final byte OFFSET = ItemContainingMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public class ThrownEggMeta extends ThrownItemProjectileMeta {
|
||||
public ThrownEggMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata, Material.EGG);
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,15 +2,11 @@ package net.minestom.server.entity.metadata.item;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import net.minestom.server.item.Material;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ThrownEnderPearlMeta extends ItemContainingMeta {
|
||||
public static final byte OFFSET = ItemContainingMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public class ThrownEnderPearlMeta extends ThrownItemProjectileMeta {
|
||||
public ThrownEnderPearlMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata, Material.ENDER_PEARL);
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,15 +2,11 @@ package net.minestom.server.entity.metadata.item;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import net.minestom.server.item.Material;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ThrownExperienceBottleMeta extends ItemContainingMeta {
|
||||
public static final byte OFFSET = ItemContainingMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public class ThrownExperienceBottleMeta extends ThrownItemProjectileMeta {
|
||||
public ThrownExperienceBottleMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata, Material.EXPERIENCE_BOTTLE);
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,24 @@
|
||||
package net.minestom.server.entity.metadata.item;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import net.minestom.server.entity.metadata.EntityMeta;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
class ThrownItemProjectileMeta extends EntityMeta {
|
||||
protected ThrownItemProjectileMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ItemStack getItem() {
|
||||
return metadata.get(MetadataDef.ThrownItemProjectile.ITEM);
|
||||
}
|
||||
|
||||
public void setItem(@NotNull ItemStack item) {
|
||||
metadata.set(MetadataDef.ThrownItemProjectile.ITEM, item);
|
||||
}
|
||||
|
||||
}
|
@ -2,15 +2,11 @@ package net.minestom.server.entity.metadata.item;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import net.minestom.server.item.Material;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ThrownPotionMeta extends ItemContainingMeta {
|
||||
public static final byte OFFSET = ItemContainingMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public class ThrownPotionMeta extends ThrownItemProjectileMeta {
|
||||
public ThrownPotionMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata, Material.AIR);
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,9 +5,6 @@ import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractMinecartContainerMeta extends AbstractMinecartMeta {
|
||||
public static final byte OFFSET = AbstractMinecartMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
protected AbstractMinecartContainerMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
@ -1,44 +1,40 @@
|
||||
package net.minestom.server.entity.metadata.minecart;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import net.minestom.server.entity.metadata.AbstractVehicleMeta;
|
||||
import net.minestom.server.entity.metadata.EntityMeta;
|
||||
import net.minestom.server.entity.metadata.ObjectDataProvider;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractMinecartMeta extends AbstractVehicleMeta implements ObjectDataProvider {
|
||||
public static final byte OFFSET = AbstractVehicleMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 3;
|
||||
|
||||
protected AbstractMinecartMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public int getCustomBlockIdAndDamage() {
|
||||
return super.metadata.getIndex(OFFSET, 0);
|
||||
return metadata.get(MetadataDef.AbstractMinecart.CUSTOM_BLOCK_ID_AND_DAMAGE);
|
||||
}
|
||||
|
||||
public void setCustomBlockIdAndDamage(int value) {
|
||||
super.metadata.setIndex(OFFSET, Metadata.VarInt(value));
|
||||
metadata.set(MetadataDef.AbstractMinecart.CUSTOM_BLOCK_ID_AND_DAMAGE, value);
|
||||
}
|
||||
|
||||
// in 16th of a block
|
||||
public int getCustomBlockYPosition() {
|
||||
return super.metadata.getIndex(OFFSET + 1, 6);
|
||||
return metadata.get(MetadataDef.AbstractMinecart.CUSTOM_BLOCK_Y_POSITION);
|
||||
}
|
||||
|
||||
public void setCustomBlockYPosition(int value) {
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.VarInt(value));
|
||||
metadata.set(MetadataDef.AbstractMinecart.CUSTOM_BLOCK_Y_POSITION, value);
|
||||
}
|
||||
|
||||
public boolean getShowCustomBlock() {
|
||||
return super.metadata.getIndex(OFFSET + 2, false);
|
||||
return metadata.get(MetadataDef.AbstractMinecart.SHOW_CUSTOM_BLOCK);
|
||||
}
|
||||
|
||||
public void setShowCustomBlock(boolean show) {
|
||||
super.metadata.setIndex(OFFSET + 2, Metadata.Boolean(show));
|
||||
metadata.set(MetadataDef.AbstractMinecart.SHOW_CUSTOM_BLOCK, show);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,9 +5,6 @@ import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ChestMinecartMeta extends AbstractMinecartContainerMeta {
|
||||
public static final byte OFFSET = AbstractMinecartContainerMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public ChestMinecartMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
@ -2,32 +2,29 @@ package net.minestom.server.entity.metadata.minecart;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CommandBlockMinecartMeta extends AbstractMinecartMeta {
|
||||
public static final byte OFFSET = AbstractMinecartMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 2;
|
||||
|
||||
public CommandBlockMinecartMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public @NotNull String getCommand() {
|
||||
return super.metadata.getIndex(OFFSET, "");
|
||||
return metadata.get(MetadataDef.MinecartCommandBlock.COMMAND);
|
||||
}
|
||||
|
||||
public void setCommand(@NotNull String value) {
|
||||
super.metadata.setIndex(OFFSET, Metadata.String(value));
|
||||
metadata.set(MetadataDef.MinecartCommandBlock.COMMAND, value);
|
||||
}
|
||||
|
||||
public @NotNull Component getLastOutput() {
|
||||
return super.metadata.getIndex(OFFSET + 1, Component.empty());
|
||||
return metadata.get(MetadataDef.MinecartCommandBlock.LAST_OUTPUT);
|
||||
}
|
||||
|
||||
public void setLastOutput(@NotNull Component value) {
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.Chat(value));
|
||||
metadata.set(MetadataDef.MinecartCommandBlock.LAST_OUTPUT, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,24 +1,21 @@
|
||||
package net.minestom.server.entity.metadata.minecart;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class FurnaceMinecartMeta extends AbstractMinecartMeta {
|
||||
public static final byte OFFSET = AbstractMinecartMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public FurnaceMinecartMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean isHasFuel() {
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
return metadata.get(MetadataDef.MinecartFurnace.HAS_FUEL);
|
||||
}
|
||||
|
||||
public void setHasFuel(boolean value) {
|
||||
super.metadata.setIndex(OFFSET, Metadata.Boolean(value));
|
||||
metadata.set(MetadataDef.MinecartFurnace.HAS_FUEL, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,9 +5,6 @@ import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class HopperMinecartMeta extends AbstractMinecartContainerMeta {
|
||||
public static final byte OFFSET = AbstractMinecartContainerMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public HopperMinecartMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
@ -5,9 +5,6 @@ import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MinecartMeta extends AbstractMinecartMeta {
|
||||
public static final byte OFFSET = AbstractMinecartMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public MinecartMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
@ -5,9 +5,6 @@ import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SpawnerMinecartMeta extends AbstractMinecartMeta {
|
||||
public static final byte OFFSET = AbstractMinecartMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public SpawnerMinecartMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
@ -5,9 +5,6 @@ import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class TntMinecartMeta extends AbstractMinecartMeta {
|
||||
public static final byte OFFSET = AbstractMinecartMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public TntMinecartMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
@ -1,24 +1,21 @@
|
||||
package net.minestom.server.entity.metadata.monster;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class BasePiglinMeta extends MonsterMeta {
|
||||
public static final byte OFFSET = MonsterMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
protected BasePiglinMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean isImmuneToZombification() {
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
return metadata.get(MetadataDef.BasePiglin.IMMUNE_ZOMBIFICATION);
|
||||
}
|
||||
|
||||
public void setImmuneToZombification(boolean value) {
|
||||
super.metadata.setIndex(OFFSET, Metadata.Boolean(value));
|
||||
metadata.set(MetadataDef.BasePiglin.IMMUNE_ZOMBIFICATION, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,25 +1,21 @@
|
||||
package net.minestom.server.entity.metadata.monster;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class BlazeMeta extends MonsterMeta {
|
||||
public static final byte OFFSET = MonsterMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
private final static byte ON_FIRE_BIT = 0x01;
|
||||
|
||||
public BlazeMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean isOnFire() {
|
||||
return getMaskBit(OFFSET, ON_FIRE_BIT);
|
||||
return metadata.get(MetadataDef.Blaze.IS_ON_FIRE);
|
||||
}
|
||||
|
||||
public void setOnFire(boolean value) {
|
||||
setMaskBit(OFFSET, ON_FIRE_BIT, value);
|
||||
metadata.set(MetadataDef.Blaze.IS_ON_FIRE, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,9 +5,6 @@ import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class BreezeMeta extends MonsterMeta {
|
||||
public static final byte OFFSET = MonsterMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public BreezeMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
@ -5,9 +5,6 @@ import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CaveSpiderMeta extends SpiderMeta {
|
||||
public static final byte OFFSET = SpiderMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public CaveSpiderMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
@ -1,31 +1,28 @@
|
||||
package net.minestom.server.entity.metadata.monster;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CreakingMeta extends MonsterMeta {
|
||||
public static final byte OFFSET = MonsterMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 2;
|
||||
|
||||
public CreakingMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean canMove() {
|
||||
return super.metadata.getIndex(OFFSET, true);
|
||||
return metadata.get(MetadataDef.Creaking.CAN_MOVE);
|
||||
}
|
||||
|
||||
public void setCanMove(boolean value) {
|
||||
super.metadata.setIndex(OFFSET, Metadata.Boolean(value));
|
||||
metadata.set(MetadataDef.Creaking.CAN_MOVE, value);
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return super.metadata.getIndex(OFFSET + 1, false);
|
||||
return metadata.get(MetadataDef.Creaking.IS_ACTIVE);
|
||||
}
|
||||
|
||||
public void setActive(boolean value) {
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.Boolean(value));
|
||||
metadata.set(MetadataDef.Creaking.IS_ACTIVE, value);
|
||||
}
|
||||
}
|
||||
|
@ -1,42 +1,39 @@
|
||||
package net.minestom.server.entity.metadata.monster;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CreeperMeta extends MonsterMeta {
|
||||
public static final byte OFFSET = MonsterMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 3;
|
||||
|
||||
public CreeperMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public State getState() {
|
||||
int id = super.metadata.getIndex(OFFSET, -1);
|
||||
int id = metadata.get(MetadataDef.Creeper.STATE);
|
||||
return id == -1 ? State.IDLE : State.FUSE;
|
||||
}
|
||||
|
||||
public void setState(@NotNull State value) {
|
||||
super.metadata.setIndex(OFFSET, Metadata.VarInt(value == State.IDLE ? -1 : 1));
|
||||
metadata.set(MetadataDef.Creeper.STATE, value == State.IDLE ? -1 : 1);
|
||||
}
|
||||
|
||||
public boolean isCharged() {
|
||||
return super.metadata.getIndex(OFFSET + 1, false);
|
||||
return metadata.get(MetadataDef.Creeper.IS_CHARGED);
|
||||
}
|
||||
|
||||
public void setCharged(boolean value) {
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.Boolean(value));
|
||||
metadata.set(MetadataDef.Creeper.IS_CHARGED, value);
|
||||
}
|
||||
|
||||
public boolean isIgnited() {
|
||||
return super.metadata.getIndex(OFFSET + 2, false);
|
||||
return metadata.get(MetadataDef.Creeper.IS_IGNITED);
|
||||
}
|
||||
|
||||
public void setIgnited(boolean value) {
|
||||
super.metadata.setIndex(OFFSET + 2, Metadata.Boolean(value));
|
||||
metadata.set(MetadataDef.Creeper.IS_IGNITED, value);
|
||||
}
|
||||
|
||||
public enum State {
|
||||
|
@ -5,9 +5,6 @@ import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ElderGuardianMeta extends GuardianMeta {
|
||||
public static final byte OFFSET = GuardianMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public ElderGuardianMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
@ -1,41 +1,38 @@
|
||||
package net.minestom.server.entity.metadata.monster;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class EndermanMeta extends MonsterMeta {
|
||||
public static final byte OFFSET = MonsterMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 3;
|
||||
|
||||
public EndermanMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public Integer getCarriedBlockID() {
|
||||
return super.metadata.getIndex(OFFSET, null);
|
||||
return metadata.get(MetadataDef.Enderman.CARRIED_BLOCK);
|
||||
}
|
||||
|
||||
public void setCarriedBlockID(@Nullable Integer value) {
|
||||
super.metadata.setIndex(OFFSET, Metadata.OptBlockState(value));
|
||||
metadata.set(MetadataDef.Enderman.CARRIED_BLOCK, value);
|
||||
}
|
||||
|
||||
public boolean isScreaming() {
|
||||
return super.metadata.getIndex(OFFSET + 1, false);
|
||||
return metadata.get(MetadataDef.Enderman.IS_SCREAMING);
|
||||
}
|
||||
|
||||
public void setScreaming(boolean value) {
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.Boolean(value));
|
||||
metadata.set(MetadataDef.Enderman.IS_SCREAMING, value);
|
||||
}
|
||||
|
||||
public boolean isStaring() {
|
||||
return super.metadata.getIndex(OFFSET + 2, false);
|
||||
return metadata.get(MetadataDef.Enderman.IS_STARING);
|
||||
}
|
||||
|
||||
public void setStaring(boolean value) {
|
||||
super.metadata.setIndex(OFFSET + 2, Metadata.Boolean(value));
|
||||
metadata.set(MetadataDef.Enderman.IS_STARING, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,9 +5,6 @@ import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EndermiteMeta extends MonsterMeta {
|
||||
public static final byte OFFSET = MonsterMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public EndermiteMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
@ -5,9 +5,6 @@ import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class GiantMeta extends MonsterMeta {
|
||||
public static final byte OFFSET = MonsterMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public GiantMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
@ -1,15 +1,13 @@
|
||||
package net.minestom.server.entity.metadata.monster;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class GuardianMeta extends MonsterMeta {
|
||||
public static final byte OFFSET = MonsterMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 2;
|
||||
|
||||
private Entity target;
|
||||
|
||||
public GuardianMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
@ -17,11 +15,20 @@ public class GuardianMeta extends MonsterMeta {
|
||||
}
|
||||
|
||||
public boolean isRetractingSpikes() {
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
return metadata.get(MetadataDef.Guardian.IS_RETRACTING_SPIKES);
|
||||
}
|
||||
|
||||
public void setRetractingSpikes(boolean retractingSpikes) {
|
||||
super.metadata.setIndex(OFFSET, Metadata.Boolean(retractingSpikes));
|
||||
public void setRetractingSpikes(boolean value) {
|
||||
metadata.set(MetadataDef.Guardian.IS_RETRACTING_SPIKES, value);
|
||||
}
|
||||
|
||||
public int getTargetEntityId() {
|
||||
return metadata.get(MetadataDef.Guardian.TARGET_EID);
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public void setTargetEntityId(int value) {
|
||||
metadata.set(MetadataDef.Guardian.TARGET_EID, value);
|
||||
}
|
||||
|
||||
public Entity getTarget() {
|
||||
@ -30,7 +37,7 @@ public class GuardianMeta extends MonsterMeta {
|
||||
|
||||
public void setTarget(@Nullable Entity target) {
|
||||
this.target = target;
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.VarInt(target == null ? 0 : target.getEntityId()));
|
||||
setTargetEntityId(target == null ? 0 : target.getEntityId());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,9 +6,6 @@ import net.minestom.server.entity.metadata.PathfinderMobMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MonsterMeta extends PathfinderMobMeta {
|
||||
public static final byte OFFSET = PathfinderMobMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
protected MonsterMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
@ -5,9 +5,6 @@ import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PiglinBruteMeta extends BasePiglinMeta {
|
||||
public static final byte OFFSET = BasePiglinMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public PiglinBruteMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
@ -2,20 +2,17 @@ package net.minestom.server.entity.metadata.monster;
|
||||
|
||||
import net.minestom.server.collision.BoundingBox;
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PiglinMeta extends BasePiglinMeta {
|
||||
public static final byte OFFSET = BasePiglinMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 3;
|
||||
|
||||
public PiglinMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean isBaby() {
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
return metadata.get(MetadataDef.Piglin.IS_BABY);
|
||||
}
|
||||
|
||||
public void setBaby(boolean value) {
|
||||
@ -32,23 +29,23 @@ public class PiglinMeta extends BasePiglinMeta {
|
||||
entity.setBoundingBox(width, bb.height() * 2, width);
|
||||
}
|
||||
});
|
||||
super.metadata.setIndex(OFFSET, Metadata.Boolean(value));
|
||||
metadata.set(MetadataDef.Piglin.IS_BABY, value);
|
||||
}
|
||||
|
||||
public boolean isChargingCrossbow() {
|
||||
return super.metadata.getIndex(OFFSET + 1, false);
|
||||
return metadata.get(MetadataDef.Piglin.IS_CHARGING_CROSSBOW);
|
||||
}
|
||||
|
||||
public void setChargingCrossbow(boolean value) {
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.Boolean(value));
|
||||
metadata.set(MetadataDef.Piglin.IS_CHARGING_CROSSBOW, value);
|
||||
}
|
||||
|
||||
public boolean isDancing() {
|
||||
return super.metadata.getIndex(OFFSET + 2, false);
|
||||
return metadata.get(MetadataDef.Piglin.IS_DANCING);
|
||||
}
|
||||
|
||||
public void setDancing(boolean value) {
|
||||
super.metadata.setIndex(OFFSET + 2, Metadata.Boolean(value));
|
||||
metadata.set(MetadataDef.Piglin.IS_DANCING, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,9 +5,6 @@ import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SilverfishMeta extends MonsterMeta {
|
||||
public static final byte OFFSET = MonsterMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public SilverfishMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
@ -1,25 +1,21 @@
|
||||
package net.minestom.server.entity.metadata.monster;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SpiderMeta extends MonsterMeta {
|
||||
public static final byte OFFSET = MonsterMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
private final static byte CLIMBING_BIT = 0x01;
|
||||
|
||||
public SpiderMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean isClimbing() {
|
||||
return getMaskBit(OFFSET, CLIMBING_BIT);
|
||||
return metadata.get(MetadataDef.Spider.IS_CLIMBING);
|
||||
}
|
||||
|
||||
public void setClimbing(boolean value) {
|
||||
setMaskBit(OFFSET, CLIMBING_BIT, value);
|
||||
metadata.set(MetadataDef.Spider.IS_CLIMBING, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,25 +1,21 @@
|
||||
package net.minestom.server.entity.metadata.monster;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class VexMeta extends MonsterMeta {
|
||||
public static final byte OFFSET = MonsterMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
private final static byte ATTACKING_BIT = 0x01;
|
||||
|
||||
public VexMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean isAttacking() {
|
||||
return getMaskBit(OFFSET, ATTACKING_BIT);
|
||||
return metadata.get(MetadataDef.Vex.IS_ATTACKING);
|
||||
}
|
||||
|
||||
public void setAttacking(boolean value) {
|
||||
setMaskBit(OFFSET, ATTACKING_BIT, value);
|
||||
metadata.set(MetadataDef.Vex.IS_ATTACKING, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,25 +1,21 @@
|
||||
package net.minestom.server.entity.metadata.monster;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class WardenMeta extends MonsterMeta {
|
||||
|
||||
public static final byte OFFSET = MonsterMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public WardenMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public int getAngerLevel() {
|
||||
return super.metadata.getIndex(OFFSET, 0);
|
||||
return metadata.get(MetadataDef.Warden.ANGER_LEVEL);
|
||||
}
|
||||
|
||||
public void setAngerLevel(int value) {
|
||||
super.metadata.setIndex(OFFSET, Metadata.VarInt(value));
|
||||
metadata.set(MetadataDef.Warden.ANGER_LEVEL, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,15 +1,13 @@
|
||||
package net.minestom.server.entity.metadata.monster;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class WitherMeta extends MonsterMeta {
|
||||
public static final byte OFFSET = MonsterMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 4;
|
||||
|
||||
private Entity centerHead;
|
||||
private Entity leftHead;
|
||||
private Entity rightHead;
|
||||
@ -18,6 +16,15 @@ public class WitherMeta extends MonsterMeta {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public int getCenterHeadEntityId() {
|
||||
return metadata.get(MetadataDef.Wither.CENTER_HEAD_TARGET);
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public void setCenterHeadEntityId(int value) {
|
||||
metadata.set(MetadataDef.Wither.CENTER_HEAD_TARGET, value);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Entity getCenterHead() {
|
||||
return this.centerHead;
|
||||
@ -25,7 +32,16 @@ public class WitherMeta extends MonsterMeta {
|
||||
|
||||
public void setCenterHead(@Nullable Entity value) {
|
||||
this.centerHead = value;
|
||||
super.metadata.setIndex(OFFSET, Metadata.VarInt(value == null ? 0 : value.getEntityId()));
|
||||
setCenterHeadEntityId(value == null ? 0 : value.getEntityId());
|
||||
}
|
||||
|
||||
public int getLeftHeadEntityId() {
|
||||
return metadata.get(MetadataDef.Wither.LEFT_HEAD_TARGET);
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public void setLeftHeadEntityId(int value) {
|
||||
metadata.set(MetadataDef.Wither.LEFT_HEAD_TARGET, value);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@ -35,7 +51,16 @@ public class WitherMeta extends MonsterMeta {
|
||||
|
||||
public void setLeftHead(@Nullable Entity value) {
|
||||
this.leftHead = value;
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.VarInt(value == null ? 0 : value.getEntityId()));
|
||||
setLeftHeadEntityId(value == null ? 0 : value.getEntityId());
|
||||
}
|
||||
|
||||
public int getRightHeadEntityId() {
|
||||
return metadata.get(MetadataDef.Wither.RIGHT_HEAD_TARGET);
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public void setRightHeadEntityId(int value) {
|
||||
metadata.set(MetadataDef.Wither.RIGHT_HEAD_TARGET, value);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@ -45,15 +70,15 @@ public class WitherMeta extends MonsterMeta {
|
||||
|
||||
public void setRightHead(@Nullable Entity value) {
|
||||
this.rightHead = value;
|
||||
super.metadata.setIndex(OFFSET + 2, Metadata.VarInt(value == null ? 0 : value.getEntityId()));
|
||||
setRightHeadEntityId(value == null ? 0 : value.getEntityId());
|
||||
}
|
||||
|
||||
public int getInvulnerableTime() {
|
||||
return super.metadata.getIndex(OFFSET + 3, 0);
|
||||
return metadata.get(MetadataDef.Wither.INVULNERABLE_TIME);
|
||||
}
|
||||
|
||||
public void setInvulnerableTime(int value) {
|
||||
super.metadata.setIndex(OFFSET + 3, Metadata.VarInt(value));
|
||||
metadata.set(MetadataDef.Wither.INVULNERABLE_TIME, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,20 +2,17 @@ package net.minestom.server.entity.metadata.monster;
|
||||
|
||||
import net.minestom.server.collision.BoundingBox;
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ZoglinMeta extends MonsterMeta {
|
||||
public static final byte OFFSET = MonsterMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public ZoglinMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean isBaby() {
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
return metadata.get(MetadataDef.Zoglin.IS_BABY);
|
||||
}
|
||||
|
||||
public void setBaby(boolean value) {
|
||||
@ -32,7 +29,7 @@ public class ZoglinMeta extends MonsterMeta {
|
||||
entity.setBoundingBox(width, bb.height() * 2, width);
|
||||
}
|
||||
});
|
||||
super.metadata.setIndex(OFFSET, Metadata.Boolean(value));
|
||||
metadata.set(MetadataDef.Zoglin.IS_BABY, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,9 +5,6 @@ import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AbstractIllagerMeta extends RaiderMeta {
|
||||
public static final byte OFFSET = RaiderMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
protected AbstractIllagerMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
@ -5,9 +5,6 @@ import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EvokerMeta extends SpellcasterIllagerMeta {
|
||||
public static final byte OFFSET = SpellcasterIllagerMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public EvokerMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
@ -5,9 +5,6 @@ import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class IllusionerMeta extends SpellcasterIllagerMeta {
|
||||
public static final byte OFFSET = SpellcasterIllagerMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public IllusionerMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
@ -1,24 +1,21 @@
|
||||
package net.minestom.server.entity.metadata.monster.raider;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PillagerMeta extends AbstractIllagerMeta {
|
||||
public static final byte OFFSET = AbstractIllagerMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public PillagerMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean isChargingCrossbow() {
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
return metadata.get(MetadataDef.Pillager.IS_CHARGING);
|
||||
}
|
||||
|
||||
public void setChargingCrossbow(boolean value) {
|
||||
super.metadata.setIndex(OFFSET, Metadata.Boolean(value));
|
||||
metadata.set(MetadataDef.Pillager.IS_CHARGING, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,25 +1,22 @@
|
||||
package net.minestom.server.entity.metadata.monster.raider;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.MetadataDef;
|
||||
import net.minestom.server.entity.MetadataHolder;
|
||||
import net.minestom.server.entity.metadata.monster.MonsterMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class RaiderMeta extends MonsterMeta {
|
||||
public static final byte OFFSET = MonsterMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
protected RaiderMeta(@NotNull Entity entity, @NotNull MetadataHolder metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean isCelebrating() {
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
return metadata.get(MetadataDef.Raider.IS_CELEBRATING);
|
||||
}
|
||||
|
||||
public void setCelebrating(boolean value) {
|
||||
super.metadata.setIndex(OFFSET, Metadata.Boolean(value));
|
||||
metadata.set(MetadataDef.Raider.IS_CELEBRATING, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user