mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-31 21:48:08 +01:00
Meta wrappers for all the entities
This commit is contained in:
parent
6eda8f97db
commit
0915858df3
@ -11,7 +11,6 @@ import net.minestom.server.entity.type.other.EntityAreaEffectCloud;
|
||||
import net.minestom.server.entity.type.other.EntityIronGolem;
|
||||
import net.minestom.server.entity.type.other.EntityShulker;
|
||||
import net.minestom.server.entity.type.other.EntitySnowman;
|
||||
import net.minestom.server.entity.type.projectile.EntityArrow;
|
||||
import net.minestom.server.entity.type.projectile.EntityPotion;
|
||||
import net.minestom.server.entity.type.projectile.EntitySpectralArrow;
|
||||
import net.minestom.server.entity.type.vehicle.EntityBoat;
|
||||
@ -291,6 +290,14 @@ public enum EntityType {
|
||||
return this.defaultGenerator.apply(position);
|
||||
}
|
||||
|
||||
public double getDefaultWidth() {
|
||||
return 0D;
|
||||
}
|
||||
|
||||
public double getDefaultHeight() {
|
||||
return 0D;
|
||||
}
|
||||
|
||||
public static EntityType fromId(int id) {
|
||||
if (id >= 0 && id < values().length) {
|
||||
return values()[id];
|
||||
|
@ -9,7 +9,7 @@ import net.minestom.server.utils.NamespaceID;
|
||||
* //==============================
|
||||
*/
|
||||
@SuppressWarnings({"deprecation"})
|
||||
public enum Particle {
|
||||
public enum ParticleType {
|
||||
AMBIENT_ENTITY_EFFECT("minecraft:ambient_entity_effect"),
|
||||
|
||||
ANGRY_VILLAGER("minecraft:angry_villager"),
|
||||
@ -156,9 +156,9 @@ public enum Particle {
|
||||
|
||||
private String namespaceID;
|
||||
|
||||
Particle(String namespaceID) {
|
||||
ParticleType(String namespaceID) {
|
||||
this.namespaceID = namespaceID;
|
||||
Registries.particles.put(NamespaceID.from(namespaceID), this);
|
||||
Registries.particleTypes.put(NamespaceID.from(namespaceID), this);
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
@ -169,7 +169,7 @@ public enum Particle {
|
||||
return namespaceID;
|
||||
}
|
||||
|
||||
public static Particle fromId(int id) {
|
||||
public static ParticleType fromId(int id) {
|
||||
if (id >= 0 && id < values().length) {
|
||||
return values()[id];
|
||||
}
|
@ -1,12 +1,13 @@
|
||||
// AUTOGENERATED by net.minestom.codegen.RegistriesGenerator
|
||||
package net.minestom.server.registry;
|
||||
|
||||
import java.util.HashMap;
|
||||
import net.minestom.server.entity.EntityType;
|
||||
import net.minestom.server.fluids.Fluid;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import net.minestom.server.item.Enchantment;
|
||||
import net.minestom.server.item.Material;
|
||||
import net.minestom.server.particle.Particle;
|
||||
import net.minestom.server.particle.ParticleType;
|
||||
import net.minestom.server.potion.PotionEffect;
|
||||
import net.minestom.server.potion.PotionType;
|
||||
import net.minestom.server.sound.Sound;
|
||||
@ -15,8 +16,6 @@ import net.minestom.server.utils.NamespaceID;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* AUTOGENERATED
|
||||
*/
|
||||
@ -49,7 +48,7 @@ public final class Registries {
|
||||
* Should only be used for internal code, please use the get* methods.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final HashMap<NamespaceID, Particle> particles = new HashMap<>();
|
||||
public static final HashMap<NamespaceID, ParticleType> particleTypes = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Should only be used for internal code, please use the get* methods.
|
||||
@ -130,35 +129,35 @@ public final class Registries {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the corresponding EntityType matching the given id. Returns null if none match.
|
||||
* Returns the corresponding EntityType matching the given id. Returns 'PIG' if none match.
|
||||
*/
|
||||
@Nullable
|
||||
@NotNull
|
||||
public static EntityType getEntityType(String id) {
|
||||
return getEntityType(NamespaceID.from(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the corresponding EntityType matching the given id. Returns null if none match.
|
||||
* Returns the corresponding EntityType matching the given id. Returns 'PIG' if none match.
|
||||
*/
|
||||
@Nullable
|
||||
@NotNull
|
||||
public static EntityType getEntityType(NamespaceID id) {
|
||||
return entityTypes.get(id);
|
||||
return entityTypes.getOrDefault(id, EntityType.PIG);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the corresponding Particle matching the given id. Returns null if none match.
|
||||
* Returns the corresponding ParticleType matching the given id. Returns null if none match.
|
||||
*/
|
||||
@Nullable
|
||||
public static Particle getParticle(String id) {
|
||||
return getParticle(NamespaceID.from(id));
|
||||
public static ParticleType getParticleType(String id) {
|
||||
return getParticleType(NamespaceID.from(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the corresponding Particle matching the given id. Returns null if none match.
|
||||
* Returns the corresponding ParticleType matching the given id. Returns null if none match.
|
||||
*/
|
||||
@Nullable
|
||||
public static Particle getParticle(NamespaceID id) {
|
||||
return particles.get(id);
|
||||
public static ParticleType getParticleType(NamespaceID id) {
|
||||
return particleTypes.get(id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -5,7 +5,7 @@ import net.minestom.codegen.enchantment.EnchantmentEnumGenerator;
|
||||
import net.minestom.codegen.entitytypes.EntityTypeEnumGenerator;
|
||||
import net.minestom.codegen.fluids.FluidEnumGenerator;
|
||||
import net.minestom.codegen.items.ItemEnumGenerator;
|
||||
import net.minestom.codegen.particles.ParticleEnumGenerator;
|
||||
import net.minestom.codegen.particles.ParticleTypeEnumGenerator;
|
||||
import net.minestom.codegen.potions.PotionEffectEnumGenerator;
|
||||
import net.minestom.codegen.potions.PotionEnumGenerator;
|
||||
import net.minestom.codegen.sounds.SoundEnumGenerator;
|
||||
@ -23,7 +23,7 @@ public class AllGenerators {
|
||||
EnchantmentEnumGenerator.main(args);
|
||||
EntityTypeEnumGenerator.main(args);
|
||||
SoundEnumGenerator.main(args);
|
||||
ParticleEnumGenerator.main(args);
|
||||
ParticleTypeEnumGenerator.main(args);
|
||||
StatsEnumGenerator.main(args);
|
||||
FluidEnumGenerator.main(args);
|
||||
RegistriesGenerator.main(args);
|
||||
|
@ -6,7 +6,7 @@ import net.minestom.server.fluids.Fluid;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import net.minestom.server.item.Enchantment;
|
||||
import net.minestom.server.item.Material;
|
||||
import net.minestom.server.particle.Particle;
|
||||
import net.minestom.server.particle.ParticleType;
|
||||
import net.minestom.server.potion.PotionEffect;
|
||||
import net.minestom.server.potion.PotionType;
|
||||
import net.minestom.server.registry.ResourceGatherer;
|
||||
@ -40,7 +40,7 @@ public class RegistriesGenerator implements CodeGenerator {
|
||||
new ImmutablePair<>(Material.class.getCanonicalName(), "AIR"),
|
||||
new ImmutablePair<>(Enchantment.class.getCanonicalName(), null),
|
||||
new ImmutablePair<>(EntityType.class.getCanonicalName(), "PIG"),
|
||||
new ImmutablePair<>(Particle.class.getCanonicalName(), null),
|
||||
new ImmutablePair<>(ParticleType.class.getCanonicalName(), null),
|
||||
new ImmutablePair<>(PotionType.class.getCanonicalName(), null),
|
||||
new ImmutablePair<>(PotionEffect.class.getCanonicalName(), null),
|
||||
new ImmutablePair<>(Sound.class.getCanonicalName(), null),
|
||||
|
@ -1,17 +1,17 @@
|
||||
package net.minestom.codegen.particles;
|
||||
|
||||
import net.minestom.codegen.BasicEnumGenerator;
|
||||
import net.minestom.codegen.stats.StatsEnumGenerator;
|
||||
import net.minestom.server.registry.ResourceGatherer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class ParticleEnumGenerator extends BasicEnumGenerator {
|
||||
public class ParticleTypeEnumGenerator extends BasicEnumGenerator {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ParticleEnumGenerator.class);
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ParticleTypeEnumGenerator.class);
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
String targetVersion;
|
||||
@ -38,10 +38,10 @@ public class ParticleEnumGenerator extends BasicEnumGenerator {
|
||||
targetFolder.mkdirs();
|
||||
}
|
||||
|
||||
new ParticleEnumGenerator(targetFolder);
|
||||
new ParticleTypeEnumGenerator(targetFolder);
|
||||
}
|
||||
|
||||
private ParticleEnumGenerator(File targetFolder) throws IOException {
|
||||
private ParticleTypeEnumGenerator(File targetFolder) throws IOException {
|
||||
super(targetFolder);
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ public class ParticleEnumGenerator extends BasicEnumGenerator {
|
||||
|
||||
@Override
|
||||
public String getClassName() {
|
||||
return "Particle";
|
||||
return "ParticleType";
|
||||
}
|
||||
|
||||
@Override
|
@ -30,7 +30,7 @@ import net.minestom.server.network.netty.NettyServer;
|
||||
import net.minestom.server.network.packet.server.play.PluginMessagePacket;
|
||||
import net.minestom.server.network.packet.server.play.ServerDifficultyPacket;
|
||||
import net.minestom.server.network.packet.server.play.UpdateViewDistancePacket;
|
||||
import net.minestom.server.particle.Particle;
|
||||
import net.minestom.server.particle.ParticleType;
|
||||
import net.minestom.server.ping.ResponseDataConsumer;
|
||||
import net.minestom.server.potion.PotionEffect;
|
||||
import net.minestom.server.potion.PotionType;
|
||||
@ -159,7 +159,7 @@ public final class MinecraftServer {
|
||||
Enchantment.values();
|
||||
EntityType.values();
|
||||
Sound.values();
|
||||
Particle.values();
|
||||
ParticleType.values();
|
||||
StatisticType.values();
|
||||
Fluid.values();
|
||||
|
||||
|
@ -6,7 +6,7 @@ import net.minestom.server.entity.EntityType;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import net.minestom.server.item.Enchantment;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import net.minestom.server.particle.Particle;
|
||||
import net.minestom.server.particle.ParticleType;
|
||||
import net.minestom.server.potion.PotionEffect;
|
||||
import net.minestom.server.utils.entity.EntityFinder;
|
||||
import net.minestom.server.utils.location.RelativeBlockPosition;
|
||||
@ -156,8 +156,8 @@ public final class Arguments {
|
||||
*/
|
||||
@Deprecated
|
||||
@NotNull
|
||||
public Particle getParticle(@NotNull String id) {
|
||||
return (Particle) getObject(id);
|
||||
public ParticleType getParticle(@NotNull String id) {
|
||||
return (ParticleType) getObject(id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2,22 +2,22 @@ package net.minestom.server.command.builder.arguments.minecraft.registry;
|
||||
|
||||
import net.minestom.server.command.builder.NodeMaker;
|
||||
import net.minestom.server.network.packet.server.play.DeclareCommandsPacket;
|
||||
import net.minestom.server.particle.Particle;
|
||||
import net.minestom.server.particle.ParticleType;
|
||||
import net.minestom.server.registry.Registries;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents an argument giving a {@link Particle}.
|
||||
* Represents an argument giving a {@link ParticleType}.
|
||||
*/
|
||||
public class ArgumentParticle extends ArgumentRegistry<Particle> {
|
||||
public class ArgumentParticle extends ArgumentRegistry<ParticleType> {
|
||||
|
||||
public ArgumentParticle(String id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Particle getRegistry(@NotNull String value) {
|
||||
return Registries.getParticle(value);
|
||||
public ParticleType getRegistry(@NotNull String value) {
|
||||
return Registries.getParticleType(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -158,6 +158,10 @@ public abstract class Entity implements Viewable, EventHandler, DataContainer, P
|
||||
this(entityType, new Position());
|
||||
}
|
||||
|
||||
public Metadata getMetadata() {
|
||||
return this.metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedules a task to be run during the next entity tick.
|
||||
* It ensures that the task will be executed in the same thread as the entity (depending of the {@link ThreadProvider}).
|
||||
|
@ -3,6 +3,7 @@ package net.minestom.server.entity;
|
||||
import net.minestom.server.chat.JsonMessage;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import net.minestom.server.network.packet.server.play.EntityMetaDataPacket;
|
||||
import net.minestom.server.particle.Particle;
|
||||
import net.minestom.server.utils.BlockPosition;
|
||||
import net.minestom.server.utils.Direction;
|
||||
import net.minestom.server.utils.Vector;
|
||||
@ -131,6 +132,15 @@ public class Metadata {
|
||||
return new Value<>(TYPE_POSE, value, writer -> writer.writeVarInt(value.ordinal()));
|
||||
}
|
||||
|
||||
public static Value<Particle> Particle(@NotNull Particle value) {
|
||||
return new Value<>(TYPE_PARTICLE, value, writer -> {
|
||||
writer.writeVarInt(value.getType().getId());
|
||||
if (value.getDataWriter() != null) {
|
||||
value.getDataWriter().accept(writer);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static final byte TYPE_BYTE = 0;
|
||||
public static final byte TYPE_VARINT = 1;
|
||||
public static final byte TYPE_FLOAT = 2;
|
||||
|
@ -0,0 +1,31 @@
|
||||
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 org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AgeableMobMeta extends PathfinderMobMeta {
|
||||
|
||||
protected AgeableMobMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
public boolean isBaby() {
|
||||
return getMetadata().getIndex((byte) 15, false);
|
||||
}
|
||||
|
||||
public void setBaby(boolean value) {
|
||||
if (isBaby() == value) {
|
||||
return;
|
||||
}
|
||||
BoundingBox bb = this.entity.getBoundingBox();
|
||||
if (value) {
|
||||
setBoundingBox(bb.getWidth() / 2, bb.getHeight() / 2);
|
||||
} else {
|
||||
setBoundingBox(bb.getWidth() * 2, bb.getHeight() * 2);
|
||||
}
|
||||
getMetadata().getIndex((byte) 15, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,168 @@
|
||||
package net.minestom.server.entity.metadata;
|
||||
|
||||
import net.minestom.server.chat.JsonMessage;
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EntityMeta {
|
||||
|
||||
private final static byte MASK_INDEX = 0;
|
||||
|
||||
private final static byte ON_FIRE_BIT = 0x01;
|
||||
private final static byte CROUNCHING_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;
|
||||
|
||||
protected final Entity entity;
|
||||
|
||||
protected EntityMeta(@NotNull Entity entity) {
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
public boolean isOnFire() {
|
||||
return getMaskBit(MASK_INDEX, ON_FIRE_BIT);
|
||||
}
|
||||
|
||||
public void setOnFire(boolean value) {
|
||||
setMaskBit(MASK_INDEX, ON_FIRE_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isCrounching() {
|
||||
return getMaskBit(MASK_INDEX, CROUNCHING_BIT);
|
||||
}
|
||||
|
||||
public void setCrounching(boolean value) {
|
||||
setMaskBit(MASK_INDEX, CROUNCHING_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isSprinting() {
|
||||
return getMaskBit(MASK_INDEX, SPRINTING_BIT);
|
||||
}
|
||||
|
||||
public void setSprinting(boolean value) {
|
||||
setMaskBit(MASK_INDEX, SPRINTING_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isSwimming() {
|
||||
return getMaskBit(MASK_INDEX, SWIMMING_BIT);
|
||||
}
|
||||
|
||||
public void setSwimming(boolean value) {
|
||||
setMaskBit(MASK_INDEX, SWIMMING_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isInvisible() {
|
||||
return getMaskBit(MASK_INDEX, INVISIBLE_BIT);
|
||||
}
|
||||
|
||||
public void setInvisible(boolean value) {
|
||||
setMaskBit(MASK_INDEX, INVISIBLE_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isHasGlowingEffect() {
|
||||
return getMaskBit(MASK_INDEX, HAS_GLOWING_EFFECT_BIT);
|
||||
}
|
||||
|
||||
public void setHasGlowingEffect(boolean value) {
|
||||
setMaskBit(MASK_INDEX, HAS_GLOWING_EFFECT_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isFlyingWithElytra() {
|
||||
return getMaskBit(MASK_INDEX, FLYING_WITH_ELYTRA_BIT);
|
||||
}
|
||||
|
||||
public void setFlyingWithElytra(boolean value) {
|
||||
setMaskBit(MASK_INDEX, FLYING_WITH_ELYTRA_BIT, value);
|
||||
}
|
||||
|
||||
public int getAirTicks() {
|
||||
return getMetadata().getIndex((byte) 1, 300);
|
||||
}
|
||||
|
||||
public void setAirTicks(int value) {
|
||||
getMetadata().setIndex((byte) 1, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
public JsonMessage getCustomName() {
|
||||
return getMetadata().getIndex((byte) 2, null);
|
||||
}
|
||||
|
||||
public void setCustomName(JsonMessage value) {
|
||||
getMetadata().setIndex((byte) 2, Metadata.OptChat(value));
|
||||
}
|
||||
|
||||
public boolean isCustomNameVisible() {
|
||||
return getMetadata().getIndex((byte) 3, false);
|
||||
}
|
||||
|
||||
public void setCustomNameVisible(boolean value) {
|
||||
getMetadata().setIndex((byte) 3, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
public boolean isSilent() {
|
||||
return getMetadata().getIndex((byte) 4, false);
|
||||
}
|
||||
|
||||
public void setSilent(boolean value) {
|
||||
getMetadata().setIndex((byte) 4, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
public boolean isHasNoGravity() {
|
||||
return getMetadata().getIndex((byte) 5, false);
|
||||
}
|
||||
|
||||
public void setHasNoGravity(boolean value) {
|
||||
getMetadata().setIndex((byte) 5, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
public Entity.Pose getPose() {
|
||||
return getMetadata().getIndex((byte) 6, Entity.Pose.STANDING);
|
||||
}
|
||||
|
||||
public void setPose(Entity.Pose value) {
|
||||
getMetadata().setIndex((byte) 6, Metadata.Pose(value));
|
||||
}
|
||||
|
||||
protected Metadata getMetadata() {
|
||||
return this.entity.getMetadata();
|
||||
}
|
||||
|
||||
protected byte getMask(byte index) {
|
||||
return getMetadata().getIndex(index, (byte) 0);
|
||||
}
|
||||
|
||||
protected void setMask(byte index, byte mask) {
|
||||
getMetadata().setIndex(index, Metadata.Byte(mask));
|
||||
}
|
||||
|
||||
protected boolean getMaskBit(byte index, byte bit) {
|
||||
return (getMask(index) & bit) == bit;
|
||||
}
|
||||
|
||||
protected void setMaskBit(byte 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);
|
||||
}
|
||||
|
||||
protected void setBoundingBox(double x, double y, double z) {
|
||||
this.entity.setBoundingBox(x, y, z);
|
||||
}
|
||||
|
||||
protected void setBoundingBox(double width, double height) {
|
||||
setBoundingBox(width, height, width);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
package net.minestom.server.entity.metadata;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.utils.BlockPosition;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class LivingEntityMeta extends EntityMeta {
|
||||
|
||||
private final static byte MASK_INDEX = 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) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
public boolean isHandActive() {
|
||||
return getMaskBit(MASK_INDEX, IS_HAND_ACTIVE_BIT);
|
||||
}
|
||||
|
||||
public void setHandActive(boolean value) {
|
||||
setMaskBit(MASK_INDEX, IS_HAND_ACTIVE_BIT, value);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Player.Hand getActiveHand() {
|
||||
return getMaskBit(MASK_INDEX, ACTIVE_HAND_BIT) ? Player.Hand.OFF : Player.Hand.MAIN;
|
||||
}
|
||||
|
||||
public void setActiveHand(@NotNull Player.Hand hand) {
|
||||
setMaskBit(MASK_INDEX, ACTIVE_HAND_BIT, hand == Player.Hand.OFF);
|
||||
}
|
||||
|
||||
public boolean isInRiptideSpinAttack() {
|
||||
return getMaskBit(MASK_INDEX, IS_IN_SPIN_ATTACK_BIT);
|
||||
}
|
||||
|
||||
public void setInRiptideSpinAttack(boolean value) {
|
||||
setMaskBit(MASK_INDEX, IS_IN_SPIN_ATTACK_BIT, value);
|
||||
}
|
||||
|
||||
public float getHealth() {
|
||||
return getMetadata().getIndex((byte) 8, 1F);
|
||||
}
|
||||
|
||||
public void setHealth(float value) {
|
||||
getMetadata().setIndex((byte) 8, Metadata.Float(value));
|
||||
}
|
||||
|
||||
public int getPotionEffectColor() {
|
||||
return getMetadata().getIndex((byte) 9, 0);
|
||||
}
|
||||
|
||||
public void setPotionEffectColor(int value) {
|
||||
getMetadata().setIndex((byte) 9, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
public boolean isPotionEffectAmbient() {
|
||||
return getMetadata().getIndex((byte) 10, false);
|
||||
}
|
||||
|
||||
public void setPotionEffectAmbient(boolean value) {
|
||||
getMetadata().setIndex((byte) 10, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
public int getNumberOfArrows() {
|
||||
return getMetadata().getIndex((byte) 11, 0);
|
||||
}
|
||||
|
||||
public void setNumberOfArrows(int value) {
|
||||
getMetadata().getIndex((byte) 11, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
public int getHealthAddedByAbsorption() {
|
||||
return getMetadata().getIndex((byte) 12, 0);
|
||||
}
|
||||
|
||||
public void setHealthAddedByAbsorption(int value) {
|
||||
getMetadata().getIndex((byte) 12, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public BlockPosition getBedInWhichSleepingPosition() {
|
||||
return getMetadata().getIndex((byte) 13, null);
|
||||
}
|
||||
|
||||
public void setBedInWhichSleepingPosition(@Nullable BlockPosition value) {
|
||||
getMetadata().setIndex((byte) 13, Metadata.OptPosition(value));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package net.minestom.server.entity.metadata;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MobMeta extends LivingEntityMeta {
|
||||
|
||||
private final static byte MASK_INDEX = 14;
|
||||
|
||||
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) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
public boolean isNoAi() {
|
||||
return getMaskBit(MASK_INDEX, NO_AI_BIT);
|
||||
}
|
||||
|
||||
public void setNoAi(boolean value) {
|
||||
setMaskBit(MASK_INDEX, NO_AI_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isLeftHanded() {
|
||||
return getMaskBit(MASK_INDEX, IS_LEFT_HANDED_BIT);
|
||||
}
|
||||
|
||||
public void setLeftHanded(boolean value) {
|
||||
setMaskBit(MASK_INDEX, IS_LEFT_HANDED_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isAggressive() {
|
||||
return getMaskBit(MASK_INDEX, IS_AGGRESSIVE_BIT);
|
||||
}
|
||||
|
||||
public void setAggressive(boolean value) {
|
||||
setMaskBit(MASK_INDEX, IS_AGGRESSIVE_BIT, value);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package net.minestom.server.entity.metadata;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PathfinderMobMeta extends MobMeta {
|
||||
|
||||
protected PathfinderMobMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,124 @@
|
||||
package net.minestom.server.entity.metadata;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jglrxavpok.hephaistos.nbt.NBT;
|
||||
|
||||
public class PlayerMeta extends LivingEntityMeta {
|
||||
|
||||
private final static byte MASK_INDEX = 16;
|
||||
|
||||
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) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
public float getAdditionalHearts() {
|
||||
return getMetadata().getIndex((byte) 14, 0F);
|
||||
}
|
||||
|
||||
public void setAdditionalHearts(float value) {
|
||||
getMetadata().setIndex((byte) 14, Metadata.Float(value));
|
||||
}
|
||||
|
||||
public int getScore() {
|
||||
return getMetadata().getIndex((byte) 15, 0);
|
||||
}
|
||||
|
||||
public void setScore(int value) {
|
||||
getMetadata().setIndex((byte) 15, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
public boolean isCapeEnabled() {
|
||||
return getMaskBit(MASK_INDEX, CAPE_BIT);
|
||||
}
|
||||
|
||||
public void setCapeEnabled(boolean value) {
|
||||
setMaskBit(MASK_INDEX, CAPE_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isJacketEnabled() {
|
||||
return getMaskBit(MASK_INDEX, JACKET_BIT);
|
||||
}
|
||||
|
||||
public void setJacketEnabled(boolean value) {
|
||||
setMaskBit(MASK_INDEX, JACKET_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isLeftSleeveEnabled() {
|
||||
return getMaskBit(MASK_INDEX, LEFT_SLEEVE_BIT);
|
||||
}
|
||||
|
||||
public void setLeftSleeveEnabled(boolean value) {
|
||||
setMaskBit(MASK_INDEX, LEFT_SLEEVE_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isRightSleeveEnabled() {
|
||||
return getMaskBit(MASK_INDEX, RIGHT_SLEEVE_BIT);
|
||||
}
|
||||
|
||||
public void setRightSleeveEnabled(boolean value) {
|
||||
setMaskBit(MASK_INDEX, RIGHT_SLEEVE_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isLeftLegEnabled() {
|
||||
return getMaskBit(MASK_INDEX, LEFT_LEG_BIT);
|
||||
}
|
||||
|
||||
public void setLeftLegEnabled(boolean value) {
|
||||
setMaskBit(MASK_INDEX, LEFT_LEG_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isRightLegEnabled() {
|
||||
return getMaskBit(MASK_INDEX, RIGHT_LEG_BIT);
|
||||
}
|
||||
|
||||
public void setRightLegEnabled(boolean value) {
|
||||
setMaskBit(MASK_INDEX, RIGHT_LEG_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isHatEnabled() {
|
||||
return getMaskBit(MASK_INDEX, HAT_BIT);
|
||||
}
|
||||
|
||||
public void setHatEnabled(boolean value) {
|
||||
setMaskBit(MASK_INDEX, HAT_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isRightMainHand() {
|
||||
return getMetadata().getIndex((byte) 17, (byte) 1) == (byte) 1;
|
||||
}
|
||||
|
||||
public void setRightMainHand(boolean value) {
|
||||
getMetadata().setIndex((byte) 17, Metadata.Byte(value ? (byte) 1 : (byte) 0));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public NBT getLeftShoulderEntityData() {
|
||||
return getMetadata().getIndex((byte) 18, null);
|
||||
}
|
||||
|
||||
public void setLeftShoulderEntityData(@Nullable NBT value) {
|
||||
getMetadata().setIndex((byte) 18, Metadata.NBT(value));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public NBT getRightShoulderEntityData() {
|
||||
return getMetadata().getIndex((byte) 19, null);
|
||||
}
|
||||
|
||||
public void setRightShoulderEntityData(@Nullable NBT value) {
|
||||
getMetadata().setIndex((byte) 19, Metadata.NBT(value));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package net.minestom.server.entity.metadata.ambient;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.metadata.MobMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AmbientCreatureMeta extends MobMeta {
|
||||
|
||||
protected AmbientCreatureMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package net.minestom.server.entity.metadata.ambient;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class BatMeta extends AmbientCreatureMeta {
|
||||
|
||||
private final static byte MASK_INDEX = 15;
|
||||
|
||||
private final static byte IS_HANGING_BIT = 0x01;
|
||||
|
||||
public BatMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
public boolean isHanging() {
|
||||
return getMaskBit(MASK_INDEX, IS_HANGING_BIT);
|
||||
}
|
||||
|
||||
public void setHanging(boolean value) {
|
||||
setMaskBit(MASK_INDEX, IS_HANGING_BIT, value);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class AbstractHorseMeta extends AnimalMeta {
|
||||
|
||||
private final static byte MASK_INDEX = 16;
|
||||
|
||||
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) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
public boolean isTamed() {
|
||||
return getMaskBit(MASK_INDEX, TAMED_BIT);
|
||||
}
|
||||
|
||||
public void setTamed(boolean value) {
|
||||
setMaskBit(MASK_INDEX, TAMED_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isSaddled() {
|
||||
return getMaskBit(MASK_INDEX, SADDLED_BIT);
|
||||
}
|
||||
|
||||
public void setSaddled(boolean value) {
|
||||
setMaskBit(MASK_INDEX, SADDLED_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isHasBred() {
|
||||
return getMaskBit(MASK_INDEX, HAS_BRED_BIT);
|
||||
}
|
||||
|
||||
public void setHasBred(boolean value) {
|
||||
setMaskBit(MASK_INDEX, HAS_BRED_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isEating() {
|
||||
return getMaskBit(MASK_INDEX, EATING_BIT);
|
||||
}
|
||||
|
||||
public void setEating(boolean value) {
|
||||
setMaskBit(MASK_INDEX, EATING_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isRearing() {
|
||||
return getMaskBit(MASK_INDEX, REARING_BIT);
|
||||
}
|
||||
|
||||
public void setRearing(boolean value) {
|
||||
setMaskBit(MASK_INDEX, REARING_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isMouthOpen() {
|
||||
return getMaskBit(MASK_INDEX, MOUTH_OPEN_BIT);
|
||||
}
|
||||
|
||||
public void setMouthOpen(boolean value) {
|
||||
setMaskBit(MASK_INDEX, MOUTH_OPEN_BIT, value);
|
||||
}
|
||||
|
||||
public UUID getOwner() {
|
||||
return getMetadata().getIndex((byte) 17, null);
|
||||
}
|
||||
|
||||
public void setOwner(UUID value) {
|
||||
getMetadata().setIndex((byte) 17, Metadata.OptUUID(value));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.metadata.AgeableMobMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AnimalMeta extends AgeableMobMeta {
|
||||
|
||||
protected AnimalMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class BeeMeta extends AnimalMeta {
|
||||
|
||||
private final static byte MASK_INDEX = 16;
|
||||
|
||||
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) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
public boolean isAngry() {
|
||||
return getMaskBit(MASK_INDEX, ANGRY_BIT);
|
||||
}
|
||||
|
||||
public void setAngry(boolean value) {
|
||||
setMaskBit(MASK_INDEX, ANGRY_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isHasStung() {
|
||||
return getMaskBit(MASK_INDEX, HAS_STUNG_BIT);
|
||||
}
|
||||
|
||||
public void setHasStung(boolean value) {
|
||||
setMaskBit(MASK_INDEX, HAS_STUNG_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isHasNectar() {
|
||||
return getMaskBit(MASK_INDEX, HAS_NECTAR_BIT);
|
||||
}
|
||||
|
||||
public void setHasNectar(boolean value) {
|
||||
setMaskBit(MASK_INDEX, HAS_NECTAR_BIT, value);
|
||||
}
|
||||
|
||||
public int getAngerTicks() {
|
||||
return getMetadata().getIndex((byte) 17, 0);
|
||||
}
|
||||
|
||||
public void setAngerTicks(int value) {
|
||||
getMetadata().setIndex((byte) 17, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ChestedHorseMeta extends AbstractHorseMeta {
|
||||
|
||||
protected ChestedHorseMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
public boolean isHasChest() {
|
||||
return getMetadata().getIndex((byte) 18, false);
|
||||
}
|
||||
|
||||
public void setHasChest(boolean value) {
|
||||
getMetadata().setIndex((byte) 18, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ChickenMeta extends AnimalMeta {
|
||||
|
||||
public ChickenMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CowMeta extends AnimalMeta {
|
||||
|
||||
public CowMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class DonkeyMeta extends ChestedHorseMeta {
|
||||
|
||||
public DonkeyMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,116 @@
|
||||
package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.UUID;
|
||||
|
||||
public class FoxMeta extends AnimalMeta {
|
||||
|
||||
private final static byte MASK_INDEX = 17;
|
||||
|
||||
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) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Type getType() {
|
||||
return Type.VALUES[getMetadata().getIndex((byte) 16, 0)];
|
||||
}
|
||||
|
||||
public void setType(@NotNull Type type) {
|
||||
getMetadata().setIndex((byte) 16, Metadata.VarInt(type.ordinal()));
|
||||
}
|
||||
|
||||
public boolean isSitting() {
|
||||
return getMaskBit(MASK_INDEX, SITTING_BIT);
|
||||
}
|
||||
|
||||
public void setSitting(boolean value) {
|
||||
setMaskBit(MASK_INDEX, SITTING_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isCrounching() {
|
||||
return getMaskBit(MASK_INDEX, CROUCHING_BIT);
|
||||
}
|
||||
|
||||
public void setCrounching(boolean value) {
|
||||
setMaskBit(MASK_INDEX, CROUCHING_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isInterested() {
|
||||
return getMaskBit(MASK_INDEX, INTERESTED_BIT);
|
||||
}
|
||||
|
||||
public void setInterested(boolean value) {
|
||||
setMaskBit(MASK_INDEX, INTERESTED_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isPouncing() {
|
||||
return getMaskBit(MASK_INDEX, POUNCING_BIT);
|
||||
}
|
||||
|
||||
public void setPouncing(boolean value) {
|
||||
setMaskBit(MASK_INDEX, POUNCING_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isSleeping() {
|
||||
return getMaskBit(MASK_INDEX, SLEEPING_BIT);
|
||||
}
|
||||
|
||||
public void setSleeping(boolean value) {
|
||||
setMaskBit(MASK_INDEX, SLEEPING_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isFaceplanted() {
|
||||
return getMaskBit(MASK_INDEX, FACEPLANTED_BIT);
|
||||
}
|
||||
|
||||
public void setFaceplanted(boolean value) {
|
||||
setMaskBit(MASK_INDEX, FACEPLANTED_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isDefending() {
|
||||
return getMaskBit(MASK_INDEX, DEFENDING_BIT);
|
||||
}
|
||||
|
||||
public void setDefending(boolean value) {
|
||||
setMaskBit(MASK_INDEX, DEFENDING_BIT, value);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public UUID getFirstUUID() {
|
||||
return getMetadata().getIndex((byte) 18, null);
|
||||
}
|
||||
|
||||
public void setFirstUUID(@Nullable UUID value) {
|
||||
getMetadata().setIndex((byte) 18, Metadata.OptUUID(value));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public UUID getSecondUUID() {
|
||||
return getMetadata().getIndex((byte) 19, null);
|
||||
}
|
||||
|
||||
public void setSecondUUID(@Nullable UUID value) {
|
||||
getMetadata().setIndex((byte) 19, Metadata.OptUUID(value));
|
||||
}
|
||||
|
||||
public enum Type {
|
||||
RED,
|
||||
SNOW;
|
||||
|
||||
private final static Type[] VALUES = values();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class HoglinMeta extends AnimalMeta {
|
||||
|
||||
public HoglinMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
public boolean isImmuneToZombification() {
|
||||
return getMetadata().getIndex((byte) 16, false);
|
||||
}
|
||||
|
||||
public void setImmuneToZombification(boolean value) {
|
||||
getMetadata().setIndex((byte) 16, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class HorseMeta extends AbstractHorseMeta {
|
||||
|
||||
public HorseMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
public Variant getVariant() {
|
||||
return getVariantFromID(getMetadata().getIndex((byte) 18, 0));
|
||||
}
|
||||
|
||||
public void setVariant(Variant variant) {
|
||||
getMetadata().setIndex((byte) 18, Metadata.VarInt(getVariantID(variant.marking, variant.color)));
|
||||
}
|
||||
|
||||
public static int getVariantID(@NotNull Marking marking, @NotNull Color color) {
|
||||
return (marking.ordinal() << 8) + color.ordinal();
|
||||
}
|
||||
|
||||
public static Variant getVariantFromID(int variantID) {
|
||||
return new Variant(
|
||||
Marking.VALUES[variantID >> 8],
|
||||
Color.VALUES[variantID & 0xFF]
|
||||
);
|
||||
}
|
||||
|
||||
public static class Variant {
|
||||
|
||||
private Marking marking;
|
||||
private Color color;
|
||||
|
||||
public Variant(@NotNull Marking marking, @NotNull Color color) {
|
||||
this.marking = marking;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Marking getMarking() {
|
||||
return this.marking;
|
||||
}
|
||||
|
||||
public void setMarking(@NotNull Marking marking) {
|
||||
this.marking = marking;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Color getColor() {
|
||||
return this.color;
|
||||
}
|
||||
|
||||
public void setColor(@NotNull Color color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public enum Marking {
|
||||
NONE,
|
||||
WHITE,
|
||||
WHITE_FIELD,
|
||||
WHITE_DOTS,
|
||||
BLACK_DOTS;
|
||||
|
||||
private final static Marking[] VALUES = values();
|
||||
}
|
||||
|
||||
public enum Color {
|
||||
WHITE,
|
||||
CREAMY,
|
||||
CHESTNUT,
|
||||
BROWN,
|
||||
BLACK,
|
||||
GRAY,
|
||||
DARK_BROWN;
|
||||
|
||||
private final static Color[] VALUES = values();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.type.animal.EntityLlama;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class LlamaMeta extends ChestedHorseMeta {
|
||||
|
||||
public LlamaMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
public int getStrength() {
|
||||
return getMetadata().getIndex((byte) 19, 0);
|
||||
}
|
||||
|
||||
public void setStrength(int value) {
|
||||
getMetadata().setIndex((byte) 19, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
public int getCarpetColor() {
|
||||
return getMetadata().getIndex((byte) 20, -1);
|
||||
}
|
||||
|
||||
public void setCarpetColor(int value) {
|
||||
getMetadata().setIndex((byte) 20, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
public Variant getVariant() {
|
||||
return Variant.VALUES[getMetadata().getIndex((byte) 21, 0)];
|
||||
}
|
||||
|
||||
public void setVariant(EntityLlama.Variant value) {
|
||||
getMetadata().setIndex((byte) 21, Metadata.VarInt(value.ordinal()));
|
||||
}
|
||||
|
||||
public enum Variant {
|
||||
CREAMY,
|
||||
WHITE,
|
||||
BROWN,
|
||||
GRAY;
|
||||
|
||||
private final static Variant[] VALUES = values();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class MooshroomMeta extends CowMeta {
|
||||
|
||||
public MooshroomMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Variant getVariant() {
|
||||
return Variant.valueOf(getMetadata().getIndex((byte) 16, "red").toUpperCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
public void setVariant(@NotNull Variant value) {
|
||||
getMetadata().setIndex((byte) 16, Metadata.String(value.name().toLowerCase(Locale.ROOT)));
|
||||
}
|
||||
|
||||
public enum Variant {
|
||||
RED,
|
||||
BROWN;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MuleMeta extends ChestedHorseMeta {
|
||||
|
||||
public MuleMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class OcelotMeta extends AnimalMeta {
|
||||
|
||||
public OcelotMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
public boolean isTrusting() {
|
||||
return getMetadata().getIndex((byte) 16, false);
|
||||
}
|
||||
|
||||
public void setTrusting(boolean value) {
|
||||
getMetadata().setIndex((byte) 16, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,106 @@
|
||||
package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PandaMeta extends AnimalMeta {
|
||||
|
||||
private final static byte MASK_INDEX = 21;
|
||||
|
||||
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) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
public int getBreedTimer() {
|
||||
return getMetadata().getIndex((byte) 16, 0);
|
||||
}
|
||||
|
||||
public void setBreedTimer(int value) {
|
||||
getMetadata().setIndex((byte) 16, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
public int getSneezeTimer() {
|
||||
return getMetadata().getIndex((byte) 17, 0);
|
||||
}
|
||||
|
||||
public void setSneezeTimer(int value) {
|
||||
getMetadata().setIndex((byte) 17, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
public int getEatTimer() {
|
||||
return getMetadata().getIndex((byte) 18, 0);
|
||||
}
|
||||
|
||||
public void setEatTimer(int value) {
|
||||
getMetadata().setIndex((byte) 18, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Gene getMainGene() {
|
||||
return Gene.VALUES[getMetadata().getIndex((byte) 19, (byte) 0)];
|
||||
}
|
||||
|
||||
public void setMainGene(@NotNull Gene value) {
|
||||
getMetadata().setIndex((byte) 19, Metadata.Byte((byte) value.ordinal()));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Gene getHiddenGene() {
|
||||
return Gene.VALUES[getMetadata().getIndex((byte) 20, (byte) 0)];
|
||||
}
|
||||
|
||||
public void setHiddenGene(@NotNull Gene value) {
|
||||
getMetadata().setIndex((byte) 20, Metadata.Byte((byte) value.ordinal()));
|
||||
}
|
||||
|
||||
public boolean isSneezing() {
|
||||
return getMaskBit(MASK_INDEX, SNEEZING_BIT);
|
||||
}
|
||||
|
||||
public void setSneezing(boolean value) {
|
||||
setMaskBit(MASK_INDEX, SNEEZING_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isRolling() {
|
||||
return getMaskBit(MASK_INDEX, ROLLING_BIT);
|
||||
}
|
||||
|
||||
public void setRolling(boolean value) {
|
||||
setMaskBit(MASK_INDEX, ROLLING_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isSitting() {
|
||||
return getMaskBit(MASK_INDEX, SITTING_BIT);
|
||||
}
|
||||
|
||||
public void setSitting(boolean value) {
|
||||
setMaskBit(MASK_INDEX, SITTING_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isOnBack() {
|
||||
return getMaskBit(MASK_INDEX, ON_BACK_BIT);
|
||||
}
|
||||
|
||||
public void setOnBack(boolean value) {
|
||||
setMaskBit(MASK_INDEX, ON_BACK_BIT, value);
|
||||
}
|
||||
|
||||
public enum Gene {
|
||||
NORMAL,
|
||||
AGGRESSIVE,
|
||||
LAZY,
|
||||
WORRIED,
|
||||
PLAYFUL,
|
||||
WEAK,
|
||||
BROWN;
|
||||
|
||||
private final static Gene[] VALUES = values();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PigMeta extends AnimalMeta {
|
||||
|
||||
public PigMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
public boolean isHasSaddle() {
|
||||
return getMetadata().getIndex((byte) 16, false);
|
||||
}
|
||||
|
||||
public void setHasSaddle(boolean value) {
|
||||
getMetadata().setIndex((byte) 16, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
public int getTimeToBoost() {
|
||||
return getMetadata().getIndex((byte) 17, 0);
|
||||
}
|
||||
|
||||
public void setTimeToBoost(int value) {
|
||||
getMetadata().getIndex((byte) 17, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PolarBearMeta extends AnimalMeta {
|
||||
|
||||
public PolarBearMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
public boolean isStandingUp() {
|
||||
return getMetadata().getIndex((byte) 16, false);
|
||||
}
|
||||
|
||||
public void setStandingUp(boolean value) {
|
||||
getMetadata().setIndex((byte) 16, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class RabbitMeta extends AnimalMeta {
|
||||
|
||||
public RabbitMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Type getType() {
|
||||
int id = getMetadata().getIndex((byte) 16, 0);
|
||||
if (id == 99) {
|
||||
return Type.KILLER_BUNNY;
|
||||
}
|
||||
return Type.VALUES[id];
|
||||
}
|
||||
|
||||
public void setType(@NotNull Type value) {
|
||||
int id = value == Type.KILLER_BUNNY ? 99 : value.ordinal();
|
||||
getMetadata().setIndex((byte) 16, Metadata.VarInt(id));
|
||||
}
|
||||
|
||||
public enum Type {
|
||||
BROWN,
|
||||
WHITE,
|
||||
BLACK,
|
||||
BLACK_AND_WHITE,
|
||||
GOLD,
|
||||
SALT_AND_PEPPER,
|
||||
KILLER_BUNNY;
|
||||
|
||||
private final static Type[] VALUES = values();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SheepMeta extends AnimalMeta {
|
||||
|
||||
private final static byte MASK_INDEX = 16;
|
||||
|
||||
private final static byte COLOR_BITS = 0x0F;
|
||||
private final static byte SHEARED_BIT = 0x10;
|
||||
|
||||
public SheepMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return getMask(MASK_INDEX) & COLOR_BITS;
|
||||
}
|
||||
|
||||
public void setColor(byte color) {
|
||||
byte before = getMask(MASK_INDEX);
|
||||
byte mask = before;
|
||||
mask &= ~COLOR_BITS;
|
||||
mask |= (color & COLOR_BITS);
|
||||
if (mask != before) {
|
||||
setMask(MASK_INDEX, mask);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isSheared() {
|
||||
return getMaskBit(MASK_INDEX, SHEARED_BIT);
|
||||
}
|
||||
|
||||
public void setSheared(boolean value) {
|
||||
setMaskBit(MASK_INDEX, SHEARED_BIT, value);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SkeletonHorseMeta extends AbstractHorseMeta {
|
||||
|
||||
public SkeletonHorseMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class StriderMeta extends AnimalMeta {
|
||||
|
||||
public StriderMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
public int getTimeToBoost() {
|
||||
return getMetadata().getIndex((byte) 16, 0);
|
||||
}
|
||||
|
||||
public void setTimeToBoost(int value) {
|
||||
getMetadata().setIndex((byte) 16, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
public boolean isShaking() {
|
||||
return getMetadata().getIndex((byte) 17, false);
|
||||
}
|
||||
|
||||
public void setShaking(boolean value) {
|
||||
getMetadata().setIndex((byte) 17, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
public boolean isHasSaddle() {
|
||||
return getMetadata().getIndex((byte) 18, false);
|
||||
}
|
||||
|
||||
public void setHasSaddle(boolean value) {
|
||||
getMetadata().setIndex((byte) 18, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.utils.BlockPosition;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class TurtleMeta extends AnimalMeta {
|
||||
|
||||
public TurtleMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public BlockPosition getHomePosition() {
|
||||
return getMetadata().getIndex((byte) 16, new BlockPosition(0, 0, 0));
|
||||
}
|
||||
|
||||
public void setBlockPosition(@NotNull BlockPosition value) {
|
||||
getMetadata().setIndex((byte) 16, Metadata.Position(value));
|
||||
}
|
||||
|
||||
public boolean isHasEgg() {
|
||||
return getMetadata().getIndex((byte) 17, false);
|
||||
}
|
||||
|
||||
public void setHasEgg(boolean value) {
|
||||
getMetadata().setIndex((byte) 17, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
public boolean isLayingEgg() {
|
||||
return getMetadata().getIndex((byte) 18, false);
|
||||
}
|
||||
|
||||
public void setLayingEgg(boolean value) {
|
||||
getMetadata().setIndex((byte) 18, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public BlockPosition getTravelPosition() {
|
||||
return getMetadata().getIndex((byte) 19, new BlockPosition(0, 0, 0));
|
||||
}
|
||||
|
||||
public void setTravelPosition(@NotNull BlockPosition value) {
|
||||
getMetadata().setIndex((byte) 19, Metadata.Position(value));
|
||||
}
|
||||
|
||||
public boolean isGoingHome() {
|
||||
return getMetadata().getIndex((byte) 20, false);
|
||||
}
|
||||
|
||||
public void setGoingHome(boolean value) {
|
||||
getMetadata().setIndex((byte) 20, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
public boolean isTravelling() {
|
||||
return getMetadata().getIndex((byte) 21, false);
|
||||
}
|
||||
|
||||
public void setTravelling(boolean value) {
|
||||
getMetadata().setIndex((byte) 21, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ZombieHorseMeta extends AbstractHorseMeta {
|
||||
|
||||
public ZombieHorseMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package net.minestom.server.entity.metadata.animal.tameable;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CatMeta extends TameableAnimalMeta {
|
||||
|
||||
public CatMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Color getColor() {
|
||||
return Color.VALUES[getMetadata().getIndex((byte) 18, 1)];
|
||||
}
|
||||
|
||||
public void setColor(@NotNull Color value) {
|
||||
getMetadata().setIndex((byte) 18, Metadata.VarInt(value.ordinal()));
|
||||
}
|
||||
|
||||
public boolean isLying() {
|
||||
return getMetadata().getIndex((byte) 19, false);
|
||||
}
|
||||
|
||||
public void setLying(boolean value) {
|
||||
getMetadata().setIndex((byte) 19, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
public boolean isRelaxed() {
|
||||
return getMetadata().getIndex((byte) 20, false);
|
||||
}
|
||||
|
||||
public void setRelaxed(boolean value) {
|
||||
getMetadata().setIndex((byte) 20, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
public int getCollarColor() {
|
||||
return getMetadata().getIndex((byte) 21, 14);
|
||||
}
|
||||
|
||||
public void setCollarColor(int value) {
|
||||
getMetadata().setIndex((byte) 21, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
public enum Color {
|
||||
TABBY,
|
||||
BLACK,
|
||||
RED,
|
||||
SIAMESE,
|
||||
BRITISH_SHORTHAIR,
|
||||
CALICO,
|
||||
PERSIAN,
|
||||
RAGDOLL,
|
||||
WHITE,
|
||||
JELLIE,
|
||||
ALL_BLACK;
|
||||
|
||||
private final static Color[] VALUES = values();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package net.minestom.server.entity.metadata.animal.tameable;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ParrotMeta extends TameableAnimalMeta {
|
||||
|
||||
public ParrotMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Color getColor() {
|
||||
return Color.VALUES[getMetadata().getIndex((byte) 18, 0)];
|
||||
}
|
||||
|
||||
public void setColor(@NotNull Color value) {
|
||||
getMetadata().setIndex((byte) 18, Metadata.VarInt(value.ordinal()));
|
||||
}
|
||||
|
||||
public enum Color {
|
||||
RED_BLUE,
|
||||
BLUE,
|
||||
GREEN,
|
||||
YELLOW_BLUE,
|
||||
GREY;
|
||||
|
||||
private final static Color[] VALUES = values();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
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.metadata.animal.AnimalMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class TameableAnimalMeta extends AnimalMeta {
|
||||
|
||||
private final static byte MASK_INDEX = 16;
|
||||
|
||||
private final static byte SITTING_BIT = 0x01;
|
||||
private final static byte TAMED_BIT = 0x04;
|
||||
|
||||
protected TameableAnimalMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
public boolean isSitting() {
|
||||
return getMaskBit(MASK_INDEX, SITTING_BIT);
|
||||
}
|
||||
|
||||
public void setSitting(boolean value) {
|
||||
setMaskBit(MASK_INDEX, SITTING_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isTamed() {
|
||||
return getMaskBit(MASK_INDEX, TAMED_BIT);
|
||||
}
|
||||
|
||||
public void setTamed(boolean value) {
|
||||
setMaskBit(MASK_INDEX, TAMED_BIT, value);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public UUID getOwner() {
|
||||
return getMetadata().getIndex((byte) 17, null);
|
||||
}
|
||||
|
||||
public void setOwner(@NotNull UUID value) {
|
||||
getMetadata().setIndex((byte) 17, Metadata.OptUUID(value));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package net.minestom.server.entity.metadata.animal.tameable;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class WolfMeta extends TameableAnimalMeta {
|
||||
|
||||
public WolfMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
public boolean isBegging() {
|
||||
return getMetadata().getIndex((byte) 18, false);
|
||||
}
|
||||
|
||||
public void setBegging(boolean value) {
|
||||
getMetadata().setIndex((byte) 18, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
public int getCollarColor() {
|
||||
return getMetadata().getIndex((byte) 19, 14);
|
||||
}
|
||||
|
||||
public void setCollarColor(int value) {
|
||||
getMetadata().setIndex((byte) 19, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
public int getAngerTime() {
|
||||
return getMetadata().getIndex((byte) 20, 0);
|
||||
}
|
||||
|
||||
public void setAngerTime(int value) {
|
||||
getMetadata().setIndex((byte) 20, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package net.minestom.server.entity.metadata.arrow;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.metadata.EntityMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AbstractArrowMeta extends EntityMeta {
|
||||
|
||||
private final static byte MASK_INDEX = 7;
|
||||
|
||||
private final static byte CRITICAL_BIT = 0x01;
|
||||
private final static byte NO_CLIP_BIT = 0x01;
|
||||
|
||||
protected AbstractArrowMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
public boolean isCritical() {
|
||||
return getMaskBit(MASK_INDEX, CRITICAL_BIT);
|
||||
}
|
||||
|
||||
public void setCritical(boolean value) {
|
||||
setMaskBit(MASK_INDEX, CRITICAL_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isNoClip() {
|
||||
return getMaskBit(MASK_INDEX, NO_CLIP_BIT);
|
||||
}
|
||||
|
||||
public void setNoClip(boolean value) {
|
||||
setMaskBit(MASK_INDEX, NO_CLIP_BIT, value);
|
||||
}
|
||||
|
||||
public byte getPiercingLevel() {
|
||||
return getMetadata().getIndex((byte) 8, (byte) 0);
|
||||
}
|
||||
|
||||
public void setPiercingLevel(byte value) {
|
||||
getMetadata().setIndex((byte) 8, Metadata.Byte(value));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package net.minestom.server.entity.metadata.arrow;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.metadata.EntityMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ArrowMeta extends EntityMeta {
|
||||
|
||||
public ArrowMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return getMetadata().getIndex((byte) 9, -1);
|
||||
}
|
||||
|
||||
public void setColor(int value) {
|
||||
getMetadata().setIndex((byte) 9, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package net.minestom.server.entity.metadata.arrow;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SpectralArrowMeta extends AbstractArrowMeta {
|
||||
|
||||
public SpectralArrowMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package net.minestom.server.entity.metadata.arrow;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ThrownTridentMeta extends AbstractArrowMeta {
|
||||
|
||||
public ThrownTridentMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
public int getLoyaltyLevel() {
|
||||
return getMetadata().getIndex((byte) 9, 0);
|
||||
}
|
||||
|
||||
public void setLoyaltyLevel(int value) {
|
||||
getMetadata().setIndex((byte) 9, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
public boolean isHasEnchantmentGlint() {
|
||||
return getMetadata().getIndex((byte) 10, false);
|
||||
}
|
||||
|
||||
public void setHasEnchantmentGlint(boolean value) {
|
||||
getMetadata().setIndex((byte) 10, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package net.minestom.server.entity.metadata.flying;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.metadata.MobMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class FlyingMeta extends MobMeta {
|
||||
|
||||
protected FlyingMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package net.minestom.server.entity.metadata.flying;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class GhastMeta extends FlyingMeta {
|
||||
|
||||
public GhastMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
public boolean isAttacking() {
|
||||
return getMetadata().getIndex((byte) 15, false);
|
||||
}
|
||||
|
||||
public void setAttacking(boolean value) {
|
||||
getMetadata().setIndex((byte) 15, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package net.minestom.server.entity.metadata.flying;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PhantomMeta extends FlyingMeta {
|
||||
|
||||
public PhantomMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return getMetadata().getIndex((byte) 15, 0);
|
||||
}
|
||||
|
||||
public void setSize(int value) {
|
||||
getMetadata().setIndex((byte) 15, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package net.minestom.server.entity.metadata.golem;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.metadata.PathfinderMobMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AbstractGolemMeta extends PathfinderMobMeta {
|
||||
|
||||
protected AbstractGolemMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package net.minestom.server.entity.metadata.golem;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class IronGolemMeta extends AbstractGolemMeta {
|
||||
|
||||
private final static byte MASK_INDEX = 15;
|
||||
|
||||
private final static byte PLAYER_CREATED_BIT = 0x01;
|
||||
|
||||
public IronGolemMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
public boolean isPlayerCreated() {
|
||||
return getMaskBit(MASK_INDEX, PLAYER_CREATED_BIT);
|
||||
}
|
||||
|
||||
public void setPlayerCreated(boolean value) {
|
||||
setMaskBit(MASK_INDEX, PLAYER_CREATED_BIT, value);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package net.minestom.server.entity.metadata.golem;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.utils.BlockPosition;
|
||||
import net.minestom.server.utils.Direction;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ShulkerMeta extends AbstractGolemMeta {
|
||||
|
||||
public ShulkerMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
public Direction getAttachFace() {
|
||||
return getMetadata().getIndex((byte) 15, Direction.DOWN);
|
||||
}
|
||||
|
||||
public void setAttachFace(Direction value) {
|
||||
getMetadata().setIndex((byte) 15, Metadata.Direction(value));
|
||||
}
|
||||
|
||||
public BlockPosition getAttachmentPosition() {
|
||||
return getMetadata().getIndex((byte) 16, null);
|
||||
}
|
||||
|
||||
public void setAttachmentPosition(BlockPosition value) {
|
||||
getMetadata().setIndex((byte) 16, Metadata.OptPosition(value));
|
||||
}
|
||||
|
||||
public byte getShieldHeight() {
|
||||
return getMetadata().getIndex((byte) 17, (byte) 0);
|
||||
}
|
||||
|
||||
public void setShieldHeight(byte value) {
|
||||
getMetadata().setIndex((byte) 17, Metadata.Byte(value));
|
||||
}
|
||||
|
||||
public byte getColor() {
|
||||
return getMetadata().getIndex((byte) 18, (byte) 10);
|
||||
}
|
||||
|
||||
public void setColor(byte value) {
|
||||
getMetadata().setIndex((byte) 18, Metadata.Byte(value));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package net.minestom.server.entity.metadata.golem;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SnowGolemMeta extends AbstractGolemMeta {
|
||||
|
||||
public SnowGolemMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
public boolean isHasPumpkinHat() {
|
||||
return getMetadata().getIndex((byte) 15, (byte) 0x10) == (byte) 0x10;
|
||||
}
|
||||
|
||||
public void setHasPumpkinHat(boolean value) {
|
||||
getMetadata().setIndex((byte) 15, Metadata.Byte(value ? (byte) 0x10 : (byte) 0x00));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package net.minestom.server.entity.metadata.minecart;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AbstractMinecartContainerMeta extends AbstractMinecartMeta {
|
||||
|
||||
protected AbstractMinecartContainerMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package net.minestom.server.entity.metadata.minecart;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.metadata.EntityMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AbstractMinecartMeta extends EntityMeta {
|
||||
|
||||
protected AbstractMinecartMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
public int getShakingPower() {
|
||||
return getMetadata().getIndex((byte) 7, 0);
|
||||
}
|
||||
|
||||
public void setShakingPower(int value) {
|
||||
getMetadata().setIndex((byte) 7, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
public int getShakingDirection() {
|
||||
return getMetadata().getIndex((byte) 8, 1);
|
||||
}
|
||||
|
||||
public void setShakingDirection(int value) {
|
||||
getMetadata().setIndex((byte) 8, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
public float getShakingMultiplier() {
|
||||
return getMetadata().getIndex((byte) 9, 0F);
|
||||
}
|
||||
|
||||
public void setShakingMultiplier(float value) {
|
||||
getMetadata().setIndex((byte) 9, Metadata.Float(value));
|
||||
}
|
||||
|
||||
public int getCustomBlockIdAndDamage() {
|
||||
return getMetadata().getIndex((byte) 10, 0);
|
||||
}
|
||||
|
||||
public void setCustomBlockIdAndDamage(int value) {
|
||||
getMetadata().setIndex((byte) 10, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
// in 16th of a block
|
||||
public int getCustomBlockYPosition() {
|
||||
return getMetadata().getIndex((byte) 11, 6);
|
||||
}
|
||||
|
||||
public void setCustomBlockYPosition(int value) {
|
||||
getMetadata().setIndex((byte) 11, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package net.minestom.server.entity.metadata.minecart;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MinecartChestMeta extends AbstractMinecartContainerMeta {
|
||||
|
||||
public MinecartChestMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package net.minestom.server.entity.metadata.minecart;
|
||||
|
||||
import net.minestom.server.chat.ColoredText;
|
||||
import net.minestom.server.chat.JsonMessage;
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MinecartCommandBlockMeta extends AbstractMinecartMeta {
|
||||
|
||||
public MinecartCommandBlockMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getCommand() {
|
||||
return getMetadata().getIndex((byte) 13, "");
|
||||
}
|
||||
|
||||
public void setCommand(@NotNull String value) {
|
||||
getMetadata().setIndex((byte) 13, Metadata.String(value));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JsonMessage getLastOutput() {
|
||||
return getMetadata().getIndex((byte) 14, ColoredText.of(""));
|
||||
}
|
||||
|
||||
public void setLastOutput(@NotNull JsonMessage value) {
|
||||
getMetadata().setIndex((byte) 14, Metadata.Chat(value));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package net.minestom.server.entity.metadata.minecart;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MinecartFurnaceMeta extends AbstractMinecartMeta {
|
||||
|
||||
public MinecartFurnaceMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
public boolean isHasFuel() {
|
||||
return getMetadata().getIndex((byte) 13, false);
|
||||
}
|
||||
|
||||
public void setHasFuel(boolean value) {
|
||||
getMetadata().setIndex((byte) 13, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package net.minestom.server.entity.metadata.minecart;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MinecartHopperMeta extends AbstractMinecartContainerMeta {
|
||||
|
||||
public MinecartHopperMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package net.minestom.server.entity.metadata.minecart;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MinecartMeta extends AbstractMinecartMeta {
|
||||
|
||||
public MinecartMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package net.minestom.server.entity.metadata.minecart;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MinecartTntMeta extends AbstractMinecartMeta {
|
||||
|
||||
public MinecartTntMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package net.minestom.server.entity.metadata.monster;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class BasePiglinMeta extends MonsterMeta {
|
||||
|
||||
protected BasePiglinMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
public boolean isImmuneToZombification() {
|
||||
return getMetadata().getIndex((byte) 15, false);
|
||||
}
|
||||
|
||||
public void setImmuneToZombification(boolean value) {
|
||||
getMetadata().setIndex((byte) 15, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package net.minestom.server.entity.metadata.monster;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class BlazeMeta extends MonsterMeta {
|
||||
|
||||
private final static byte MASK_INDEX = 15;
|
||||
|
||||
private final static byte ON_FIRE_BIT = 0x01;
|
||||
|
||||
public BlazeMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
public boolean isOnFire() {
|
||||
return getMaskBit(MASK_INDEX, ON_FIRE_BIT);
|
||||
}
|
||||
|
||||
public void setOnFire(boolean value) {
|
||||
setMaskBit(MASK_INDEX, ON_FIRE_BIT, value);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package net.minestom.server.entity.metadata.monster;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CreeperMeta extends MonsterMeta {
|
||||
|
||||
public CreeperMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public State getState() {
|
||||
int id = getMetadata().getIndex((byte) 15, -1);
|
||||
return id == -1 ? State.IDLE : State.FUSE;
|
||||
}
|
||||
|
||||
public void setState(@NotNull State value) {
|
||||
getMetadata().setIndex((byte) 15, Metadata.VarInt(value == State.IDLE ? -1 : 1));
|
||||
}
|
||||
|
||||
public boolean isCharged() {
|
||||
return getMetadata().getIndex((byte) 16, false);
|
||||
}
|
||||
|
||||
public void setCharged(boolean value) {
|
||||
getMetadata().setIndex((byte) 16, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
public boolean isIgnited() {
|
||||
return getMetadata().getIndex((byte) 17, false);
|
||||
}
|
||||
|
||||
public void setIgnited(boolean value) {
|
||||
getMetadata().setIndex((byte) 17, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
public enum State {
|
||||
IDLE,
|
||||
FUSE
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package net.minestom.server.entity.metadata.monster;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ElderGuardianMeta extends GuardianMeta {
|
||||
|
||||
public ElderGuardianMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package net.minestom.server.entity.metadata.monster;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class EndermanMeta extends MonsterMeta {
|
||||
|
||||
public EndermanMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
public Integer getCarriedBlockID() {
|
||||
return getMetadata().getIndex((byte) 15, null);
|
||||
}
|
||||
|
||||
public void setCarriedBlockID(@Nullable Integer value) {
|
||||
getMetadata().setIndex((byte) 15, Metadata.OptBlockID(value));
|
||||
}
|
||||
|
||||
public boolean isScreaming() {
|
||||
return getMetadata().getIndex((byte) 16, false);
|
||||
}
|
||||
|
||||
public void setScreaming(boolean value) {
|
||||
getMetadata().setIndex((byte) 16, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
public boolean isStaring() {
|
||||
return getMetadata().getIndex((byte) 17, false);
|
||||
}
|
||||
|
||||
public void setStaring(boolean value) {
|
||||
getMetadata().setIndex((byte) 17, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package net.minestom.server.entity.metadata.monster;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EndermineMeta extends MonsterMeta {
|
||||
|
||||
public EndermineMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package net.minestom.server.entity.metadata.monster;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class GiantMeta extends MonsterMeta {
|
||||
|
||||
public GiantMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package net.minestom.server.entity.metadata.monster;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class GuardianMeta extends MonsterMeta {
|
||||
|
||||
private Entity target;
|
||||
|
||||
public GuardianMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
public boolean isRetractingSpikes() {
|
||||
return getMetadata().getIndex((byte) 15, false);
|
||||
}
|
||||
|
||||
public void setRetractingSpikes(boolean retractingSpikes) {
|
||||
getMetadata().setIndex((byte) 15, Metadata.Boolean(retractingSpikes));
|
||||
}
|
||||
|
||||
public Entity getTarget() {
|
||||
return this.target;
|
||||
}
|
||||
|
||||
public void setTarget(@NotNull Entity target) {
|
||||
this.target = target;
|
||||
getMetadata().setIndex((byte) 16, Metadata.VarInt(target.getEntityId()));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package net.minestom.server.entity.metadata.monster;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.metadata.PathfinderMobMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MonsterMeta extends PathfinderMobMeta {
|
||||
|
||||
protected MonsterMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package net.minestom.server.entity.metadata.monster;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PiglinBruteMeta extends BasePiglinMeta {
|
||||
|
||||
public PiglinBruteMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
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 org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PiglinMeta extends BasePiglinMeta {
|
||||
|
||||
public PiglinMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
public boolean isBaby() {
|
||||
return getMetadata().getIndex((byte) 16, false);
|
||||
}
|
||||
|
||||
public void setBaby(boolean value) {
|
||||
if (isBaby() == value) {
|
||||
return;
|
||||
}
|
||||
BoundingBox bb = this.entity.getBoundingBox();
|
||||
if (value) {
|
||||
setBoundingBox(bb.getWidth() / 2, bb.getHeight() / 2);
|
||||
} else {
|
||||
setBoundingBox(bb.getWidth() * 2, bb.getHeight() * 2);
|
||||
}
|
||||
getMetadata().setIndex((byte) 16, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
public boolean isChargingCrossbow() {
|
||||
return getMetadata().getIndex((byte) 17, false);
|
||||
}
|
||||
|
||||
public void setChargingCrossbow(boolean value) {
|
||||
getMetadata().setIndex((byte) 17, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
public boolean isDancing() {
|
||||
return getMetadata().getIndex((byte) 18, false);
|
||||
}
|
||||
|
||||
public void setDancing(boolean value) {
|
||||
getMetadata().setIndex((byte) 18, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package net.minestom.server.entity.metadata.monster;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SilverfishMeta extends MonsterMeta {
|
||||
|
||||
public SilverfishMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package net.minestom.server.entity.metadata.monster;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SpiderMeta extends MonsterMeta {
|
||||
|
||||
private final static byte MASK_INDEX = 15;
|
||||
|
||||
private final static byte CLIMBING_BIT = 0x01;
|
||||
|
||||
public SpiderMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
public boolean isClimbing() {
|
||||
return getMaskBit(MASK_INDEX, CLIMBING_BIT);
|
||||
}
|
||||
|
||||
public void setClimbing(boolean value) {
|
||||
setMaskBit(MASK_INDEX, CLIMBING_BIT, value);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package net.minestom.server.entity.metadata.monster;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class VexMeta extends MonsterMeta {
|
||||
|
||||
private final static byte MASK_INDEX = 15;
|
||||
|
||||
private final static byte ATTACKING_BIT = 0x01;
|
||||
|
||||
public VexMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
public boolean isAttacking() {
|
||||
return getMaskBit(MASK_INDEX, ATTACKING_BIT);
|
||||
}
|
||||
|
||||
public void setAttacking(boolean value) {
|
||||
setMaskBit(MASK_INDEX, ATTACKING_BIT, value);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package net.minestom.server.entity.metadata.monster;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class WitherMeta extends MonsterMeta {
|
||||
|
||||
private Entity centerHead;
|
||||
private Entity leftHead;
|
||||
private Entity rightHead;
|
||||
|
||||
public WitherMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Entity getCenterHead() {
|
||||
return this.centerHead;
|
||||
}
|
||||
|
||||
public void setCenterHead(@Nullable Entity value) {
|
||||
this.centerHead = value;
|
||||
getMetadata().setIndex((byte) 15, Metadata.VarInt(value == null ? 0 : value.getEntityId()));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Entity getLeftHead() {
|
||||
return this.leftHead;
|
||||
}
|
||||
|
||||
public void setLeftHead(@Nullable Entity value) {
|
||||
this.leftHead = value;
|
||||
getMetadata().setIndex((byte) 16, Metadata.VarInt(value == null ? 0 : value.getEntityId()));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Entity getRightHead() {
|
||||
return this.rightHead;
|
||||
}
|
||||
|
||||
public void setRightHead(@Nullable Entity value) {
|
||||
this.rightHead = value;
|
||||
getMetadata().setIndex((byte) 17, Metadata.VarInt(value == null ? 0 : value.getEntityId()));
|
||||
}
|
||||
|
||||
public int getInvulnerableTime() {
|
||||
return getMetadata().getIndex((byte) 18, 0);
|
||||
}
|
||||
|
||||
public void setInvulnerableTime(int value) {
|
||||
getMetadata().setIndex((byte) 18, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
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 org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ZoglinMeta extends MonsterMeta {
|
||||
|
||||
public ZoglinMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
public boolean isBaby() {
|
||||
return getMetadata().getIndex((byte) 15, false);
|
||||
}
|
||||
|
||||
public void setBaby(boolean value) {
|
||||
if (isBaby() == value) {
|
||||
return;
|
||||
}
|
||||
BoundingBox bb = this.entity.getBoundingBox();
|
||||
if (value) {
|
||||
setBoundingBox(bb.getWidth() / 2, bb.getHeight() / 2);
|
||||
} else {
|
||||
setBoundingBox(bb.getWidth() * 2, bb.getHeight() * 2);
|
||||
}
|
||||
getMetadata().setIndex((byte) 15, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package net.minestom.server.entity.metadata.monster.raider;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AbstractIllagerMeta extends RaiderMeta {
|
||||
|
||||
protected AbstractIllagerMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package net.minestom.server.entity.metadata.monster.raider;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EvokerMeta extends SpellcasterIllagerMeta {
|
||||
|
||||
public EvokerMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package net.minestom.server.entity.metadata.monster.raider;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class IllusionerMeta extends SpellcasterIllagerMeta {
|
||||
|
||||
public IllusionerMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package net.minestom.server.entity.metadata.monster.raider;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PillagerMeta extends AbstractIllagerMeta {
|
||||
|
||||
public PillagerMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +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.metadata.monster.MonsterMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class RaiderMeta extends MonsterMeta {
|
||||
|
||||
protected RaiderMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
public boolean isCelebrating() {
|
||||
return getMetadata().getIndex((byte) 15, false);
|
||||
}
|
||||
|
||||
public void setCelebrating(boolean value) {
|
||||
getMetadata().setIndex((byte) 15, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package net.minestom.server.entity.metadata.monster.raider;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class RavagerMeta extends RaiderMeta {
|
||||
|
||||
public RavagerMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
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.type.monster.EntitySpellcasterIllager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SpellcasterIllagerMeta extends AbstractIllagerMeta {
|
||||
|
||||
protected SpellcasterIllagerMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Spell getSpell() {
|
||||
return Spell.VALUES[getMetadata().getIndex((byte) 16, (byte) 0)];
|
||||
}
|
||||
|
||||
public void setSpell(@NotNull Spell spell) {
|
||||
getMetadata().setIndex((byte) 16, Metadata.Byte((byte) spell.ordinal()));
|
||||
}
|
||||
|
||||
public enum Spell {
|
||||
NONE,
|
||||
SUMMON_VEX,
|
||||
ATTACK,
|
||||
WOLOLO,
|
||||
DISAPPEAR,
|
||||
BLINDNESS;
|
||||
|
||||
private final static Spell[] VALUES = values();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package net.minestom.server.entity.metadata.monster.raider;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class VindicatorMeta extends AbstractIllagerMeta {
|
||||
|
||||
public VindicatorMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package net.minestom.server.entity.metadata.monster.raider;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class WitchMeta extends RaiderMeta {
|
||||
|
||||
public WitchMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
public boolean isDrinkingPotion() {
|
||||
return getMetadata().getIndex((byte) 16, false);
|
||||
}
|
||||
|
||||
public void setDrinkingPotion(boolean value) {
|
||||
getMetadata().setIndex((byte) 16, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package net.minestom.server.entity.metadata.monster.skeleton;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.metadata.monster.MonsterMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AbstractSkeletonMeta extends MonsterMeta {
|
||||
|
||||
protected AbstractSkeletonMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package net.minestom.server.entity.metadata.monster.skeleton;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SkeletonMeta extends AbstractSkeletonMeta {
|
||||
|
||||
public SkeletonMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package net.minestom.server.entity.metadata.monster.skeleton;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class StrayMeta extends AbstractSkeletonMeta {
|
||||
|
||||
public StrayMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package net.minestom.server.entity.metadata.monster.skeleton;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class WitherSkeletonMeta extends AbstractSkeletonMeta {
|
||||
|
||||
public WitherSkeletonMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package net.minestom.server.entity.metadata.monster.zombie;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class DrownedMeta extends ZombieMeta {
|
||||
|
||||
public DrownedMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package net.minestom.server.entity.metadata.monster.zombie;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class HuskMeta extends ZombieMeta {
|
||||
|
||||
public HuskMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package net.minestom.server.entity.metadata.monster.zombie;
|
||||
|
||||
import net.minestom.server.collision.BoundingBox;
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.metadata.monster.MonsterMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ZombieMeta extends MonsterMeta {
|
||||
|
||||
public ZombieMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
public boolean isBaby() {
|
||||
return getMetadata().getIndex((byte) 15, false);
|
||||
}
|
||||
|
||||
public void setBaby(boolean value) {
|
||||
if (isBaby() == value) {
|
||||
return;
|
||||
}
|
||||
BoundingBox bb = this.entity.getBoundingBox();
|
||||
if (value) {
|
||||
setBoundingBox(bb.getWidth() / 2, bb.getHeight() / 2);
|
||||
} else {
|
||||
setBoundingBox(bb.getWidth() * 2, bb.getHeight() * 2);
|
||||
}
|
||||
getMetadata().setIndex((byte) 15, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
public boolean isBecomingDrowned() {
|
||||
return getMetadata().getIndex((byte) 17, false);
|
||||
}
|
||||
|
||||
public void setBecomingDrowned(boolean value) {
|
||||
getMetadata().setIndex((byte) 17, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package net.minestom.server.entity.metadata.monster.zombie;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.metadata.villager.VillagerMeta;
|
||||
import net.minestom.server.entity.type.ambient.EntityVillager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ZombieVillagerMeta extends ZombieMeta {
|
||||
|
||||
public ZombieVillagerMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
public boolean isConverting() {
|
||||
return getMetadata().getIndex((byte) 18, false);
|
||||
}
|
||||
|
||||
public void setConverting(boolean value) {
|
||||
getMetadata().setIndex((byte) 18, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
public VillagerMeta.VillagerData getVillagerData() {
|
||||
int[] data = getMetadata().getIndex((byte) 17, null);
|
||||
if (data == null) {
|
||||
return new VillagerMeta.VillagerData(VillagerMeta.Type.PLAINS, VillagerMeta.Profession.NONE, VillagerMeta.Level.NOVICE);
|
||||
}
|
||||
return new VillagerMeta.VillagerData(VillagerMeta.Type.VALUES[data[0]], VillagerMeta.Profession.VALUES[data[1]], VillagerMeta.Level.VALUES[data[2] - 1]);
|
||||
}
|
||||
|
||||
public void setVillagerData(EntityVillager.VillagerData data) {
|
||||
getMetadata().setIndex((byte) 17, Metadata.VillagerData(
|
||||
data.getType().ordinal(),
|
||||
data.getProfession().ordinal(),
|
||||
data.getLevel().ordinal() + 1
|
||||
));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package net.minestom.server.entity.metadata.monster.zombie;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ZombifiedPiglinMeta extends ZombieMeta {
|
||||
|
||||
public ZombifiedPiglinMeta(@NotNull Entity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package net.minestom.server.entity.metadata.object;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.item.Material;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EyeOfEnderMeta extends ObjectEntityMeta {
|
||||
|
||||
public EyeOfEnderMeta(@NotNull Entity entity) {
|
||||
super(entity, Material.ENDER_EYE);
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user