mirror of
https://github.com/Minestom/Minestom.git
synced 2025-03-02 11:21:15 +01:00
update existing metadata to 1.17, using new system
This commit is contained in:
parent
1065ad346e
commit
1850efb3fc
@ -238,20 +238,20 @@ public class Metadata {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getIndex(byte index, @Nullable T defaultValue) {
|
||||
Entry<?> value = this.metadataMap.get(index);
|
||||
public <T> T getIndex(int index, @Nullable T defaultValue) {
|
||||
Entry<?> value = this.metadataMap.get((byte) index);
|
||||
return value != null ? (T) value.getMetaValue().value : defaultValue;
|
||||
}
|
||||
|
||||
public void setIndex(byte index, @NotNull Value<?> value) {
|
||||
final Entry<?> entry = new Entry<>(index, value);
|
||||
this.metadataMap.put(index, entry);
|
||||
public void setIndex(int index, @NotNull Value<?> value) {
|
||||
final Entry<?> entry = new Entry<>((byte) index, value);
|
||||
this.metadataMap.put((byte) index, entry);
|
||||
|
||||
// Send metadata packet to update viewers and self
|
||||
if (this.entity != null && this.entity.isActive()) {
|
||||
if (!this.notifyAboutChanges) {
|
||||
synchronized (this.notNotifiedChanges) {
|
||||
this.notNotifiedChanges.put(index, entry);
|
||||
this.notNotifiedChanges.put((byte) index, entry);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -6,13 +6,15 @@ import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AgeableMobMeta extends PathfinderMobMeta {
|
||||
public static final byte OFFSET = PathfinderMobMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
protected AgeableMobMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean isBaby() {
|
||||
return super.metadata.getIndex((byte) 15, false);
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
}
|
||||
|
||||
public void setBaby(boolean value) {
|
||||
@ -25,7 +27,7 @@ public class AgeableMobMeta extends PathfinderMobMeta {
|
||||
} else {
|
||||
setBoundingBox(bb.getWidth() * 2, bb.getHeight() * 2);
|
||||
}
|
||||
super.metadata.setIndex((byte) 15, Metadata.Boolean(value));
|
||||
super.metadata.setIndex(OFFSET, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,8 +7,8 @@ import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EntityMeta {
|
||||
|
||||
private final static byte MASK_INDEX = 0;
|
||||
public static final byte OFFSET = 0;
|
||||
public static final byte MAX_OFFSET = OFFSET + 8;
|
||||
|
||||
private final static byte ON_FIRE_BIT = 0x01;
|
||||
private final static byte CROUNCHING_BIT = 0x02;
|
||||
@ -44,67 +44,67 @@ public class EntityMeta {
|
||||
}
|
||||
|
||||
public boolean isOnFire() {
|
||||
return getMaskBit(MASK_INDEX, ON_FIRE_BIT);
|
||||
return getMaskBit(OFFSET, ON_FIRE_BIT);
|
||||
}
|
||||
|
||||
public void setOnFire(boolean value) {
|
||||
setMaskBit(MASK_INDEX, ON_FIRE_BIT, value);
|
||||
setMaskBit(OFFSET, ON_FIRE_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isSneaking() {
|
||||
return getMaskBit(MASK_INDEX, CROUNCHING_BIT);
|
||||
return getMaskBit(OFFSET, CROUNCHING_BIT);
|
||||
}
|
||||
|
||||
public void setSneaking(boolean value) {
|
||||
setMaskBit(MASK_INDEX, CROUNCHING_BIT, value);
|
||||
setMaskBit(OFFSET, CROUNCHING_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isSprinting() {
|
||||
return getMaskBit(MASK_INDEX, SPRINTING_BIT);
|
||||
return getMaskBit(OFFSET, SPRINTING_BIT);
|
||||
}
|
||||
|
||||
public void setSprinting(boolean value) {
|
||||
setMaskBit(MASK_INDEX, SPRINTING_BIT, value);
|
||||
setMaskBit(OFFSET, SPRINTING_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isSwimming() {
|
||||
return getMaskBit(MASK_INDEX, SWIMMING_BIT);
|
||||
return getMaskBit(OFFSET, SWIMMING_BIT);
|
||||
}
|
||||
|
||||
public void setSwimming(boolean value) {
|
||||
setMaskBit(MASK_INDEX, SWIMMING_BIT, value);
|
||||
setMaskBit(OFFSET, SWIMMING_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isInvisible() {
|
||||
return getMaskBit(MASK_INDEX, INVISIBLE_BIT);
|
||||
return getMaskBit(OFFSET, INVISIBLE_BIT);
|
||||
}
|
||||
|
||||
public void setInvisible(boolean value) {
|
||||
setMaskBit(MASK_INDEX, INVISIBLE_BIT, value);
|
||||
setMaskBit(OFFSET, INVISIBLE_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isHasGlowingEffect() {
|
||||
return getMaskBit(MASK_INDEX, HAS_GLOWING_EFFECT_BIT);
|
||||
return getMaskBit(OFFSET, HAS_GLOWING_EFFECT_BIT);
|
||||
}
|
||||
|
||||
public void setHasGlowingEffect(boolean value) {
|
||||
setMaskBit(MASK_INDEX, HAS_GLOWING_EFFECT_BIT, value);
|
||||
setMaskBit(OFFSET, HAS_GLOWING_EFFECT_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isFlyingWithElytra() {
|
||||
return getMaskBit(MASK_INDEX, FLYING_WITH_ELYTRA_BIT);
|
||||
return getMaskBit(OFFSET, FLYING_WITH_ELYTRA_BIT);
|
||||
}
|
||||
|
||||
public void setFlyingWithElytra(boolean value) {
|
||||
setMaskBit(MASK_INDEX, FLYING_WITH_ELYTRA_BIT, value);
|
||||
setMaskBit(OFFSET, FLYING_WITH_ELYTRA_BIT, value);
|
||||
}
|
||||
|
||||
public int getAirTicks() {
|
||||
return this.metadata.getIndex((byte) 1, 300);
|
||||
return this.metadata.getIndex(OFFSET + 1, 300);
|
||||
}
|
||||
|
||||
public void setAirTicks(int value) {
|
||||
this.metadata.setIndex((byte) 1, Metadata.VarInt(value));
|
||||
this.metadata.setIndex(OFFSET + 1, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -126,66 +126,66 @@ public class EntityMeta {
|
||||
}
|
||||
|
||||
public Component getCustomName() {
|
||||
return this.metadata.getIndex((byte) 2, null);
|
||||
return this.metadata.getIndex(OFFSET + 2, null);
|
||||
}
|
||||
|
||||
public void setCustomName(Component value) {
|
||||
this.metadata.setIndex((byte) 2, Metadata.OptChat(value));
|
||||
this.metadata.setIndex(OFFSET + 2, Metadata.OptChat(value));
|
||||
}
|
||||
|
||||
public boolean isCustomNameVisible() {
|
||||
return this.metadata.getIndex((byte) 3, false);
|
||||
return this.metadata.getIndex(OFFSET + 3, false);
|
||||
}
|
||||
|
||||
public void setCustomNameVisible(boolean value) {
|
||||
this.metadata.setIndex((byte) 3, Metadata.Boolean(value));
|
||||
this.metadata.setIndex(OFFSET + 3, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
public boolean isSilent() {
|
||||
return this.metadata.getIndex((byte) 4, false);
|
||||
return this.metadata.getIndex(OFFSET + 4, false);
|
||||
}
|
||||
|
||||
public void setSilent(boolean value) {
|
||||
this.metadata.setIndex((byte) 4, Metadata.Boolean(value));
|
||||
this.metadata.setIndex(OFFSET + 4, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
public boolean isHasNoGravity() {
|
||||
return this.metadata.getIndex((byte) 5, false);
|
||||
return this.metadata.getIndex(OFFSET + 5, false);
|
||||
}
|
||||
|
||||
public void setHasNoGravity(boolean value) {
|
||||
this.metadata.setIndex((byte) 5, Metadata.Boolean(value));
|
||||
this.metadata.setIndex(OFFSET + 5, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
public Entity.Pose getPose() {
|
||||
return this.metadata.getIndex((byte) 6, Entity.Pose.STANDING);
|
||||
return this.metadata.getIndex(OFFSET + 6, Entity.Pose.STANDING);
|
||||
}
|
||||
|
||||
public void setPose(Entity.Pose value) {
|
||||
this.metadata.setIndex((byte) 6, Metadata.Pose(value));
|
||||
this.metadata.setIndex(OFFSET + 6, Metadata.Pose(value));
|
||||
}
|
||||
|
||||
public int getTickFrozen() {
|
||||
return this.metadata.getIndex((byte) 7, 0);
|
||||
return this.metadata.getIndex(OFFSET + 7, 0);
|
||||
}
|
||||
|
||||
public void setTickFrozen(int tickFrozen) {
|
||||
this.metadata.setIndex((byte) 7, Metadata.VarInt(tickFrozen));
|
||||
this.metadata.setIndex(OFFSET + 7, Metadata.VarInt(tickFrozen));
|
||||
}
|
||||
|
||||
protected byte getMask(byte index) {
|
||||
protected byte getMask(int index) {
|
||||
return this.metadata.getIndex(index, (byte) 0);
|
||||
}
|
||||
|
||||
protected void setMask(byte index, byte mask) {
|
||||
protected void setMask(int index, byte mask) {
|
||||
this.metadata.setIndex(index, Metadata.Byte(mask));
|
||||
}
|
||||
|
||||
protected boolean getMaskBit(byte index, byte bit) {
|
||||
protected boolean getMaskBit(int index, byte bit) {
|
||||
return (getMask(index) & bit) == bit;
|
||||
}
|
||||
|
||||
protected void setMaskBit(byte index, byte bit, boolean value) {
|
||||
protected void setMaskBit(int index, byte bit, boolean value) {
|
||||
byte mask = getMask(index);
|
||||
boolean currentValue = (mask & bit) == bit;
|
||||
if (currentValue == value) {
|
||||
|
@ -8,8 +8,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class LivingEntityMeta extends EntityMeta {
|
||||
|
||||
private final static byte MASK_INDEX = 7;
|
||||
public static final byte OFFSET = EntityMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 7;
|
||||
|
||||
private final static byte IS_HAND_ACTIVE_BIT = 0x01;
|
||||
private final static byte ACTIVE_HAND_BIT = 0x02;
|
||||
@ -20,77 +20,77 @@ public class LivingEntityMeta extends EntityMeta {
|
||||
}
|
||||
|
||||
public boolean isHandActive() {
|
||||
return getMaskBit(MASK_INDEX, IS_HAND_ACTIVE_BIT);
|
||||
return getMaskBit(OFFSET, IS_HAND_ACTIVE_BIT);
|
||||
}
|
||||
|
||||
public void setHandActive(boolean value) {
|
||||
setMaskBit(MASK_INDEX, IS_HAND_ACTIVE_BIT, value);
|
||||
setMaskBit(OFFSET, IS_HAND_ACTIVE_BIT, value);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Player.Hand getActiveHand() {
|
||||
return getMaskBit(MASK_INDEX, ACTIVE_HAND_BIT) ? Player.Hand.OFF : Player.Hand.MAIN;
|
||||
return getMaskBit(OFFSET, 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);
|
||||
setMaskBit(OFFSET, ACTIVE_HAND_BIT, hand == Player.Hand.OFF);
|
||||
}
|
||||
|
||||
public boolean isInRiptideSpinAttack() {
|
||||
return getMaskBit(MASK_INDEX, IS_IN_SPIN_ATTACK_BIT);
|
||||
return getMaskBit(OFFSET, IS_IN_SPIN_ATTACK_BIT);
|
||||
}
|
||||
|
||||
public void setInRiptideSpinAttack(boolean value) {
|
||||
setMaskBit(MASK_INDEX, IS_IN_SPIN_ATTACK_BIT, value);
|
||||
setMaskBit(OFFSET, IS_IN_SPIN_ATTACK_BIT, value);
|
||||
}
|
||||
|
||||
public float getHealth() {
|
||||
return super.metadata.getIndex((byte) 8, 1F);
|
||||
return super.metadata.getIndex(OFFSET + 1, 1F);
|
||||
}
|
||||
|
||||
public void setHealth(float value) {
|
||||
super.metadata.setIndex((byte) 8, Metadata.Float(value));
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.Float(value));
|
||||
}
|
||||
|
||||
public int getPotionEffectColor() {
|
||||
return super.metadata.getIndex((byte) 9, 0);
|
||||
return super.metadata.getIndex(OFFSET + 2, 0);
|
||||
}
|
||||
|
||||
public void setPotionEffectColor(int value) {
|
||||
super.metadata.setIndex((byte) 9, Metadata.VarInt(value));
|
||||
super.metadata.setIndex(OFFSET + 2, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
public boolean isPotionEffectAmbient() {
|
||||
return super.metadata.getIndex((byte) 10, false);
|
||||
return super.metadata.getIndex(OFFSET + 3, false);
|
||||
}
|
||||
|
||||
public void setPotionEffectAmbient(boolean value) {
|
||||
super.metadata.setIndex((byte) 10, Metadata.Boolean(value));
|
||||
super.metadata.setIndex(OFFSET + 3, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
public int getArrowCount() {
|
||||
return super.metadata.getIndex((byte) 11, 0);
|
||||
return super.metadata.getIndex(OFFSET + 4, 0);
|
||||
}
|
||||
|
||||
public void setArrowCount(int value) {
|
||||
super.metadata.getIndex((byte) 11, Metadata.VarInt(value));
|
||||
super.metadata.getIndex(OFFSET + 4, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
public int getHealthAddedByAbsorption() {
|
||||
return super.metadata.getIndex((byte) 12, 0);
|
||||
return super.metadata.getIndex(OFFSET + 5, 0);
|
||||
}
|
||||
|
||||
public void setHealthAddedByAbsorption(int value) {
|
||||
super.metadata.getIndex((byte) 12, Metadata.VarInt(value));
|
||||
super.metadata.getIndex(OFFSET + 5, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public BlockPosition getBedInWhichSleepingPosition() {
|
||||
return super.metadata.getIndex((byte) 13, null);
|
||||
return super.metadata.getIndex(OFFSET + 6, null);
|
||||
}
|
||||
|
||||
public void setBedInWhichSleepingPosition(@Nullable BlockPosition value) {
|
||||
super.metadata.setIndex((byte) 13, Metadata.OptPosition(value));
|
||||
super.metadata.setIndex(OFFSET + 6, Metadata.OptPosition(value));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MobMeta extends LivingEntityMeta {
|
||||
|
||||
private final static byte MASK_INDEX = 14;
|
||||
public static final byte OFFSET = LivingEntityMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
private final static byte NO_AI_BIT = 0x01;
|
||||
private final static byte IS_LEFT_HANDED_BIT = 0x02;
|
||||
@ -17,27 +17,27 @@ public class MobMeta extends LivingEntityMeta {
|
||||
}
|
||||
|
||||
public boolean isNoAi() {
|
||||
return getMaskBit(MASK_INDEX, NO_AI_BIT);
|
||||
return getMaskBit(OFFSET, NO_AI_BIT);
|
||||
}
|
||||
|
||||
public void setNoAi(boolean value) {
|
||||
setMaskBit(MASK_INDEX, NO_AI_BIT, value);
|
||||
setMaskBit(OFFSET, NO_AI_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isLeftHanded() {
|
||||
return getMaskBit(MASK_INDEX, IS_LEFT_HANDED_BIT);
|
||||
return getMaskBit(OFFSET, IS_LEFT_HANDED_BIT);
|
||||
}
|
||||
|
||||
public void setLeftHanded(boolean value) {
|
||||
setMaskBit(MASK_INDEX, IS_LEFT_HANDED_BIT, value);
|
||||
setMaskBit(OFFSET, IS_LEFT_HANDED_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isAggressive() {
|
||||
return getMaskBit(MASK_INDEX, IS_AGGRESSIVE_BIT);
|
||||
return getMaskBit(OFFSET, IS_AGGRESSIVE_BIT);
|
||||
}
|
||||
|
||||
public void setAggressive(boolean value) {
|
||||
setMaskBit(MASK_INDEX, IS_AGGRESSIVE_BIT, value);
|
||||
setMaskBit(OFFSET, IS_AGGRESSIVE_BIT, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,8 @@ import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PathfinderMobMeta extends MobMeta {
|
||||
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
protected PathfinderMobMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
|
@ -7,8 +7,8 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jglrxavpok.hephaistos.nbt.NBT;
|
||||
|
||||
public class PlayerMeta extends LivingEntityMeta {
|
||||
|
||||
private final static byte MASK_INDEX = 16;
|
||||
public static final byte OFFSET = LivingEntityMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
private final static byte CAPE_BIT = 0x01;
|
||||
private final static byte JACKET_BIT = 0x02;
|
||||
@ -23,101 +23,101 @@ public class PlayerMeta extends LivingEntityMeta {
|
||||
}
|
||||
|
||||
public float getAdditionalHearts() {
|
||||
return super.metadata.getIndex((byte) 14, 0F);
|
||||
return super.metadata.getIndex(OFFSET, 0F);
|
||||
}
|
||||
|
||||
public void setAdditionalHearts(float value) {
|
||||
super.metadata.setIndex((byte) 14, Metadata.Float(value));
|
||||
super.metadata.setIndex(OFFSET, Metadata.Float(value));
|
||||
}
|
||||
|
||||
public int getScore() {
|
||||
return super.metadata.getIndex((byte) 15, 0);
|
||||
return super.metadata.getIndex(OFFSET + 1, 0);
|
||||
}
|
||||
|
||||
public void setScore(int value) {
|
||||
super.metadata.setIndex((byte) 15, Metadata.VarInt(value));
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
public boolean isCapeEnabled() {
|
||||
return getMaskBit(MASK_INDEX, CAPE_BIT);
|
||||
return getMaskBit(OFFSET + 2, CAPE_BIT);
|
||||
}
|
||||
|
||||
public void setCapeEnabled(boolean value) {
|
||||
setMaskBit(MASK_INDEX, CAPE_BIT, value);
|
||||
setMaskBit(OFFSET + 2, CAPE_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isJacketEnabled() {
|
||||
return getMaskBit(MASK_INDEX, JACKET_BIT);
|
||||
return getMaskBit(OFFSET + 2, JACKET_BIT);
|
||||
}
|
||||
|
||||
public void setJacketEnabled(boolean value) {
|
||||
setMaskBit(MASK_INDEX, JACKET_BIT, value);
|
||||
setMaskBit(OFFSET + 2, JACKET_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isLeftSleeveEnabled() {
|
||||
return getMaskBit(MASK_INDEX, LEFT_SLEEVE_BIT);
|
||||
return getMaskBit(OFFSET + 2, LEFT_SLEEVE_BIT);
|
||||
}
|
||||
|
||||
public void setLeftSleeveEnabled(boolean value) {
|
||||
setMaskBit(MASK_INDEX, LEFT_SLEEVE_BIT, value);
|
||||
setMaskBit(OFFSET + 2, LEFT_SLEEVE_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isRightSleeveEnabled() {
|
||||
return getMaskBit(MASK_INDEX, RIGHT_SLEEVE_BIT);
|
||||
return getMaskBit(OFFSET + 2, RIGHT_SLEEVE_BIT);
|
||||
}
|
||||
|
||||
public void setRightSleeveEnabled(boolean value) {
|
||||
setMaskBit(MASK_INDEX, RIGHT_SLEEVE_BIT, value);
|
||||
setMaskBit(OFFSET + 2, RIGHT_SLEEVE_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isLeftLegEnabled() {
|
||||
return getMaskBit(MASK_INDEX, LEFT_LEG_BIT);
|
||||
return getMaskBit(OFFSET + 2, LEFT_LEG_BIT);
|
||||
}
|
||||
|
||||
public void setLeftLegEnabled(boolean value) {
|
||||
setMaskBit(MASK_INDEX, LEFT_LEG_BIT, value);
|
||||
setMaskBit(OFFSET + 2, LEFT_LEG_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isRightLegEnabled() {
|
||||
return getMaskBit(MASK_INDEX, RIGHT_LEG_BIT);
|
||||
return getMaskBit(OFFSET + 2, RIGHT_LEG_BIT);
|
||||
}
|
||||
|
||||
public void setRightLegEnabled(boolean value) {
|
||||
setMaskBit(MASK_INDEX, RIGHT_LEG_BIT, value);
|
||||
setMaskBit(OFFSET + 2, RIGHT_LEG_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isHatEnabled() {
|
||||
return getMaskBit(MASK_INDEX, HAT_BIT);
|
||||
return getMaskBit(OFFSET + 2, HAT_BIT);
|
||||
}
|
||||
|
||||
public void setHatEnabled(boolean value) {
|
||||
setMaskBit(MASK_INDEX, HAT_BIT, value);
|
||||
setMaskBit(OFFSET + 2, HAT_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isRightMainHand() {
|
||||
return super.metadata.getIndex((byte) 17, (byte) 1) == (byte) 1;
|
||||
return super.metadata.getIndex(OFFSET + 3, (byte) 1) == (byte) 1;
|
||||
}
|
||||
|
||||
public void setRightMainHand(boolean value) {
|
||||
super.metadata.setIndex((byte) 17, Metadata.Byte(value ? (byte) 1 : (byte) 0));
|
||||
super.metadata.setIndex(OFFSET + 3, Metadata.Byte(value ? (byte) 1 : (byte) 0));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public NBT getLeftShoulderEntityData() {
|
||||
return super.metadata.getIndex((byte) 18, null);
|
||||
return super.metadata.getIndex(OFFSET + 4, null);
|
||||
}
|
||||
|
||||
public void setLeftShoulderEntityData(@Nullable NBT value) {
|
||||
super.metadata.setIndex((byte) 18, Metadata.NBT(value));
|
||||
super.metadata.setIndex(OFFSET + 4, Metadata.NBT(value));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public NBT getRightShoulderEntityData() {
|
||||
return super.metadata.getIndex((byte) 19, null);
|
||||
return super.metadata.getIndex(OFFSET + 5, null);
|
||||
}
|
||||
|
||||
public void setRightShoulderEntityData(@Nullable NBT value) {
|
||||
super.metadata.setIndex((byte) 19, Metadata.NBT(value));
|
||||
super.metadata.setIndex(OFFSET + 5, Metadata.NBT(value));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,10 +2,13 @@ package net.minestom.server.entity.metadata.ambient;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.metadata.LivingEntityMeta;
|
||||
import net.minestom.server.entity.metadata.MobMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AmbientCreatureMeta extends MobMeta {
|
||||
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
protected AmbientCreatureMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
|
@ -2,11 +2,12 @@ package net.minestom.server.entity.metadata.ambient;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.metadata.LivingEntityMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class BatMeta extends AmbientCreatureMeta {
|
||||
|
||||
private final static byte MASK_INDEX = 15;
|
||||
public static final byte OFFSET = AmbientCreatureMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
private final static byte IS_HANGING_BIT = 0x01;
|
||||
|
||||
@ -15,11 +16,11 @@ public class BatMeta extends AmbientCreatureMeta {
|
||||
}
|
||||
|
||||
public boolean isHanging() {
|
||||
return getMaskBit(MASK_INDEX, IS_HANGING_BIT);
|
||||
return getMaskBit(OFFSET, IS_HANGING_BIT);
|
||||
}
|
||||
|
||||
public void setHanging(boolean value) {
|
||||
setMaskBit(MASK_INDEX, IS_HANGING_BIT, value);
|
||||
setMaskBit(OFFSET, IS_HANGING_BIT, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,13 +2,14 @@ package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.metadata.LivingEntityMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class AbstractHorseMeta extends AnimalMeta {
|
||||
|
||||
private final static byte MASK_INDEX = 16;
|
||||
public static final byte OFFSET = AnimalMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 2;
|
||||
|
||||
private final static byte TAMED_BIT = 0x02;
|
||||
private final static byte SADDLED_BIT = 0x04;
|
||||
@ -22,59 +23,59 @@ public class AbstractHorseMeta extends AnimalMeta {
|
||||
}
|
||||
|
||||
public boolean isTamed() {
|
||||
return getMaskBit(MASK_INDEX, TAMED_BIT);
|
||||
return getMaskBit(OFFSET, TAMED_BIT);
|
||||
}
|
||||
|
||||
public void setTamed(boolean value) {
|
||||
setMaskBit(MASK_INDEX, TAMED_BIT, value);
|
||||
setMaskBit(OFFSET, TAMED_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isSaddled() {
|
||||
return getMaskBit(MASK_INDEX, SADDLED_BIT);
|
||||
return getMaskBit(OFFSET, SADDLED_BIT);
|
||||
}
|
||||
|
||||
public void setSaddled(boolean value) {
|
||||
setMaskBit(MASK_INDEX, SADDLED_BIT, value);
|
||||
setMaskBit(OFFSET, SADDLED_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isHasBred() {
|
||||
return getMaskBit(MASK_INDEX, HAS_BRED_BIT);
|
||||
return getMaskBit(OFFSET, HAS_BRED_BIT);
|
||||
}
|
||||
|
||||
public void setHasBred(boolean value) {
|
||||
setMaskBit(MASK_INDEX, HAS_BRED_BIT, value);
|
||||
setMaskBit(OFFSET, HAS_BRED_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isEating() {
|
||||
return getMaskBit(MASK_INDEX, EATING_BIT);
|
||||
return getMaskBit(OFFSET, EATING_BIT);
|
||||
}
|
||||
|
||||
public void setEating(boolean value) {
|
||||
setMaskBit(MASK_INDEX, EATING_BIT, value);
|
||||
setMaskBit(OFFSET, EATING_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isRearing() {
|
||||
return getMaskBit(MASK_INDEX, REARING_BIT);
|
||||
return getMaskBit(OFFSET, REARING_BIT);
|
||||
}
|
||||
|
||||
public void setRearing(boolean value) {
|
||||
setMaskBit(MASK_INDEX, REARING_BIT, value);
|
||||
setMaskBit(OFFSET, REARING_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isMouthOpen() {
|
||||
return getMaskBit(MASK_INDEX, MOUTH_OPEN_BIT);
|
||||
return getMaskBit(OFFSET, MOUTH_OPEN_BIT);
|
||||
}
|
||||
|
||||
public void setMouthOpen(boolean value) {
|
||||
setMaskBit(MASK_INDEX, MOUTH_OPEN_BIT, value);
|
||||
setMaskBit(OFFSET, MOUTH_OPEN_BIT, value);
|
||||
}
|
||||
|
||||
public UUID getOwner() {
|
||||
return super.metadata.getIndex((byte) 17, null);
|
||||
return super.metadata.getIndex(OFFSET + 1, null);
|
||||
}
|
||||
|
||||
public void setOwner(UUID value) {
|
||||
super.metadata.setIndex((byte) 17, Metadata.OptUUID(value));
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.OptUUID(value));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,9 +3,12 @@ package net.minestom.server.entity.metadata.animal;
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.metadata.AgeableMobMeta;
|
||||
import net.minestom.server.entity.metadata.LivingEntityMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AnimalMeta extends AgeableMobMeta {
|
||||
public static final byte OFFSET = AgeableMobMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
protected AnimalMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
|
@ -2,11 +2,13 @@ package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.metadata.LivingEntityMeta;
|
||||
import net.minestom.server.entity.metadata.ambient.AmbientCreatureMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class BeeMeta extends AnimalMeta {
|
||||
|
||||
private final static byte MASK_INDEX = 16;
|
||||
public static final byte OFFSET = AnimalMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 2;
|
||||
|
||||
private final static byte ANGRY_BIT = 0x02;
|
||||
private final static byte HAS_STUNG_BIT = 0x04;
|
||||
@ -17,35 +19,35 @@ public class BeeMeta extends AnimalMeta {
|
||||
}
|
||||
|
||||
public boolean isAngry() {
|
||||
return getMaskBit(MASK_INDEX, ANGRY_BIT);
|
||||
return getMaskBit(OFFSET, ANGRY_BIT);
|
||||
}
|
||||
|
||||
public void setAngry(boolean value) {
|
||||
setMaskBit(MASK_INDEX, ANGRY_BIT, value);
|
||||
setMaskBit(OFFSET, ANGRY_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isHasStung() {
|
||||
return getMaskBit(MASK_INDEX, HAS_STUNG_BIT);
|
||||
return getMaskBit(OFFSET, HAS_STUNG_BIT);
|
||||
}
|
||||
|
||||
public void setHasStung(boolean value) {
|
||||
setMaskBit(MASK_INDEX, HAS_STUNG_BIT, value);
|
||||
setMaskBit(OFFSET, HAS_STUNG_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isHasNectar() {
|
||||
return getMaskBit(MASK_INDEX, HAS_NECTAR_BIT);
|
||||
return getMaskBit(OFFSET, HAS_NECTAR_BIT);
|
||||
}
|
||||
|
||||
public void setHasNectar(boolean value) {
|
||||
setMaskBit(MASK_INDEX, HAS_NECTAR_BIT, value);
|
||||
setMaskBit(OFFSET, HAS_NECTAR_BIT, value);
|
||||
}
|
||||
|
||||
public int getAngerTicks() {
|
||||
return super.metadata.getIndex((byte) 17, 0);
|
||||
return super.metadata.getIndex(OFFSET + 1, 0);
|
||||
}
|
||||
|
||||
public void setAngerTicks(int value) {
|
||||
super.metadata.setIndex((byte) 17, Metadata.VarInt(value));
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,20 +2,23 @@ package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.metadata.LivingEntityMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ChestedHorseMeta extends AbstractHorseMeta {
|
||||
public static final byte OFFSET = AbstractHorseMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
protected ChestedHorseMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean isHasChest() {
|
||||
return super.metadata.getIndex((byte) 18, false);
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
}
|
||||
|
||||
public void setHasChest(boolean value) {
|
||||
super.metadata.setIndex((byte) 18, Metadata.Boolean(value));
|
||||
super.metadata.setIndex(OFFSET, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,9 +2,12 @@ package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.metadata.LivingEntityMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ChickenMeta extends AnimalMeta {
|
||||
public static final byte OFFSET = AnimalMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public ChickenMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
|
@ -2,9 +2,12 @@ package net.minestom.server.entity.metadata.animal;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.metadata.LivingEntityMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CowMeta extends AnimalMeta {
|
||||
public static final byte OFFSET = AnimalMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public CowMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
|
@ -5,6 +5,8 @@ import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class DonkeyMeta extends ChestedHorseMeta {
|
||||
public static final byte OFFSET = AnimalMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public DonkeyMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
|
@ -8,8 +8,8 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.util.UUID;
|
||||
|
||||
public class FoxMeta extends AnimalMeta {
|
||||
|
||||
private final static byte MASK_INDEX = 17;
|
||||
public static final byte OFFSET = AnimalMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 4;
|
||||
|
||||
private final static byte SITTING_BIT = 0x01;
|
||||
private final static byte CROUCHING_BIT = 0x04;
|
||||
@ -25,85 +25,85 @@ public class FoxMeta extends AnimalMeta {
|
||||
|
||||
@NotNull
|
||||
public Type getType() {
|
||||
return Type.VALUES[super.metadata.getIndex((byte) 16, 0)];
|
||||
return Type.VALUES[super.metadata.getIndex(OFFSET, 0)];
|
||||
}
|
||||
|
||||
public void setType(@NotNull Type type) {
|
||||
super.metadata.setIndex((byte) 16, Metadata.VarInt(type.ordinal()));
|
||||
super.metadata.setIndex(OFFSET, Metadata.VarInt(type.ordinal()));
|
||||
}
|
||||
|
||||
public boolean isSitting() {
|
||||
return getMaskBit(MASK_INDEX, SITTING_BIT);
|
||||
return getMaskBit(OFFSET + 1, SITTING_BIT);
|
||||
}
|
||||
|
||||
public void setSitting(boolean value) {
|
||||
setMaskBit(MASK_INDEX, SITTING_BIT, value);
|
||||
setMaskBit(OFFSET + 1, SITTING_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isFoxSneaking() {
|
||||
return getMaskBit(MASK_INDEX, CROUCHING_BIT);
|
||||
return getMaskBit(OFFSET + 1, CROUCHING_BIT);
|
||||
}
|
||||
|
||||
public void setFoxSneaking(boolean value) {
|
||||
setMaskBit(MASK_INDEX, CROUCHING_BIT, value);
|
||||
setMaskBit(OFFSET + 1, CROUCHING_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isInterested() {
|
||||
return getMaskBit(MASK_INDEX, INTERESTED_BIT);
|
||||
return getMaskBit(OFFSET + 1, INTERESTED_BIT);
|
||||
}
|
||||
|
||||
public void setInterested(boolean value) {
|
||||
setMaskBit(MASK_INDEX, INTERESTED_BIT, value);
|
||||
setMaskBit(OFFSET + 1, INTERESTED_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isPouncing() {
|
||||
return getMaskBit(MASK_INDEX, POUNCING_BIT);
|
||||
return getMaskBit(OFFSET + 1, POUNCING_BIT);
|
||||
}
|
||||
|
||||
public void setPouncing(boolean value) {
|
||||
setMaskBit(MASK_INDEX, POUNCING_BIT, value);
|
||||
setMaskBit(OFFSET + 1, POUNCING_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isSleeping() {
|
||||
return getMaskBit(MASK_INDEX, SLEEPING_BIT);
|
||||
return getMaskBit(OFFSET + 1, SLEEPING_BIT);
|
||||
}
|
||||
|
||||
public void setSleeping(boolean value) {
|
||||
setMaskBit(MASK_INDEX, SLEEPING_BIT, value);
|
||||
setMaskBit(OFFSET + 1, SLEEPING_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isFaceplanted() {
|
||||
return getMaskBit(MASK_INDEX, FACEPLANTED_BIT);
|
||||
return getMaskBit(OFFSET + 1, FACEPLANTED_BIT);
|
||||
}
|
||||
|
||||
public void setFaceplanted(boolean value) {
|
||||
setMaskBit(MASK_INDEX, FACEPLANTED_BIT, value);
|
||||
setMaskBit(OFFSET + 1, FACEPLANTED_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isDefending() {
|
||||
return getMaskBit(MASK_INDEX, DEFENDING_BIT);
|
||||
return getMaskBit(OFFSET + 1, DEFENDING_BIT);
|
||||
}
|
||||
|
||||
public void setDefending(boolean value) {
|
||||
setMaskBit(MASK_INDEX, DEFENDING_BIT, value);
|
||||
setMaskBit(OFFSET + 1, DEFENDING_BIT, value);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public UUID getFirstUUID() {
|
||||
return super.metadata.getIndex((byte) 18, null);
|
||||
return super.metadata.getIndex(OFFSET + 2, null);
|
||||
}
|
||||
|
||||
public void setFirstUUID(@Nullable UUID value) {
|
||||
super.metadata.setIndex((byte) 18, Metadata.OptUUID(value));
|
||||
super.metadata.setIndex(OFFSET + 2, Metadata.OptUUID(value));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public UUID getSecondUUID() {
|
||||
return super.metadata.getIndex((byte) 19, null);
|
||||
return super.metadata.getIndex(OFFSET + 3, null);
|
||||
}
|
||||
|
||||
public void setSecondUUID(@Nullable UUID value) {
|
||||
super.metadata.setIndex((byte) 19, Metadata.OptUUID(value));
|
||||
super.metadata.setIndex(OFFSET + 3, Metadata.OptUUID(value));
|
||||
}
|
||||
|
||||
public enum Type {
|
||||
|
@ -5,17 +5,19 @@ import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class HoglinMeta extends AnimalMeta {
|
||||
public static final byte OFFSET = AnimalMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public HoglinMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean isImmuneToZombification() {
|
||||
return super.metadata.getIndex((byte) 16, false);
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
}
|
||||
|
||||
public void setImmuneToZombification(boolean value) {
|
||||
super.metadata.setIndex((byte) 16, Metadata.Boolean(value));
|
||||
super.metadata.setIndex(OFFSET, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,17 +5,19 @@ import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class HorseMeta extends AbstractHorseMeta {
|
||||
public static final byte OFFSET = AbstractHorseMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public HorseMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public Variant getVariant() {
|
||||
return getVariantFromID(super.metadata.getIndex((byte) 18, 0));
|
||||
return getVariantFromID(super.metadata.getIndex(OFFSET, 0));
|
||||
}
|
||||
|
||||
public void setVariant(Variant variant) {
|
||||
super.metadata.setIndex((byte) 18, Metadata.VarInt(getVariantID(variant.marking, variant.color)));
|
||||
super.metadata.setIndex(OFFSET, Metadata.VarInt(getVariantID(variant.marking, variant.color)));
|
||||
}
|
||||
|
||||
public static int getVariantID(@NotNull Marking marking, @NotNull Color color) {
|
||||
|
@ -5,33 +5,35 @@ import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class LlamaMeta extends ChestedHorseMeta {
|
||||
public static final byte OFFSET = ChestedHorseMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 3;
|
||||
|
||||
public LlamaMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public int getStrength() {
|
||||
return super.metadata.getIndex((byte) 19, 0);
|
||||
return super.metadata.getIndex(OFFSET, 0);
|
||||
}
|
||||
|
||||
public void setStrength(int value) {
|
||||
super.metadata.setIndex((byte) 19, Metadata.VarInt(value));
|
||||
super.metadata.setIndex(OFFSET, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
public int getCarpetColor() {
|
||||
return super.metadata.getIndex((byte) 20, -1);
|
||||
return super.metadata.getIndex(OFFSET + 1, -1);
|
||||
}
|
||||
|
||||
public void setCarpetColor(int value) {
|
||||
super.metadata.setIndex((byte) 20, Metadata.VarInt(value));
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
public Variant getVariant() {
|
||||
return Variant.VALUES[super.metadata.getIndex((byte) 21, 0)];
|
||||
return Variant.VALUES[super.metadata.getIndex(OFFSET + 2, 0)];
|
||||
}
|
||||
|
||||
public void setVariant(Variant value) {
|
||||
super.metadata.setIndex((byte) 21, Metadata.VarInt(value.ordinal()));
|
||||
super.metadata.setIndex(OFFSET + 2, Metadata.VarInt(value.ordinal()));
|
||||
}
|
||||
|
||||
public enum Variant {
|
||||
|
@ -7,6 +7,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.Locale;
|
||||
|
||||
public class MooshroomMeta extends CowMeta {
|
||||
public static final byte OFFSET = CowMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public MooshroomMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
@ -14,11 +16,11 @@ public class MooshroomMeta extends CowMeta {
|
||||
|
||||
@NotNull
|
||||
public Variant getVariant() {
|
||||
return Variant.valueOf(super.metadata.getIndex((byte) 16, "red").toUpperCase(Locale.ROOT));
|
||||
return Variant.valueOf(super.metadata.getIndex(OFFSET, "red").toUpperCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
public void setVariant(@NotNull Variant value) {
|
||||
super.metadata.setIndex((byte) 16, Metadata.String(value.name().toLowerCase(Locale.ROOT)));
|
||||
super.metadata.setIndex(OFFSET, Metadata.String(value.name().toLowerCase(Locale.ROOT)));
|
||||
}
|
||||
|
||||
public enum Variant {
|
||||
|
@ -5,6 +5,8 @@ import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MuleMeta extends ChestedHorseMeta {
|
||||
public static final byte OFFSET = ChestedHorseMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public MuleMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
|
@ -5,17 +5,19 @@ import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class OcelotMeta extends AnimalMeta {
|
||||
public static final byte OFFSET = AnimalMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public OcelotMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean isTrusting() {
|
||||
return super.metadata.getIndex((byte) 16, false);
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
}
|
||||
|
||||
public void setTrusting(boolean value) {
|
||||
super.metadata.setIndex((byte) 16, Metadata.Boolean(value));
|
||||
super.metadata.setIndex(OFFSET, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PandaMeta extends AnimalMeta {
|
||||
|
||||
private final static byte MASK_INDEX = 21;
|
||||
public static final byte OFFSET = AnimalMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 6;
|
||||
|
||||
private final static byte SNEEZING_BIT = 0x02;
|
||||
private final static byte ROLLING_BIT = 0x04;
|
||||
@ -18,77 +18,77 @@ public class PandaMeta extends AnimalMeta {
|
||||
}
|
||||
|
||||
public int getBreedTimer() {
|
||||
return super.metadata.getIndex((byte) 16, 0);
|
||||
return super.metadata.getIndex(OFFSET, 0);
|
||||
}
|
||||
|
||||
public void setBreedTimer(int value) {
|
||||
super.metadata.setIndex((byte) 16, Metadata.VarInt(value));
|
||||
super.metadata.setIndex(OFFSET, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
public int getSneezeTimer() {
|
||||
return super.metadata.getIndex((byte) 17, 0);
|
||||
return super.metadata.getIndex(OFFSET + 1, 0);
|
||||
}
|
||||
|
||||
public void setSneezeTimer(int value) {
|
||||
super.metadata.setIndex((byte) 17, Metadata.VarInt(value));
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
public int getEatTimer() {
|
||||
return super.metadata.getIndex((byte) 18, 0);
|
||||
return super.metadata.getIndex(OFFSET + 2, 0);
|
||||
}
|
||||
|
||||
public void setEatTimer(int value) {
|
||||
super.metadata.setIndex((byte) 18, Metadata.VarInt(value));
|
||||
super.metadata.setIndex(OFFSET + 2, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Gene getMainGene() {
|
||||
return Gene.VALUES[super.metadata.getIndex((byte) 19, (byte) 0)];
|
||||
return Gene.VALUES[super.metadata.getIndex(OFFSET + 3, (byte) 0)];
|
||||
}
|
||||
|
||||
public void setMainGene(@NotNull Gene value) {
|
||||
super.metadata.setIndex((byte) 19, Metadata.Byte((byte) value.ordinal()));
|
||||
super.metadata.setIndex(OFFSET + 3, Metadata.Byte((byte) value.ordinal()));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Gene getHiddenGene() {
|
||||
return Gene.VALUES[super.metadata.getIndex((byte) 20, (byte) 0)];
|
||||
return Gene.VALUES[super.metadata.getIndex(OFFSET + 4, (byte) 0)];
|
||||
}
|
||||
|
||||
public void setHiddenGene(@NotNull Gene value) {
|
||||
super.metadata.setIndex((byte) 20, Metadata.Byte((byte) value.ordinal()));
|
||||
super.metadata.setIndex(OFFSET + 4, Metadata.Byte((byte) value.ordinal()));
|
||||
}
|
||||
|
||||
public boolean isSneezing() {
|
||||
return getMaskBit(MASK_INDEX, SNEEZING_BIT);
|
||||
return getMaskBit(OFFSET + 5, SNEEZING_BIT);
|
||||
}
|
||||
|
||||
public void setSneezing(boolean value) {
|
||||
setMaskBit(MASK_INDEX, SNEEZING_BIT, value);
|
||||
setMaskBit(OFFSET + 5, SNEEZING_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isRolling() {
|
||||
return getMaskBit(MASK_INDEX, ROLLING_BIT);
|
||||
return getMaskBit(OFFSET + 5, ROLLING_BIT);
|
||||
}
|
||||
|
||||
public void setRolling(boolean value) {
|
||||
setMaskBit(MASK_INDEX, ROLLING_BIT, value);
|
||||
setMaskBit(OFFSET + 5, ROLLING_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isSitting() {
|
||||
return getMaskBit(MASK_INDEX, SITTING_BIT);
|
||||
return getMaskBit(OFFSET + 5, SITTING_BIT);
|
||||
}
|
||||
|
||||
public void setSitting(boolean value) {
|
||||
setMaskBit(MASK_INDEX, SITTING_BIT, value);
|
||||
setMaskBit(OFFSET + 5, SITTING_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isOnBack() {
|
||||
return getMaskBit(MASK_INDEX, ON_BACK_BIT);
|
||||
return getMaskBit(OFFSET + 5, ON_BACK_BIT);
|
||||
}
|
||||
|
||||
public void setOnBack(boolean value) {
|
||||
setMaskBit(MASK_INDEX, ON_BACK_BIT, value);
|
||||
setMaskBit(OFFSET + 5, ON_BACK_BIT, value);
|
||||
}
|
||||
|
||||
public enum Gene {
|
||||
|
@ -5,25 +5,27 @@ import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PigMeta extends AnimalMeta {
|
||||
public static final byte OFFSET = AnimalMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 2;
|
||||
|
||||
public PigMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean isHasSaddle() {
|
||||
return super.metadata.getIndex((byte) 16, false);
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
}
|
||||
|
||||
public void setHasSaddle(boolean value) {
|
||||
super.metadata.setIndex((byte) 16, Metadata.Boolean(value));
|
||||
super.metadata.setIndex(OFFSET, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
public int getTimeToBoost() {
|
||||
return super.metadata.getIndex((byte) 17, 0);
|
||||
return super.metadata.getIndex(OFFSET + 1, 0);
|
||||
}
|
||||
|
||||
public void setTimeToBoost(int value) {
|
||||
super.metadata.getIndex((byte) 17, Metadata.VarInt(value));
|
||||
super.metadata.getIndex(OFFSET + 1, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,17 +5,19 @@ import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PolarBearMeta extends AnimalMeta {
|
||||
public static final byte OFFSET = AnimalMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public PolarBearMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean isStandingUp() {
|
||||
return super.metadata.getIndex((byte) 16, false);
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
}
|
||||
|
||||
public void setStandingUp(boolean value) {
|
||||
super.metadata.setIndex((byte) 16, Metadata.Boolean(value));
|
||||
super.metadata.setIndex(OFFSET, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,8 @@ import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class RabbitMeta extends AnimalMeta {
|
||||
public static final byte OFFSET = AnimalMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public RabbitMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
@ -12,7 +14,7 @@ public class RabbitMeta extends AnimalMeta {
|
||||
|
||||
@NotNull
|
||||
public Type getType() {
|
||||
int id = super.metadata.getIndex((byte) 16, 0);
|
||||
int id = super.metadata.getIndex(OFFSET, 0);
|
||||
if (id == 99) {
|
||||
return Type.KILLER_BUNNY;
|
||||
}
|
||||
@ -21,7 +23,7 @@ public class RabbitMeta extends AnimalMeta {
|
||||
|
||||
public void setType(@NotNull Type value) {
|
||||
int id = value == Type.KILLER_BUNNY ? 99 : value.ordinal();
|
||||
super.metadata.setIndex((byte) 16, Metadata.VarInt(id));
|
||||
super.metadata.setIndex(OFFSET, Metadata.VarInt(id));
|
||||
}
|
||||
|
||||
public enum Type {
|
||||
|
@ -5,8 +5,8 @@ import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SheepMeta extends AnimalMeta {
|
||||
|
||||
private final static byte MASK_INDEX = 16;
|
||||
public static final byte OFFSET = AnimalMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
private final static byte COLOR_BITS = 0x0F;
|
||||
private final static byte SHEARED_BIT = 0x10;
|
||||
@ -16,25 +16,25 @@ public class SheepMeta extends AnimalMeta {
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return getMask(MASK_INDEX) & COLOR_BITS;
|
||||
return getMask(OFFSET) & COLOR_BITS;
|
||||
}
|
||||
|
||||
public void setColor(byte color) {
|
||||
byte before = getMask(MASK_INDEX);
|
||||
byte before = getMask(OFFSET);
|
||||
byte mask = before;
|
||||
mask &= ~COLOR_BITS;
|
||||
mask |= (color & COLOR_BITS);
|
||||
if (mask != before) {
|
||||
setMask(MASK_INDEX, mask);
|
||||
setMask(OFFSET, mask);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isSheared() {
|
||||
return getMaskBit(MASK_INDEX, SHEARED_BIT);
|
||||
return getMaskBit(OFFSET, SHEARED_BIT);
|
||||
}
|
||||
|
||||
public void setSheared(boolean value) {
|
||||
setMaskBit(MASK_INDEX, SHEARED_BIT, value);
|
||||
setMaskBit(OFFSET, SHEARED_BIT, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,8 @@ import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SkeletonHorseMeta extends AbstractHorseMeta {
|
||||
public static final byte OFFSET = AbstractHorseMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public SkeletonHorseMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
|
@ -5,33 +5,35 @@ import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class StriderMeta extends AnimalMeta {
|
||||
public static final byte OFFSET = AnimalMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 3;
|
||||
|
||||
public StriderMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public int getTimeToBoost() {
|
||||
return super.metadata.getIndex((byte) 16, 0);
|
||||
return super.metadata.getIndex(OFFSET, 0);
|
||||
}
|
||||
|
||||
public void setTimeToBoost(int value) {
|
||||
super.metadata.setIndex((byte) 16, Metadata.VarInt(value));
|
||||
super.metadata.setIndex(OFFSET, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
public boolean isShaking() {
|
||||
return super.metadata.getIndex((byte) 17, false);
|
||||
return super.metadata.getIndex(OFFSET + 1, false);
|
||||
}
|
||||
|
||||
public void setShaking(boolean value) {
|
||||
super.metadata.setIndex((byte) 17, Metadata.Boolean(value));
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
public boolean isHasSaddle() {
|
||||
return super.metadata.getIndex((byte) 18, false);
|
||||
return super.metadata.getIndex(OFFSET + 2, false);
|
||||
}
|
||||
|
||||
public void setHasSaddle(boolean value) {
|
||||
super.metadata.setIndex((byte) 18, Metadata.Boolean(value));
|
||||
super.metadata.setIndex(OFFSET + 2, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,6 +6,8 @@ import net.minestom.server.utils.BlockPosition;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class TurtleMeta extends AnimalMeta {
|
||||
public static final byte OFFSET = AnimalMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 6;
|
||||
|
||||
public TurtleMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
@ -13,52 +15,52 @@ public class TurtleMeta extends AnimalMeta {
|
||||
|
||||
@NotNull
|
||||
public BlockPosition getHomePosition() {
|
||||
return super.metadata.getIndex((byte) 16, new BlockPosition(0, 0, 0));
|
||||
return super.metadata.getIndex(OFFSET, new BlockPosition(0, 0, 0));
|
||||
}
|
||||
|
||||
public void setBlockPosition(@NotNull BlockPosition value) {
|
||||
super.metadata.setIndex((byte) 16, Metadata.Position(value));
|
||||
super.metadata.setIndex(OFFSET, Metadata.Position(value));
|
||||
}
|
||||
|
||||
public boolean isHasEgg() {
|
||||
return super.metadata.getIndex((byte) 17, false);
|
||||
return super.metadata.getIndex(OFFSET + 1, false);
|
||||
}
|
||||
|
||||
public void setHasEgg(boolean value) {
|
||||
super.metadata.setIndex((byte) 17, Metadata.Boolean(value));
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
public boolean isLayingEgg() {
|
||||
return super.metadata.getIndex((byte) 18, false);
|
||||
return super.metadata.getIndex(OFFSET + 2, false);
|
||||
}
|
||||
|
||||
public void setLayingEgg(boolean value) {
|
||||
super.metadata.setIndex((byte) 18, Metadata.Boolean(value));
|
||||
super.metadata.setIndex(OFFSET + 2, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public BlockPosition getTravelPosition() {
|
||||
return super.metadata.getIndex((byte) 19, new BlockPosition(0, 0, 0));
|
||||
return super.metadata.getIndex(OFFSET + 3, new BlockPosition(0, 0, 0));
|
||||
}
|
||||
|
||||
public void setTravelPosition(@NotNull BlockPosition value) {
|
||||
super.metadata.setIndex((byte) 19, Metadata.Position(value));
|
||||
super.metadata.setIndex(OFFSET + 3, Metadata.Position(value));
|
||||
}
|
||||
|
||||
public boolean isGoingHome() {
|
||||
return super.metadata.getIndex((byte) 20, false);
|
||||
return super.metadata.getIndex(OFFSET + 4, false);
|
||||
}
|
||||
|
||||
public void setGoingHome(boolean value) {
|
||||
super.metadata.setIndex((byte) 20, Metadata.Boolean(value));
|
||||
super.metadata.setIndex(OFFSET + 4, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
public boolean isTravelling() {
|
||||
return super.metadata.getIndex((byte) 21, false);
|
||||
return super.metadata.getIndex(OFFSET + 5, false);
|
||||
}
|
||||
|
||||
public void setTravelling(boolean value) {
|
||||
super.metadata.setIndex((byte) 21, Metadata.Boolean(value));
|
||||
super.metadata.setIndex(OFFSET + 5, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,8 @@ import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ZombieHorseMeta extends AbstractHorseMeta {
|
||||
public static final byte OFFSET = AbstractHorseMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public ZombieHorseMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
|
@ -2,9 +2,12 @@ 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;
|
||||
|
||||
public class CatMeta extends TameableAnimalMeta {
|
||||
public static final byte OFFSET = TameableAnimalMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 4;
|
||||
|
||||
public CatMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
@ -12,35 +15,35 @@ public class CatMeta extends TameableAnimalMeta {
|
||||
|
||||
@NotNull
|
||||
public Color getColor() {
|
||||
return Color.VALUES[super.metadata.getIndex((byte) 18, 1)];
|
||||
return Color.VALUES[super.metadata.getIndex(OFFSET, 1)];
|
||||
}
|
||||
|
||||
public void setColor(@NotNull Color value) {
|
||||
super.metadata.setIndex((byte) 18, Metadata.VarInt(value.ordinal()));
|
||||
super.metadata.setIndex(OFFSET, Metadata.VarInt(value.ordinal()));
|
||||
}
|
||||
|
||||
public boolean isLying() {
|
||||
return super.metadata.getIndex((byte) 19, false);
|
||||
return super.metadata.getIndex(OFFSET + 1, false);
|
||||
}
|
||||
|
||||
public void setLying(boolean value) {
|
||||
super.metadata.setIndex((byte) 19, Metadata.Boolean(value));
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
public boolean isRelaxed() {
|
||||
return super.metadata.getIndex((byte) 20, false);
|
||||
return super.metadata.getIndex(OFFSET + 2, false);
|
||||
}
|
||||
|
||||
public void setRelaxed(boolean value) {
|
||||
super.metadata.setIndex((byte) 20, Metadata.Boolean(value));
|
||||
super.metadata.setIndex(OFFSET + 2, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
public int getCollarColor() {
|
||||
return super.metadata.getIndex((byte) 21, 14);
|
||||
return super.metadata.getIndex(OFFSET + 3, 14);
|
||||
}
|
||||
|
||||
public void setCollarColor(int value) {
|
||||
super.metadata.setIndex((byte) 21, Metadata.VarInt(value));
|
||||
super.metadata.setIndex(OFFSET + 3, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
public enum Color {
|
||||
|
@ -2,9 +2,12 @@ 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;
|
||||
|
||||
public class ParrotMeta extends TameableAnimalMeta {
|
||||
public static final byte OFFSET = TameableAnimalMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public ParrotMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
@ -12,11 +15,11 @@ public class ParrotMeta extends TameableAnimalMeta {
|
||||
|
||||
@NotNull
|
||||
public Color getColor() {
|
||||
return Color.VALUES[super.metadata.getIndex((byte) 18, 0)];
|
||||
return Color.VALUES[super.metadata.getIndex(OFFSET, 0)];
|
||||
}
|
||||
|
||||
public void setColor(@NotNull Color value) {
|
||||
super.metadata.setIndex((byte) 18, Metadata.VarInt(value.ordinal()));
|
||||
super.metadata.setIndex(OFFSET, Metadata.VarInt(value.ordinal()));
|
||||
}
|
||||
|
||||
public enum Color {
|
||||
|
@ -8,8 +8,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.UUID;
|
||||
|
||||
public class TameableAnimalMeta extends AnimalMeta {
|
||||
|
||||
private final static byte MASK_INDEX = 16;
|
||||
public static final byte OFFSET = AnimalMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 2;
|
||||
|
||||
private final static byte SITTING_BIT = 0x01;
|
||||
private final static byte TAMED_BIT = 0x04;
|
||||
@ -19,28 +19,28 @@ public class TameableAnimalMeta extends AnimalMeta {
|
||||
}
|
||||
|
||||
public boolean isSitting() {
|
||||
return getMaskBit(MASK_INDEX, SITTING_BIT);
|
||||
return getMaskBit(OFFSET, SITTING_BIT);
|
||||
}
|
||||
|
||||
public void setSitting(boolean value) {
|
||||
setMaskBit(MASK_INDEX, SITTING_BIT, value);
|
||||
setMaskBit(OFFSET, SITTING_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isTamed() {
|
||||
return getMaskBit(MASK_INDEX, TAMED_BIT);
|
||||
return getMaskBit(OFFSET, TAMED_BIT);
|
||||
}
|
||||
|
||||
public void setTamed(boolean value) {
|
||||
setMaskBit(MASK_INDEX, TAMED_BIT, value);
|
||||
setMaskBit(OFFSET, TAMED_BIT, value);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public UUID getOwner() {
|
||||
return super.metadata.getIndex((byte) 17, null);
|
||||
return super.metadata.getIndex(OFFSET + 1, null);
|
||||
}
|
||||
|
||||
public void setOwner(@NotNull UUID value) {
|
||||
super.metadata.setIndex((byte) 17, Metadata.OptUUID(value));
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.OptUUID(value));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,33 +5,35 @@ import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class WolfMeta extends TameableAnimalMeta {
|
||||
public static final byte OFFSET = TameableAnimalMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 3;
|
||||
|
||||
public WolfMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean isBegging() {
|
||||
return super.metadata.getIndex((byte) 18, false);
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
}
|
||||
|
||||
public void setBegging(boolean value) {
|
||||
super.metadata.setIndex((byte) 18, Metadata.Boolean(value));
|
||||
super.metadata.setIndex(OFFSET, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
public int getCollarColor() {
|
||||
return super.metadata.getIndex((byte) 19, 14);
|
||||
return super.metadata.getIndex(OFFSET + 1, 14);
|
||||
}
|
||||
|
||||
public void setCollarColor(int value) {
|
||||
super.metadata.setIndex((byte) 19, Metadata.VarInt(value));
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
public int getAngerTime() {
|
||||
return super.metadata.getIndex((byte) 20, 0);
|
||||
return super.metadata.getIndex(OFFSET + 2, 0);
|
||||
}
|
||||
|
||||
public void setAngerTime(int value) {
|
||||
super.metadata.setIndex((byte) 20, Metadata.VarInt(value));
|
||||
super.metadata.setIndex(OFFSET + 2, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,11 +3,12 @@ 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 net.minestom.server.entity.metadata.animal.tameable.TameableAnimalMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AbstractArrowMeta extends EntityMeta {
|
||||
|
||||
private final static byte MASK_INDEX = 7;
|
||||
public static final byte OFFSET = EntityMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 2;
|
||||
|
||||
private final static byte CRITICAL_BIT = 0x01;
|
||||
private final static byte NO_CLIP_BIT = 0x01;
|
||||
@ -17,27 +18,27 @@ public class AbstractArrowMeta extends EntityMeta {
|
||||
}
|
||||
|
||||
public boolean isCritical() {
|
||||
return getMaskBit(MASK_INDEX, CRITICAL_BIT);
|
||||
return getMaskBit(OFFSET, CRITICAL_BIT);
|
||||
}
|
||||
|
||||
public void setCritical(boolean value) {
|
||||
setMaskBit(MASK_INDEX, CRITICAL_BIT, value);
|
||||
setMaskBit(OFFSET, CRITICAL_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isNoClip() {
|
||||
return getMaskBit(MASK_INDEX, NO_CLIP_BIT);
|
||||
return getMaskBit(OFFSET, NO_CLIP_BIT);
|
||||
}
|
||||
|
||||
public void setNoClip(boolean value) {
|
||||
setMaskBit(MASK_INDEX, NO_CLIP_BIT, value);
|
||||
setMaskBit(OFFSET, NO_CLIP_BIT, value);
|
||||
}
|
||||
|
||||
public byte getPiercingLevel() {
|
||||
return super.metadata.getIndex((byte) 8, (byte) 0);
|
||||
return super.metadata.getIndex(OFFSET + 1, (byte) 0);
|
||||
}
|
||||
|
||||
public void setPiercingLevel(byte value) {
|
||||
super.metadata.setIndex((byte) 8, Metadata.Byte(value));
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.Byte(value));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,10 +4,13 @@ import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.metadata.ObjectDataProvider;
|
||||
import net.minestom.server.entity.metadata.ProjectileMeta;
|
||||
import net.minestom.server.entity.metadata.animal.tameable.TameableAnimalMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class ArrowMeta extends AbstractArrowMeta implements ObjectDataProvider, ProjectileMeta {
|
||||
public static final byte OFFSET = AbstractArrowMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
private Entity shooter;
|
||||
|
||||
@ -16,11 +19,11 @@ public class ArrowMeta extends AbstractArrowMeta implements ObjectDataProvider,
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return super.metadata.getIndex((byte) 9, -1);
|
||||
return super.metadata.getIndex(OFFSET, -1);
|
||||
}
|
||||
|
||||
public void setColor(int value) {
|
||||
super.metadata.setIndex((byte) 9, Metadata.VarInt(value));
|
||||
super.metadata.setIndex(OFFSET, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -8,6 +8,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class SpectralArrowMeta extends AbstractArrowMeta implements ObjectDataProvider, ProjectileMeta {
|
||||
public static final byte OFFSET = AbstractArrowMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
private Entity shooter;
|
||||
|
||||
|
@ -5,25 +5,27 @@ import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ThrownTridentMeta extends AbstractArrowMeta {
|
||||
public static final byte OFFSET = AbstractArrowMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 2;
|
||||
|
||||
public ThrownTridentMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public int getLoyaltyLevel() {
|
||||
return super.metadata.getIndex((byte) 9, 0);
|
||||
return super.metadata.getIndex(OFFSET, 0);
|
||||
}
|
||||
|
||||
public void setLoyaltyLevel(int value) {
|
||||
super.metadata.setIndex((byte) 9, Metadata.VarInt(value));
|
||||
super.metadata.setIndex(OFFSET, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
public boolean isHasEnchantmentGlint() {
|
||||
return super.metadata.getIndex((byte) 10, false);
|
||||
return super.metadata.getIndex(OFFSET + 1, false);
|
||||
}
|
||||
|
||||
public void setHasEnchantmentGlint(boolean value) {
|
||||
super.metadata.setIndex((byte) 10, Metadata.Boolean(value));
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,9 +3,12 @@ package net.minestom.server.entity.metadata.flying;
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.metadata.MobMeta;
|
||||
import net.minestom.server.entity.metadata.arrow.AbstractArrowMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class FlyingMeta extends MobMeta {
|
||||
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
protected FlyingMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
|
@ -2,20 +2,23 @@ package net.minestom.server.entity.metadata.flying;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.metadata.MobMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class GhastMeta extends FlyingMeta {
|
||||
public static final byte OFFSET = FlyingMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public GhastMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean isAttacking() {
|
||||
return super.metadata.getIndex((byte) 15, false);
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
}
|
||||
|
||||
public void setAttacking(boolean value) {
|
||||
super.metadata.setIndex((byte) 15, Metadata.Boolean(value));
|
||||
super.metadata.setIndex(OFFSET, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,20 +2,23 @@ package net.minestom.server.entity.metadata.flying;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.metadata.MobMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PhantomMeta extends FlyingMeta {
|
||||
public static final byte OFFSET = FlyingMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public PhantomMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return super.metadata.getIndex((byte) 15, 0);
|
||||
return super.metadata.getIndex(OFFSET, 0);
|
||||
}
|
||||
|
||||
public void setSize(int value) {
|
||||
super.metadata.setIndex((byte) 15, Metadata.VarInt(value));
|
||||
super.metadata.setIndex(OFFSET, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,10 +2,13 @@ package net.minestom.server.entity.metadata.golem;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.metadata.MobMeta;
|
||||
import net.minestom.server.entity.metadata.PathfinderMobMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AbstractGolemMeta extends PathfinderMobMeta {
|
||||
public static final byte OFFSET = PathfinderMobMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
protected AbstractGolemMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
|
@ -2,11 +2,12 @@ package net.minestom.server.entity.metadata.golem;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.metadata.MobMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class IronGolemMeta extends AbstractGolemMeta {
|
||||
|
||||
private final static byte MASK_INDEX = 15;
|
||||
public static final byte OFFSET = AbstractGolemMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
private final static byte PLAYER_CREATED_BIT = 0x01;
|
||||
|
||||
@ -15,11 +16,11 @@ public class IronGolemMeta extends AbstractGolemMeta {
|
||||
}
|
||||
|
||||
public boolean isPlayerCreated() {
|
||||
return getMaskBit(MASK_INDEX, PLAYER_CREATED_BIT);
|
||||
return getMaskBit(OFFSET, PLAYER_CREATED_BIT);
|
||||
}
|
||||
|
||||
public void setPlayerCreated(boolean value) {
|
||||
setMaskBit(MASK_INDEX, PLAYER_CREATED_BIT, value);
|
||||
setMaskBit(OFFSET, PLAYER_CREATED_BIT, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,41 +7,43 @@ import net.minestom.server.utils.Direction;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ShulkerMeta extends AbstractGolemMeta {
|
||||
public static final byte OFFSET = AbstractGolemMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 4;
|
||||
|
||||
public ShulkerMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public Direction getAttachFace() {
|
||||
return super.metadata.getIndex((byte) 15, Direction.DOWN);
|
||||
return super.metadata.getIndex(OFFSET, Direction.DOWN);
|
||||
}
|
||||
|
||||
public void setAttachFace(Direction value) {
|
||||
super.metadata.setIndex((byte) 15, Metadata.Direction(value));
|
||||
super.metadata.setIndex(OFFSET, Metadata.Direction(value));
|
||||
}
|
||||
|
||||
public BlockPosition getAttachmentPosition() {
|
||||
return super.metadata.getIndex((byte) 16, null);
|
||||
return super.metadata.getIndex(OFFSET + 1, null);
|
||||
}
|
||||
|
||||
public void setAttachmentPosition(BlockPosition value) {
|
||||
super.metadata.setIndex((byte) 16, Metadata.OptPosition(value));
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.OptPosition(value));
|
||||
}
|
||||
|
||||
public byte getShieldHeight() {
|
||||
return super.metadata.getIndex((byte) 17, (byte) 0);
|
||||
return super.metadata.getIndex(OFFSET + 2, (byte) 0);
|
||||
}
|
||||
|
||||
public void setShieldHeight(byte value) {
|
||||
super.metadata.setIndex((byte) 17, Metadata.Byte(value));
|
||||
super.metadata.setIndex(OFFSET + 2, Metadata.Byte(value));
|
||||
}
|
||||
|
||||
public byte getColor() {
|
||||
return super.metadata.getIndex((byte) 18, (byte) 10);
|
||||
return super.metadata.getIndex(OFFSET + 3, (byte) 10);
|
||||
}
|
||||
|
||||
public void setColor(byte value) {
|
||||
super.metadata.setIndex((byte) 18, Metadata.Byte(value));
|
||||
super.metadata.setIndex(OFFSET + 3, Metadata.Byte(value));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,17 +5,19 @@ import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SnowGolemMeta extends AbstractGolemMeta {
|
||||
public static final byte OFFSET = AbstractGolemMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public SnowGolemMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean isHasPumpkinHat() {
|
||||
return super.metadata.getIndex((byte) 15, (byte) 0x10) == (byte) 0x10;
|
||||
return super.metadata.getIndex(OFFSET, (byte) 0x10) == (byte) 0x10;
|
||||
}
|
||||
|
||||
public void setHasPumpkinHat(boolean value) {
|
||||
super.metadata.setIndex((byte) 15, Metadata.Byte(value ? (byte) 0x10 : (byte) 0x00));
|
||||
super.metadata.setIndex(OFFSET, Metadata.Byte(value ? (byte) 0x10 : (byte) 0x00));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,6 +6,8 @@ import net.minestom.server.item.Material;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EyeOfEnderMeta extends ItemContainingMeta {
|
||||
public static final byte OFFSET = ItemContainingMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public EyeOfEnderMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata, Material.ENDER_EYE);
|
||||
|
@ -4,11 +4,14 @@ import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.metadata.ObjectDataProvider;
|
||||
import net.minestom.server.entity.metadata.ProjectileMeta;
|
||||
import net.minestom.server.entity.metadata.golem.AbstractGolemMeta;
|
||||
import net.minestom.server.item.Material;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class FireballMeta extends ItemContainingMeta implements ObjectDataProvider, ProjectileMeta {
|
||||
public static final byte OFFSET = ItemContainingMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
private Entity shooter;
|
||||
|
||||
|
@ -3,11 +3,14 @@ package net.minestom.server.entity.metadata.item;
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.metadata.EntityMeta;
|
||||
import net.minestom.server.entity.metadata.golem.AbstractGolemMeta;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import net.minestom.server.item.Material;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
class ItemContainingMeta extends EntityMeta {
|
||||
public static final byte OFFSET = EntityMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
private final ItemStack defaultItem;
|
||||
|
||||
@ -18,11 +21,11 @@ class ItemContainingMeta extends EntityMeta {
|
||||
|
||||
@NotNull
|
||||
public ItemStack getItem() {
|
||||
return super.metadata.getIndex((byte) 7, this.defaultItem);
|
||||
return super.metadata.getIndex(OFFSET, this.defaultItem);
|
||||
}
|
||||
|
||||
public void setItem(@NotNull ItemStack item) {
|
||||
super.metadata.setIndex((byte) 7, Metadata.Slot(item));
|
||||
super.metadata.setIndex(OFFSET, Metadata.Slot(item));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,6 +7,8 @@ import net.minestom.server.item.Material;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ItemEntityMeta extends ItemContainingMeta implements ObjectDataProvider {
|
||||
public static final byte OFFSET = ItemContainingMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public ItemEntityMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata, Material.AIR);
|
||||
|
@ -9,6 +9,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class SmallFireballMeta extends ItemContainingMeta implements ObjectDataProvider, ProjectileMeta {
|
||||
public static final byte OFFSET = ItemContainingMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
private Entity shooter;
|
||||
|
||||
|
@ -6,6 +6,8 @@ import net.minestom.server.item.Material;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SnowballMeta extends ItemContainingMeta {
|
||||
public static final byte OFFSET = ItemContainingMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public SnowballMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata, Material.SNOWBALL);
|
||||
|
@ -6,6 +6,8 @@ import net.minestom.server.item.Material;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ThrownEggMeta extends ItemContainingMeta {
|
||||
public static final byte OFFSET = ItemContainingMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public ThrownEggMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata, Material.EGG);
|
||||
|
@ -6,6 +6,8 @@ import net.minestom.server.item.Material;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ThrownEnderPearlMeta extends ItemContainingMeta {
|
||||
public static final byte OFFSET = ItemContainingMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public ThrownEnderPearlMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata, Material.ENDER_PEARL);
|
||||
|
@ -6,6 +6,8 @@ import net.minestom.server.item.Material;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ThrownExperienceBottleMeta extends ItemContainingMeta {
|
||||
public static final byte OFFSET = ItemContainingMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public ThrownExperienceBottleMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata, Material.EXPERIENCE_BOTTLE);
|
||||
|
@ -6,6 +6,8 @@ import net.minestom.server.item.Material;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ThrownPotionMeta extends ItemContainingMeta {
|
||||
public static final byte OFFSET = ItemContainingMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public ThrownPotionMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata, Material.AIR);
|
||||
|
@ -5,6 +5,8 @@ import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractMinecartContainerMeta extends AbstractMinecartMeta {
|
||||
public static final byte OFFSET = AbstractMinecartMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
protected AbstractMinecartContainerMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
|
@ -7,50 +7,52 @@ import net.minestom.server.entity.metadata.ObjectDataProvider;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractMinecartMeta extends EntityMeta implements ObjectDataProvider {
|
||||
public static final byte OFFSET = EntityMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 6;
|
||||
|
||||
protected AbstractMinecartMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public int getShakingPower() {
|
||||
return super.metadata.getIndex((byte) 7, 0);
|
||||
return super.metadata.getIndex(OFFSET, 0);
|
||||
}
|
||||
|
||||
public void setShakingPower(int value) {
|
||||
super.metadata.setIndex((byte) 7, Metadata.VarInt(value));
|
||||
super.metadata.setIndex(OFFSET, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
public int getShakingDirection() {
|
||||
return super.metadata.getIndex((byte) 8, 1);
|
||||
return super.metadata.getIndex(OFFSET + 1, 1);
|
||||
}
|
||||
|
||||
public void setShakingDirection(int value) {
|
||||
super.metadata.setIndex((byte) 8, Metadata.VarInt(value));
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
public float getShakingMultiplier() {
|
||||
return super.metadata.getIndex((byte) 9, 0F);
|
||||
return super.metadata.getIndex(OFFSET + 2, 0F);
|
||||
}
|
||||
|
||||
public void setShakingMultiplier(float value) {
|
||||
super.metadata.setIndex((byte) 9, Metadata.Float(value));
|
||||
super.metadata.setIndex(OFFSET + 2, Metadata.Float(value));
|
||||
}
|
||||
|
||||
public int getCustomBlockIdAndDamage() {
|
||||
return super.metadata.getIndex((byte) 10, 0);
|
||||
return super.metadata.getIndex(OFFSET + 3, 0);
|
||||
}
|
||||
|
||||
public void setCustomBlockIdAndDamage(int value) {
|
||||
super.metadata.setIndex((byte) 10, Metadata.VarInt(value));
|
||||
super.metadata.setIndex(OFFSET + 3, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
// in 16th of a block
|
||||
public int getCustomBlockYPosition() {
|
||||
return super.metadata.getIndex((byte) 11, 6);
|
||||
return super.metadata.getIndex(OFFSET + 4, 6);
|
||||
}
|
||||
|
||||
public void setCustomBlockYPosition(int value) {
|
||||
super.metadata.setIndex((byte) 11, Metadata.VarInt(value));
|
||||
super.metadata.setIndex(OFFSET + 4, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,6 +5,8 @@ import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ChestMinecartMeta extends AbstractMinecartContainerMeta {
|
||||
public static final byte OFFSET = AbstractMinecartContainerMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public ChestMinecartMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
|
@ -7,6 +7,8 @@ import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CommandBlockMinecartMeta extends AbstractMinecartMeta {
|
||||
public static final byte OFFSET = AbstractMinecartMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 2;
|
||||
|
||||
public CommandBlockMinecartMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
@ -14,11 +16,11 @@ public class CommandBlockMinecartMeta extends AbstractMinecartMeta {
|
||||
|
||||
@NotNull
|
||||
public String getCommand() {
|
||||
return super.metadata.getIndex((byte) 13, "");
|
||||
return super.metadata.getIndex(OFFSET, "");
|
||||
}
|
||||
|
||||
public void setCommand(@NotNull String value) {
|
||||
super.metadata.setIndex((byte) 13, Metadata.String(value));
|
||||
super.metadata.setIndex(OFFSET, Metadata.String(value));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -32,7 +34,7 @@ public class CommandBlockMinecartMeta extends AbstractMinecartMeta {
|
||||
|
||||
@NotNull
|
||||
public Component getLastOutput() {
|
||||
return super.metadata.getIndex((byte) 14, Component.empty());
|
||||
return super.metadata.getIndex(OFFSET + 1, Component.empty());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -44,7 +46,7 @@ public class CommandBlockMinecartMeta extends AbstractMinecartMeta {
|
||||
}
|
||||
|
||||
public void setLastOutput(@NotNull Component value) {
|
||||
super.metadata.setIndex((byte) 14, Metadata.Chat(value));
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.Chat(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,17 +5,19 @@ import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class FurnaceMinecartMeta extends AbstractMinecartMeta {
|
||||
public static final byte OFFSET = AbstractMinecartMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public FurnaceMinecartMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean isHasFuel() {
|
||||
return super.metadata.getIndex((byte) 13, false);
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
}
|
||||
|
||||
public void setHasFuel(boolean value) {
|
||||
super.metadata.setIndex((byte) 13, Metadata.Boolean(value));
|
||||
super.metadata.setIndex(OFFSET, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,6 +5,8 @@ import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class HopperMinecartMeta extends AbstractMinecartContainerMeta {
|
||||
public static final byte OFFSET = AbstractMinecartContainerMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public HopperMinecartMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
|
@ -5,6 +5,8 @@ import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MinecartMeta extends AbstractMinecartMeta {
|
||||
public static final byte OFFSET = AbstractMinecartMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public MinecartMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
|
@ -5,6 +5,8 @@ import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SpawnerMinecartMeta extends AbstractMinecartMeta {
|
||||
public static final byte OFFSET = AbstractMinecartMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public SpawnerMinecartMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
|
@ -5,6 +5,8 @@ import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class TntMinecartMeta extends AbstractMinecartMeta {
|
||||
public static final byte OFFSET = AbstractMinecartMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public TntMinecartMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
|
@ -5,17 +5,19 @@ import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class BasePiglinMeta extends MonsterMeta {
|
||||
public static final byte OFFSET = MonsterMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
protected BasePiglinMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean isImmuneToZombification() {
|
||||
return super.metadata.getIndex((byte) 15, false);
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
}
|
||||
|
||||
public void setImmuneToZombification(boolean value) {
|
||||
super.metadata.setIndex((byte) 15, Metadata.Boolean(value));
|
||||
super.metadata.setIndex(OFFSET, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class BlazeMeta extends MonsterMeta {
|
||||
|
||||
private final static byte MASK_INDEX = 15;
|
||||
public static final byte OFFSET = MonsterMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
private final static byte ON_FIRE_BIT = 0x01;
|
||||
|
||||
@ -15,11 +15,11 @@ public class BlazeMeta extends MonsterMeta {
|
||||
}
|
||||
|
||||
public boolean isOnFire() {
|
||||
return getMaskBit(MASK_INDEX, ON_FIRE_BIT);
|
||||
return getMaskBit(OFFSET, ON_FIRE_BIT);
|
||||
}
|
||||
|
||||
public void setOnFire(boolean value) {
|
||||
setMaskBit(MASK_INDEX, ON_FIRE_BIT, value);
|
||||
setMaskBit(OFFSET, ON_FIRE_BIT, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,8 @@ import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CaveSpiderMeta extends SpiderMeta {
|
||||
public static final byte OFFSET = SpiderMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public CaveSpiderMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
|
@ -5,6 +5,8 @@ import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CreeperMeta extends MonsterMeta {
|
||||
public static final byte OFFSET = MonsterMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 3;
|
||||
|
||||
public CreeperMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
@ -12,28 +14,28 @@ public class CreeperMeta extends MonsterMeta {
|
||||
|
||||
@NotNull
|
||||
public State getState() {
|
||||
int id = super.metadata.getIndex((byte) 15, -1);
|
||||
int id = super.metadata.getIndex(OFFSET, -1);
|
||||
return id == -1 ? State.IDLE : State.FUSE;
|
||||
}
|
||||
|
||||
public void setState(@NotNull State value) {
|
||||
super.metadata.setIndex((byte) 15, Metadata.VarInt(value == State.IDLE ? -1 : 1));
|
||||
super.metadata.setIndex(OFFSET, Metadata.VarInt(value == State.IDLE ? -1 : 1));
|
||||
}
|
||||
|
||||
public boolean isCharged() {
|
||||
return super.metadata.getIndex((byte) 16, false);
|
||||
return super.metadata.getIndex(OFFSET + 1, false);
|
||||
}
|
||||
|
||||
public void setCharged(boolean value) {
|
||||
super.metadata.setIndex((byte) 16, Metadata.Boolean(value));
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
public boolean isIgnited() {
|
||||
return super.metadata.getIndex((byte) 17, false);
|
||||
return super.metadata.getIndex(OFFSET + 2, false);
|
||||
}
|
||||
|
||||
public void setIgnited(boolean value) {
|
||||
super.metadata.setIndex((byte) 17, Metadata.Boolean(value));
|
||||
super.metadata.setIndex(OFFSET + 2, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
public enum State {
|
||||
|
@ -5,6 +5,8 @@ import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ElderGuardianMeta extends GuardianMeta {
|
||||
public static final byte OFFSET = GuardianMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public ElderGuardianMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
|
@ -6,33 +6,35 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class EndermanMeta extends MonsterMeta {
|
||||
public static final byte OFFSET = MonsterMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 3;
|
||||
|
||||
public EndermanMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public Integer getCarriedBlockID() {
|
||||
return super.metadata.getIndex((byte) 15, null);
|
||||
return super.metadata.getIndex(OFFSET, null);
|
||||
}
|
||||
|
||||
public void setCarriedBlockID(@Nullable Integer value) {
|
||||
super.metadata.setIndex((byte) 15, Metadata.OptBlockID(value));
|
||||
super.metadata.setIndex(OFFSET, Metadata.OptBlockID(value));
|
||||
}
|
||||
|
||||
public boolean isScreaming() {
|
||||
return super.metadata.getIndex((byte) 16, false);
|
||||
return super.metadata.getIndex(OFFSET + 1, false);
|
||||
}
|
||||
|
||||
public void setScreaming(boolean value) {
|
||||
super.metadata.setIndex((byte) 16, Metadata.Boolean(value));
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
public boolean isStaring() {
|
||||
return super.metadata.getIndex((byte) 17, false);
|
||||
return super.metadata.getIndex(OFFSET + 2, false);
|
||||
}
|
||||
|
||||
public void setStaring(boolean value) {
|
||||
super.metadata.setIndex((byte) 17, Metadata.Boolean(value));
|
||||
super.metadata.setIndex(OFFSET + 2, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,8 @@ import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EndermiteMeta extends MonsterMeta {
|
||||
public static final byte OFFSET = MonsterMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public EndermiteMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
|
@ -5,6 +5,8 @@ import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class GiantMeta extends MonsterMeta {
|
||||
public static final byte OFFSET = MonsterMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public GiantMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
|
@ -5,6 +5,8 @@ import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class GuardianMeta extends MonsterMeta {
|
||||
public static final byte OFFSET = MonsterMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 2;
|
||||
|
||||
private Entity target;
|
||||
|
||||
@ -13,11 +15,11 @@ public class GuardianMeta extends MonsterMeta {
|
||||
}
|
||||
|
||||
public boolean isRetractingSpikes() {
|
||||
return super.metadata.getIndex((byte) 15, false);
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
}
|
||||
|
||||
public void setRetractingSpikes(boolean retractingSpikes) {
|
||||
super.metadata.setIndex((byte) 15, Metadata.Boolean(retractingSpikes));
|
||||
super.metadata.setIndex(OFFSET, Metadata.Boolean(retractingSpikes));
|
||||
}
|
||||
|
||||
public Entity getTarget() {
|
||||
@ -26,7 +28,7 @@ public class GuardianMeta extends MonsterMeta {
|
||||
|
||||
public void setTarget(@NotNull Entity target) {
|
||||
this.target = target;
|
||||
super.metadata.setIndex((byte) 16, Metadata.VarInt(target.getEntityId()));
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.VarInt(target.getEntityId()));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,9 +3,12 @@ package net.minestom.server.entity.metadata.monster;
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Metadata;
|
||||
import net.minestom.server.entity.metadata.PathfinderMobMeta;
|
||||
import net.minestom.server.entity.metadata.minecart.AbstractMinecartMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MonsterMeta extends PathfinderMobMeta {
|
||||
public static final byte OFFSET = PathfinderMobMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
protected MonsterMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
|
@ -5,6 +5,8 @@ import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PiglinBruteMeta extends BasePiglinMeta {
|
||||
public static final byte OFFSET = BasePiglinMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public PiglinBruteMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
|
@ -6,13 +6,15 @@ import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PiglinMeta extends BasePiglinMeta {
|
||||
public static final byte OFFSET = BasePiglinMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 3;
|
||||
|
||||
public PiglinMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean isBaby() {
|
||||
return super.metadata.getIndex((byte) 16, false);
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
}
|
||||
|
||||
public void setBaby(boolean value) {
|
||||
@ -25,23 +27,23 @@ public class PiglinMeta extends BasePiglinMeta {
|
||||
} else {
|
||||
setBoundingBox(bb.getWidth() * 2, bb.getHeight() * 2);
|
||||
}
|
||||
super.metadata.setIndex((byte) 16, Metadata.Boolean(value));
|
||||
super.metadata.setIndex(OFFSET, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
public boolean isChargingCrossbow() {
|
||||
return super.metadata.getIndex((byte) 17, false);
|
||||
return super.metadata.getIndex(OFFSET + 1, false);
|
||||
}
|
||||
|
||||
public void setChargingCrossbow(boolean value) {
|
||||
super.metadata.setIndex((byte) 17, Metadata.Boolean(value));
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
public boolean isDancing() {
|
||||
return super.metadata.getIndex((byte) 18, false);
|
||||
return super.metadata.getIndex(OFFSET + 2, false);
|
||||
}
|
||||
|
||||
public void setDancing(boolean value) {
|
||||
super.metadata.setIndex((byte) 18, Metadata.Boolean(value));
|
||||
super.metadata.setIndex(OFFSET + 2, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,8 @@ import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SilverfishMeta extends MonsterMeta {
|
||||
public static final byte OFFSET = MonsterMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public SilverfishMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
|
@ -5,8 +5,8 @@ import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SpiderMeta extends MonsterMeta {
|
||||
|
||||
private final static byte MASK_INDEX = 15;
|
||||
public static final byte OFFSET = MonsterMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
private final static byte CLIMBING_BIT = 0x01;
|
||||
|
||||
@ -15,11 +15,11 @@ public class SpiderMeta extends MonsterMeta {
|
||||
}
|
||||
|
||||
public boolean isClimbing() {
|
||||
return getMaskBit(MASK_INDEX, CLIMBING_BIT);
|
||||
return getMaskBit(OFFSET, CLIMBING_BIT);
|
||||
}
|
||||
|
||||
public void setClimbing(boolean value) {
|
||||
setMaskBit(MASK_INDEX, CLIMBING_BIT, value);
|
||||
setMaskBit(OFFSET, CLIMBING_BIT, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class VexMeta extends MonsterMeta {
|
||||
|
||||
private final static byte MASK_INDEX = 15;
|
||||
public static final byte OFFSET = MonsterMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
private final static byte ATTACKING_BIT = 0x01;
|
||||
|
||||
@ -15,11 +15,11 @@ public class VexMeta extends MonsterMeta {
|
||||
}
|
||||
|
||||
public boolean isAttacking() {
|
||||
return getMaskBit(MASK_INDEX, ATTACKING_BIT);
|
||||
return getMaskBit(OFFSET, ATTACKING_BIT);
|
||||
}
|
||||
|
||||
public void setAttacking(boolean value) {
|
||||
setMaskBit(MASK_INDEX, ATTACKING_BIT, value);
|
||||
setMaskBit(OFFSET, ATTACKING_BIT, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,6 +6,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class WitherMeta extends MonsterMeta {
|
||||
public static final byte OFFSET = MonsterMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 4;
|
||||
|
||||
private Entity centerHead;
|
||||
private Entity leftHead;
|
||||
@ -22,7 +24,7 @@ public class WitherMeta extends MonsterMeta {
|
||||
|
||||
public void setCenterHead(@Nullable Entity value) {
|
||||
this.centerHead = value;
|
||||
super.metadata.setIndex((byte) 15, Metadata.VarInt(value == null ? 0 : value.getEntityId()));
|
||||
super.metadata.setIndex(OFFSET, Metadata.VarInt(value == null ? 0 : value.getEntityId()));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@ -32,7 +34,7 @@ public class WitherMeta extends MonsterMeta {
|
||||
|
||||
public void setLeftHead(@Nullable Entity value) {
|
||||
this.leftHead = value;
|
||||
super.metadata.setIndex((byte) 16, Metadata.VarInt(value == null ? 0 : value.getEntityId()));
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.VarInt(value == null ? 0 : value.getEntityId()));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@ -42,15 +44,15 @@ public class WitherMeta extends MonsterMeta {
|
||||
|
||||
public void setRightHead(@Nullable Entity value) {
|
||||
this.rightHead = value;
|
||||
super.metadata.setIndex((byte) 17, Metadata.VarInt(value == null ? 0 : value.getEntityId()));
|
||||
super.metadata.setIndex(OFFSET + 2, Metadata.VarInt(value == null ? 0 : value.getEntityId()));
|
||||
}
|
||||
|
||||
public int getInvulnerableTime() {
|
||||
return super.metadata.getIndex((byte) 18, 0);
|
||||
return super.metadata.getIndex(OFFSET + 3, 0);
|
||||
}
|
||||
|
||||
public void setInvulnerableTime(int value) {
|
||||
super.metadata.setIndex((byte) 18, Metadata.VarInt(value));
|
||||
super.metadata.setIndex(OFFSET + 3, Metadata.VarInt(value));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,13 +6,15 @@ import net.minestom.server.entity.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ZoglinMeta extends MonsterMeta {
|
||||
public static final byte OFFSET = MonsterMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public ZoglinMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean isBaby() {
|
||||
return super.metadata.getIndex((byte) 15, false);
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
}
|
||||
|
||||
public void setBaby(boolean value) {
|
||||
@ -25,7 +27,7 @@ public class ZoglinMeta extends MonsterMeta {
|
||||
} else {
|
||||
setBoundingBox(bb.getWidth() * 2, bb.getHeight() * 2);
|
||||
}
|
||||
super.metadata.setIndex((byte) 15, Metadata.Boolean(value));
|
||||
super.metadata.setIndex(OFFSET, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,9 +2,12 @@ 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 AbstractIllagerMeta extends RaiderMeta {
|
||||
public static final byte OFFSET = RaiderMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
protected AbstractIllagerMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
|
@ -2,9 +2,12 @@ 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 EvokerMeta extends SpellcasterIllagerMeta {
|
||||
public static final byte OFFSET = SpellcasterIllagerMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public EvokerMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
|
@ -2,9 +2,12 @@ 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 IllusionerMeta extends SpellcasterIllagerMeta {
|
||||
public static final byte OFFSET = SpellcasterIllagerMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public IllusionerMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
|
@ -2,9 +2,12 @@ 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 PillagerMeta extends AbstractIllagerMeta {
|
||||
public static final byte OFFSET = AbstractIllagerMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public PillagerMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
|
@ -6,17 +6,19 @@ import net.minestom.server.entity.metadata.monster.MonsterMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class RaiderMeta extends MonsterMeta {
|
||||
public static final byte OFFSET = MonsterMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
protected RaiderMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean isCelebrating() {
|
||||
return super.metadata.getIndex((byte) 15, false);
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
}
|
||||
|
||||
public void setCelebrating(boolean value) {
|
||||
super.metadata.setIndex((byte) 15, Metadata.Boolean(value));
|
||||
super.metadata.setIndex(OFFSET, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,9 +2,12 @@ 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 RavagerMeta extends RaiderMeta {
|
||||
public static final byte OFFSET = RaiderMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public RavagerMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
|
@ -2,9 +2,12 @@ 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 SpellcasterIllagerMeta extends AbstractIllagerMeta {
|
||||
public static final byte OFFSET = AbstractIllagerMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
protected SpellcasterIllagerMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
@ -12,11 +15,11 @@ public class SpellcasterIllagerMeta extends AbstractIllagerMeta {
|
||||
|
||||
@NotNull
|
||||
public Spell getSpell() {
|
||||
return Spell.VALUES[super.metadata.getIndex((byte) 16, (byte) 0)];
|
||||
return Spell.VALUES[super.metadata.getIndex(OFFSET, (byte) 0)];
|
||||
}
|
||||
|
||||
public void setSpell(@NotNull Spell spell) {
|
||||
super.metadata.setIndex((byte) 16, Metadata.Byte((byte) spell.ordinal()));
|
||||
super.metadata.setIndex(OFFSET, Metadata.Byte((byte) spell.ordinal()));
|
||||
}
|
||||
|
||||
public enum Spell {
|
||||
|
@ -2,9 +2,12 @@ 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 VindicatorMeta extends AbstractIllagerMeta {
|
||||
public static final byte OFFSET = AbstractIllagerMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public VindicatorMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
|
@ -2,20 +2,23 @@ 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 WitchMeta extends RaiderMeta {
|
||||
public static final byte OFFSET = RaiderMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public WitchMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean isDrinkingPotion() {
|
||||
return super.metadata.getIndex((byte) 16, false);
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
}
|
||||
|
||||
public void setDrinkingPotion(boolean value) {
|
||||
super.metadata.setIndex((byte) 16, Metadata.Boolean(value));
|
||||
super.metadata.setIndex(OFFSET, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,6 +6,8 @@ import net.minestom.server.entity.metadata.monster.MonsterMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AbstractSkeletonMeta extends MonsterMeta {
|
||||
public static final byte OFFSET = MonsterMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
protected AbstractSkeletonMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
|
@ -2,9 +2,12 @@ package net.minestom.server.entity.metadata.monster.skeleton;
|
||||
|
||||
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 SkeletonMeta extends AbstractSkeletonMeta {
|
||||
public static final byte OFFSET = AbstractSkeletonMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public SkeletonMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
|
@ -2,9 +2,12 @@ package net.minestom.server.entity.metadata.monster.skeleton;
|
||||
|
||||
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 StrayMeta extends AbstractSkeletonMeta {
|
||||
public static final byte OFFSET = AbstractSkeletonMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public StrayMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
|
@ -2,9 +2,12 @@ package net.minestom.server.entity.metadata.monster.skeleton;
|
||||
|
||||
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 WitherSkeletonMeta extends AbstractSkeletonMeta {
|
||||
public static final byte OFFSET = AbstractSkeletonMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public WitherSkeletonMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
|
@ -2,9 +2,12 @@ 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.monster.MonsterMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class DrownedMeta extends ZombieMeta {
|
||||
public static final byte OFFSET = ZombieMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public DrownedMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
|
@ -2,9 +2,12 @@ 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.monster.MonsterMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class HuskMeta extends ZombieMeta {
|
||||
public static final byte OFFSET = ZombieMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public HuskMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
|
@ -7,13 +7,15 @@ import net.minestom.server.entity.metadata.monster.MonsterMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ZombieMeta extends MonsterMeta {
|
||||
public static final byte OFFSET = MonsterMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 3;
|
||||
|
||||
public ZombieMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean isBaby() {
|
||||
return super.metadata.getIndex((byte) 15, false);
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
}
|
||||
|
||||
public void setBaby(boolean value) {
|
||||
@ -26,15 +28,15 @@ public class ZombieMeta extends MonsterMeta {
|
||||
} else {
|
||||
setBoundingBox(bb.getWidth() * 2, bb.getHeight() * 2);
|
||||
}
|
||||
super.metadata.setIndex((byte) 15, Metadata.Boolean(value));
|
||||
super.metadata.setIndex(OFFSET, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
public boolean isBecomingDrowned() {
|
||||
return super.metadata.getIndex((byte) 17, false);
|
||||
return super.metadata.getIndex(OFFSET + 2, false);
|
||||
}
|
||||
|
||||
public void setBecomingDrowned(boolean value) {
|
||||
super.metadata.setIndex((byte) 17, Metadata.Boolean(value));
|
||||
super.metadata.setIndex(OFFSET + 2, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,25 +2,28 @@ 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.monster.MonsterMeta;
|
||||
import net.minestom.server.entity.metadata.villager.VillagerMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ZombieVillagerMeta extends ZombieMeta {
|
||||
public static final byte OFFSET = ZombieMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 2;
|
||||
|
||||
public ZombieVillagerMeta(@NotNull Entity entity, @NotNull Metadata metadata) {
|
||||
super(entity, metadata);
|
||||
}
|
||||
|
||||
public boolean isConverting() {
|
||||
return super.metadata.getIndex((byte) 18, false);
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
}
|
||||
|
||||
public void setConverting(boolean value) {
|
||||
super.metadata.setIndex((byte) 18, Metadata.Boolean(value));
|
||||
super.metadata.setIndex(OFFSET, Metadata.Boolean(value));
|
||||
}
|
||||
|
||||
public VillagerMeta.VillagerData getVillagerData() {
|
||||
int[] data = super.metadata.getIndex((byte) 17, null);
|
||||
int[] data = super.metadata.getIndex(OFFSET + 1, null);
|
||||
if (data == null) {
|
||||
return new VillagerMeta.VillagerData(VillagerMeta.Type.PLAINS, VillagerMeta.Profession.NONE, VillagerMeta.Level.NOVICE);
|
||||
}
|
||||
@ -28,7 +31,7 @@ public class ZombieVillagerMeta extends ZombieMeta {
|
||||
}
|
||||
|
||||
public void setVillagerData(VillagerMeta.VillagerData data) {
|
||||
super.metadata.setIndex((byte) 17, Metadata.VillagerData(
|
||||
super.metadata.setIndex(OFFSET + 1, Metadata.VillagerData(
|
||||
data.getType().ordinal(),
|
||||
data.getProfession().ordinal(),
|
||||
data.getLevel().ordinal() + 1
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user