diff --git a/src/autogenerated/java/net/minestom/server/entity/EntityType.java b/src/autogenerated/java/net/minestom/server/entity/EntityType.java index 868816d6a..a24392848 100644 --- a/src/autogenerated/java/net/minestom/server/entity/EntityType.java +++ b/src/autogenerated/java/net/minestom/server/entity/EntityType.java @@ -1,6 +1,7 @@ package net.minestom.server.entity; import net.minestom.server.entity.type.ambient.EntityBat; +import net.minestom.server.entity.type.ambient.EntityTraderLlama; import net.minestom.server.entity.type.ambient.EntityVillager; import net.minestom.server.entity.type.ambient.EntityWanderingTrader; import net.minestom.server.entity.type.animal.*; @@ -8,6 +9,7 @@ import net.minestom.server.entity.type.decoration.EntityArmorStand; import net.minestom.server.entity.type.monster.*; import net.minestom.server.entity.type.other.EntityAreaEffectCloud; import net.minestom.server.entity.type.other.EntityIronGolem; +import net.minestom.server.entity.type.other.EntityShulker; import net.minestom.server.entity.type.other.EntitySnowman; import net.minestom.server.entity.type.projectile.EntityArrow; import net.minestom.server.entity.type.projectile.EntityPotion; @@ -206,7 +208,7 @@ public enum EntityType { TRIDENT("minecraft:trident"), - TRADER_LLAMA("minecraft:trader_llama", EntityRaderLlama.class), + TRADER_LLAMA("minecraft:trader_llama", EntityTraderLlama.class), TROPICAL_FISH("minecraft:tropical_fish", EntityTropicalFish.class), diff --git a/src/main/java/net/minestom/server/entity/type/TameableAnimalCreature.java b/src/main/java/net/minestom/server/entity/type/TameableAnimalCreature.java new file mode 100644 index 000000000..dc400d050 --- /dev/null +++ b/src/main/java/net/minestom/server/entity/type/TameableAnimalCreature.java @@ -0,0 +1,74 @@ +package net.minestom.server.entity.type; + +import net.minestom.server.entity.EntityType; +import net.minestom.server.entity.Metadata; +import net.minestom.server.instance.Instance; +import net.minestom.server.utils.Position; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.UUID; + +/** + * Created by k.shandurenko on 23.02.2021 + */ +public class TameableAnimalCreature extends AgeableCreature implements TameableAnimal { + + private final static byte SITTING_BIT = 0x1; + private final static byte TAMED_BIT = 0x4; + + protected TameableAnimalCreature(@NotNull EntityType entityType, @NotNull Position spawnPosition) { + super(entityType, spawnPosition); + } + + protected TameableAnimalCreature(@NotNull EntityType entityType, @NotNull Position spawnPosition, @Nullable Instance instance) { + super(entityType, spawnPosition, instance); + } + + public boolean isSitting() { + return (getMask() & SITTING_BIT) != 0; + } + + public void setSitting(boolean value) { + modifyMask(SITTING_BIT, value); + } + + public boolean isTamed() { + return (getMask() & TAMED_BIT) != 0; + } + + public void setTamed(boolean value) { + modifyMask(TAMED_BIT, value); + } + + public UUID getOwner() { + return this.metadata.getIndex((byte) 17, null); + } + + public void setOwner(UUID value) { + this.metadata.setIndex((byte) 17, Metadata.OptUUID(value)); + } + + private byte getMask() { + return this.metadata.getIndex((byte) 16, (byte) 0); + } + + private void setMask(byte mask) { + this.metadata.setIndex((byte) 16, Metadata.Byte(mask)); + } + + private void modifyMask(byte bit, boolean value) { + byte mask = getMask(); + boolean isPresent = (mask & bit) == bit; + if (isPresent == value) { + return; + } + if (value) { + mask |= bit; + } else { + mask &= ~bit; + } + setMask(mask); + } + +} diff --git a/src/main/java/net/minestom/server/entity/type/ambient/EntityTraderLlama.java b/src/main/java/net/minestom/server/entity/type/ambient/EntityTraderLlama.java new file mode 100644 index 000000000..58d94de14 --- /dev/null +++ b/src/main/java/net/minestom/server/entity/type/ambient/EntityTraderLlama.java @@ -0,0 +1,25 @@ +package net.minestom.server.entity.type.ambient; + +import net.minestom.server.entity.EntityCreature; +import net.minestom.server.entity.EntityType; +import net.minestom.server.instance.Instance; +import net.minestom.server.utils.Position; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Created by k.shandurenko on 23.02.2021 + */ +public class EntityTraderLlama extends EntityCreature { + + public EntityTraderLlama(@NotNull Position spawnPosition) { + super(EntityType.TRADER_LLAMA, spawnPosition); + setBoundingBox(.9D, 1.87D, .9D); + } + + public EntityTraderLlama(@NotNull Position spawnPosition, @Nullable Instance instance) { + super(EntityType.TRADER_LLAMA, spawnPosition, instance); + setBoundingBox(.9D, 1.87D, .9D); + } + +} diff --git a/src/main/java/net/minestom/server/entity/type/ambient/EntityVillager.java b/src/main/java/net/minestom/server/entity/type/ambient/EntityVillager.java index e0374475b..ed644edcd 100644 --- a/src/main/java/net/minestom/server/entity/type/ambient/EntityVillager.java +++ b/src/main/java/net/minestom/server/entity/type/ambient/EntityVillager.java @@ -23,10 +23,12 @@ public class EntityVillager extends EntityAbstractVillager { EntityVillager(@NotNull EntityType entityType, @NotNull Position spawnPosition) { super(entityType, spawnPosition); + setBoundingBox(.6D, 1.95D, .6D); } EntityVillager(@NotNull EntityType entityType, @NotNull Position spawnPosition, @Nullable Instance instance) { super(entityType, spawnPosition, instance); + setBoundingBox(.6D, 1.95D, .6D); } public VillagerData getVillagerData() { diff --git a/src/main/java/net/minestom/server/entity/type/animal/EntityCat.java b/src/main/java/net/minestom/server/entity/type/animal/EntityCat.java index 4fd48e24e..c49b94e9f 100644 --- a/src/main/java/net/minestom/server/entity/type/animal/EntityCat.java +++ b/src/main/java/net/minestom/server/entity/type/animal/EntityCat.java @@ -1,13 +1,70 @@ package net.minestom.server.entity.type.animal; -import net.minestom.server.entity.EntityCreature; import net.minestom.server.entity.EntityType; -import net.minestom.server.entity.type.TameableAnimal; +import net.minestom.server.entity.Metadata; +import net.minestom.server.entity.type.TameableAnimalCreature; +import net.minestom.server.instance.Instance; import net.minestom.server.utils.Position; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; -public class EntityCat extends EntityCreature implements TameableAnimal { - public EntityCat(Position spawnPosition) { +public class EntityCat extends TameableAnimalCreature { + + public EntityCat(@NotNull Position spawnPosition) { super(EntityType.CAT, spawnPosition); - setBoundingBox(0.6f, 0.7f, 0.6f); + setBoundingBox(.6D, .7D, .6D); + } + + public EntityCat(@NotNull Position spawnPosition, @Nullable Instance instance) { + super(EntityType.CAT, spawnPosition, instance); + setBoundingBox(.6D, .7D, .6D); + } + + public Color getColor() { + return Color.VALUES[this.metadata.getIndex((byte) 18, 1)]; + } + + public void setColor(Color value) { + this.metadata.setIndex((byte) 18, Metadata.VarInt(value.ordinal())); + } + + public boolean isLying() { + return this.metadata.getIndex((byte) 19, false); + } + + public void setLying(boolean value) { + this.metadata.setIndex((byte) 19, Metadata.Boolean(value)); + } + + public boolean isRelaxed() { + return this.metadata.getIndex((byte) 20, false); + } + + public void setRelaxed(boolean value) { + this.metadata.setIndex((byte) 20, Metadata.Boolean(value)); + } + + public int getCollarColor() { + return this.metadata.getIndex((byte) 21, 14); + } + + public void setCollarColor(int value) { + this.metadata.setIndex((byte) 21, Metadata.VarInt(value)); + } + + public enum Color { + TABBY, + BLACK, + RED, + SIAMESE, + BRITISH_SHORTHAIR, + CALICO, + PERSIAN, + RAGDOLL, + WHITE, + JELLIE, + ALL_BLACK; + + private final static Color[] VALUES = values(); } } diff --git a/src/main/java/net/minestom/server/entity/type/animal/EntityHoglin.java b/src/main/java/net/minestom/server/entity/type/animal/EntityHoglin.java new file mode 100644 index 000000000..1d175d7d6 --- /dev/null +++ b/src/main/java/net/minestom/server/entity/type/animal/EntityHoglin.java @@ -0,0 +1,35 @@ +package net.minestom.server.entity.type.animal; + +import net.minestom.server.entity.EntityType; +import net.minestom.server.entity.Metadata; +import net.minestom.server.entity.type.AgeableCreature; +import net.minestom.server.entity.type.Animal; +import net.minestom.server.instance.Instance; +import net.minestom.server.utils.Position; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Created by k.shandurenko on 23.02.2021 + */ +public class EntityHoglin extends AgeableCreature implements Animal { + + public EntityHoglin(@NotNull Position spawnPosition) { + super(EntityType.HOGLIN, spawnPosition); + setBoundingBox(1.3965D, 1.4D, 1.3965D); + } + + public EntityHoglin(@NotNull Position spawnPosition, @Nullable Instance instance) { + super(EntityType.HOGLIN, spawnPosition, instance); + setBoundingBox(1.3965D, 1.4D, 1.3965D); + } + + public boolean isImmuneToZombification() { + return this.metadata.getIndex((byte) 16, false); + } + + public void setImmuneToZombification(boolean value) { + this.metadata.setIndex((byte) 16, Metadata.Boolean(value)); + } + +} diff --git a/src/main/java/net/minestom/server/entity/type/animal/EntityParrot.java b/src/main/java/net/minestom/server/entity/type/animal/EntityParrot.java new file mode 100644 index 000000000..9db9a1f8f --- /dev/null +++ b/src/main/java/net/minestom/server/entity/type/animal/EntityParrot.java @@ -0,0 +1,44 @@ +package net.minestom.server.entity.type.animal; + +import net.minestom.server.entity.EntityType; +import net.minestom.server.entity.Metadata; +import net.minestom.server.entity.type.TameableAnimalCreature; +import net.minestom.server.instance.Instance; +import net.minestom.server.utils.Position; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Created by k.shandurenko on 23.02.2021 + */ +public class EntityParrot extends TameableAnimalCreature { + + public EntityParrot(@NotNull Position spawnPosition) { + super(EntityType.PARROT, spawnPosition); + setBoundingBox(.5D, .9D, .5D); + } + + public EntityParrot(@NotNull Position spawnPosition, @Nullable Instance instance) { + super(EntityType.PARROT, spawnPosition, instance); + setBoundingBox(.5D, .9D, .5D); + } + + public Color getColor() { + return Color.VALUES[this.metadata.getIndex((byte) 18, 0)]; + } + + public void setColor(Color value) { + this.metadata.setIndex((byte) 18, Metadata.VarInt(value.ordinal())); + } + + public enum Color { + RED_BLUE, + BLUE, + GREEN, + YELLOW_BLUE, + GREY; + + private final static Color[] VALUES = values(); + } + +} diff --git a/src/main/java/net/minestom/server/entity/type/animal/EntitySheep.java b/src/main/java/net/minestom/server/entity/type/animal/EntitySheep.java new file mode 100644 index 000000000..75c6e7949 --- /dev/null +++ b/src/main/java/net/minestom/server/entity/type/animal/EntitySheep.java @@ -0,0 +1,66 @@ +package net.minestom.server.entity.type.animal; + +import net.minestom.server.entity.EntityType; +import net.minestom.server.entity.Metadata; +import net.minestom.server.entity.type.AgeableCreature; +import net.minestom.server.entity.type.Animal; +import net.minestom.server.instance.Instance; +import net.minestom.server.utils.Position; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Created by k.shandurenko on 23.02.2021 + */ +public class EntitySheep extends AgeableCreature implements Animal { + + public EntitySheep(@NotNull Position spawnPosition) { + super(EntityType.SHEEP, spawnPosition); + setBoundingBox(.9D, 1.3D, .9D); + } + + public EntitySheep(@NotNull Position spawnPosition, @Nullable Instance instance) { + super(EntityType.SHEEP, spawnPosition, instance); + setBoundingBox(.9D, 1.3D, .9D); + } + + public int getColor() { + return getMask() & 0x0F; + } + + public void setColor(byte color) { + byte before = getMask(); + byte mask = before; + mask &= ~0x0F; + mask |= (color & 0x0F); + if (mask != before) { + setMask(mask); + } + } + + public boolean isSheared() { + return (getMask() & 0x10) != 0; + } + + public void setSheared(boolean value) { + byte mask = getMask(); + if (((mask & 0x10) != 0) == value) { + return; + } + if (value) { + mask |= 0x10; + } else { + mask &= ~0x10; + } + setMask(mask); + } + + private byte getMask() { + return this.metadata.getIndex((byte) 16, (byte) 0); + } + + private void setMask(byte value) { + this.metadata.setIndex((byte) 16, Metadata.Byte(value)); + } + +} diff --git a/src/main/java/net/minestom/server/entity/type/animal/EntityStrider.java b/src/main/java/net/minestom/server/entity/type/animal/EntityStrider.java new file mode 100644 index 000000000..fad7a9fbe --- /dev/null +++ b/src/main/java/net/minestom/server/entity/type/animal/EntityStrider.java @@ -0,0 +1,51 @@ +package net.minestom.server.entity.type.animal; + +import net.minestom.server.entity.EntityType; +import net.minestom.server.entity.Metadata; +import net.minestom.server.entity.type.AgeableCreature; +import net.minestom.server.entity.type.Animal; +import net.minestom.server.instance.Instance; +import net.minestom.server.utils.Position; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Created by k.shandurenko on 23.02.2021 + */ +public class EntityStrider extends AgeableCreature implements Animal { + + public EntityStrider(@NotNull Position spawnPosition) { + super(EntityType.STRIDER, spawnPosition); + setBoundingBox(.9D, 1.7D, .9D); + } + + public EntityStrider(@NotNull Position spawnPosition, @Nullable Instance instance) { + super(EntityType.STRIDER, spawnPosition, instance); + setBoundingBox(.9D, 1.7D, .9D); + } + + public int getTimeToBoost() { + return this.metadata.getIndex((byte) 16, 0); + } + + public void setTimeToBoost(int value) { + this.metadata.setIndex((byte) 16, Metadata.VarInt(value)); + } + + public boolean isShaking() { + return this.metadata.getIndex((byte) 17, false); + } + + public void setShaking(boolean value) { + this.metadata.setIndex((byte) 17, Metadata.Boolean(value)); + } + + public boolean isHasSaddle() { + return this.metadata.getIndex((byte) 18, false); + } + + public void setHasSaddle(boolean value) { + this.metadata.setIndex((byte) 18, Metadata.Boolean(value)); + } + +} diff --git a/src/main/java/net/minestom/server/entity/type/animal/EntityWolf.java b/src/main/java/net/minestom/server/entity/type/animal/EntityWolf.java new file mode 100644 index 000000000..c8910d090 --- /dev/null +++ b/src/main/java/net/minestom/server/entity/type/animal/EntityWolf.java @@ -0,0 +1,50 @@ +package net.minestom.server.entity.type.animal; + +import net.minestom.server.entity.EntityType; +import net.minestom.server.entity.Metadata; +import net.minestom.server.entity.type.TameableAnimalCreature; +import net.minestom.server.instance.Instance; +import net.minestom.server.utils.Position; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Created by k.shandurenko on 23.02.2021 + */ +public class EntityWolf extends TameableAnimalCreature { + + public EntityWolf(@NotNull Position spawnPosition) { + super(EntityType.WOLF, spawnPosition); + setBoundingBox(.6D, .85D, .6D); + } + + public EntityWolf(@NotNull Position spawnPosition, @Nullable Instance instance) { + super(EntityType.WOLF, spawnPosition, instance); + setBoundingBox(.6D, .85D, .6D); + } + + public boolean isBegging() { + return this.metadata.getIndex((byte) 18, false); + } + + public void setBegging(boolean value) { + this.metadata.setIndex((byte) 18, Metadata.Boolean(value)); + } + + public int getCollarColor() { + return this.metadata.getIndex((byte) 19, 14); + } + + public void setCollarColor(int value) { + this.metadata.setIndex((byte) 19, Metadata.VarInt(value)); + } + + public int getAngerTime() { + return this.metadata.getIndex((byte) 20, 0); + } + + public void setAngerTime(int value) { + this.metadata.setIndex((byte) 20, Metadata.VarInt(value)); + } + +} diff --git a/src/main/java/net/minestom/server/entity/type/monster/EntityBasePiglin.java b/src/main/java/net/minestom/server/entity/type/monster/EntityBasePiglin.java new file mode 100644 index 000000000..f75d595a3 --- /dev/null +++ b/src/main/java/net/minestom/server/entity/type/monster/EntityBasePiglin.java @@ -0,0 +1,33 @@ +package net.minestom.server.entity.type.monster; + +import net.minestom.server.entity.EntityCreature; +import net.minestom.server.entity.EntityType; +import net.minestom.server.entity.Metadata; +import net.minestom.server.entity.type.Monster; +import net.minestom.server.instance.Instance; +import net.minestom.server.utils.Position; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Created by k.shandurenko on 23.02.2021 + */ +public class EntityBasePiglin extends EntityCreature implements Monster { + + EntityBasePiglin(@NotNull EntityType entityType, @NotNull Position spawnPosition) { + super(entityType, spawnPosition); + } + + EntityBasePiglin(@NotNull EntityType entityType, @NotNull Position spawnPosition, @Nullable Instance instance) { + super(entityType, spawnPosition, instance); + } + + public boolean isImmuneToZombification() { + return this.metadata.getIndex((byte) 16, false); + } + + public void setImmuneToZombification(boolean value) { + this.metadata.setIndex((byte) 16, Metadata.Boolean(value)); + } + +} diff --git a/src/main/java/net/minestom/server/entity/type/monster/EntityElderGuardian.java b/src/main/java/net/minestom/server/entity/type/monster/EntityElderGuardian.java new file mode 100644 index 000000000..cf72465f5 --- /dev/null +++ b/src/main/java/net/minestom/server/entity/type/monster/EntityElderGuardian.java @@ -0,0 +1,24 @@ +package net.minestom.server.entity.type.monster; + +import net.minestom.server.entity.EntityType; +import net.minestom.server.instance.Instance; +import net.minestom.server.utils.Position; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Created by k.shandurenko on 23.02.2021 + */ +public class EntityElderGuardian extends EntityGuardian { + + public EntityElderGuardian(@NotNull Position spawnPosition) { + super(EntityType.ELDER_GUARDIAN, spawnPosition); + setBoundingBox(1.9975D, 1.9975D, 1.9975D); + } + + public EntityElderGuardian(@NotNull Position spawnPosition, @Nullable Instance instance) { + super(EntityType.ELDER_GUARDIAN, spawnPosition, instance); + setBoundingBox(1.9975D, 1.9975D, 1.9975D); + } + +} diff --git a/src/main/java/net/minestom/server/entity/type/monster/EntityEnderman.java b/src/main/java/net/minestom/server/entity/type/monster/EntityEnderman.java new file mode 100644 index 000000000..5231fcedc --- /dev/null +++ b/src/main/java/net/minestom/server/entity/type/monster/EntityEnderman.java @@ -0,0 +1,51 @@ +package net.minestom.server.entity.type.monster; + +import net.minestom.server.entity.EntityCreature; +import net.minestom.server.entity.EntityType; +import net.minestom.server.entity.Metadata; +import net.minestom.server.entity.type.Monster; +import net.minestom.server.instance.Instance; +import net.minestom.server.utils.Position; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Created by k.shandurenko on 23.02.2021 + */ +public class EntityEnderman extends EntityCreature implements Monster { + + public EntityEnderman(@NotNull Position spawnPosition) { + super(EntityType.ENDERMAN, spawnPosition); + setBoundingBox(.6D, 2.9D, .6D); + } + + public EntityEnderman(@NotNull Position spawnPosition, @Nullable Instance instance) { + super(EntityType.ENDERMAN, spawnPosition, instance); + setBoundingBox(.6D, 2.9D, .6D); + } + + public Integer getCarriedBlockID() { + return this.metadata.getIndex((byte) 15, null); + } + + public void setCarriedBlockID(@Nullable Integer value) { + this.metadata.setIndex((byte) 15, Metadata.OptBlockID(value)); + } + + public boolean isScreaming() { + return this.metadata.getIndex((byte) 16, false); + } + + public void setScreaming(boolean value) { + this.metadata.setIndex((byte) 16, Metadata.Boolean(value)); + } + + public boolean isStaring() { + return this.metadata.getIndex((byte) 17, false); + } + + public void setStaring(boolean value) { + this.metadata.setIndex((byte) 17, Metadata.Boolean(value)); + } + +} diff --git a/src/main/java/net/minestom/server/entity/type/monster/EntityEvoker.java b/src/main/java/net/minestom/server/entity/type/monster/EntityEvoker.java new file mode 100644 index 000000000..2154a062e --- /dev/null +++ b/src/main/java/net/minestom/server/entity/type/monster/EntityEvoker.java @@ -0,0 +1,24 @@ +package net.minestom.server.entity.type.monster; + +import net.minestom.server.entity.EntityType; +import net.minestom.server.instance.Instance; +import net.minestom.server.utils.Position; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Created by k.shandurenko on 23.02.2021 + */ +public class EntityEvoker extends EntitySpellcasterIllager { + + public EntityEvoker(@NotNull Position spawnPosition) { + super(EntityType.EVOKER, spawnPosition); + setBoundingBox(.6D, 1.95D, .6D); + } + + public EntityEvoker(@NotNull Position spawnPosition, @Nullable Instance instance) { + super(EntityType.EVOKER, spawnPosition, instance); + setBoundingBox(.6D, 1.95D, .6D); + } + +} diff --git a/src/main/java/net/minestom/server/entity/type/monster/EntityGuardian.java b/src/main/java/net/minestom/server/entity/type/monster/EntityGuardian.java index c3936ea50..a8b5ccd4c 100644 --- a/src/main/java/net/minestom/server/entity/type/monster/EntityGuardian.java +++ b/src/main/java/net/minestom/server/entity/type/monster/EntityGuardian.java @@ -5,18 +5,33 @@ import net.minestom.server.entity.EntityCreature; import net.minestom.server.entity.EntityType; import net.minestom.server.entity.Metadata; import net.minestom.server.entity.type.Monster; +import net.minestom.server.instance.Instance; import net.minestom.server.utils.Position; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; public class EntityGuardian extends EntityCreature implements Monster { private Entity target; - public EntityGuardian(Position spawnPosition) { + public EntityGuardian(@NotNull Position spawnPosition) { super(EntityType.GUARDIAN, spawnPosition); setBoundingBox(0.85f, 0.85f, 0.85f); } + public EntityGuardian(@NotNull Position spawnPosition, @Nullable Instance instance) { + super(EntityType.GUARDIAN, spawnPosition, instance); + setBoundingBox(0.85f, 0.85f, 0.85f); + } + + EntityGuardian(@NotNull EntityType entityType, @NotNull Position spawnPosition) { + super(entityType, spawnPosition); + } + + EntityGuardian(@NotNull EntityType entityType, @NotNull Position spawnPosition, @Nullable Instance instance) { + super(entityType, spawnPosition, instance); + } + public boolean isRetractingSpikes() { return metadata.getIndex((byte) 15, false); } diff --git a/src/main/java/net/minestom/server/entity/type/monster/EntityIllusioner.java b/src/main/java/net/minestom/server/entity/type/monster/EntityIllusioner.java new file mode 100644 index 000000000..4906686ba --- /dev/null +++ b/src/main/java/net/minestom/server/entity/type/monster/EntityIllusioner.java @@ -0,0 +1,24 @@ +package net.minestom.server.entity.type.monster; + +import net.minestom.server.entity.EntityType; +import net.minestom.server.instance.Instance; +import net.minestom.server.utils.Position; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Created by k.shandurenko on 23.02.2021 + */ +public class EntityIllusioner extends EntitySpellcasterIllager { + + public EntityIllusioner(@NotNull Position spawnPosition) { + super(EntityType.ILLUSIONER, spawnPosition); + setBoundingBox(.6D, 1.95D, .6D); + } + + public EntityIllusioner(@NotNull Position spawnPosition, @Nullable Instance instance) { + super(EntityType.ILLUSIONER, spawnPosition, instance); + setBoundingBox(.6D, 1.95D, .6D); + } + +} diff --git a/src/main/java/net/minestom/server/entity/type/monster/EntityMagmaCube.java b/src/main/java/net/minestom/server/entity/type/monster/EntityMagmaCube.java new file mode 100644 index 000000000..0bcafb723 --- /dev/null +++ b/src/main/java/net/minestom/server/entity/type/monster/EntityMagmaCube.java @@ -0,0 +1,16 @@ +package net.minestom.server.entity.type.monster; + +import net.minestom.server.entity.EntityType; +import net.minestom.server.utils.Position; +import org.jetbrains.annotations.NotNull; + +/** + * Created by k.shandurenko on 23.02.2021 + */ +public class EntityMagmaCube extends EntitySlime { + + public EntityMagmaCube(@NotNull Position spawnPosition) { + super(EntityType.MAGMA_CUBE, spawnPosition); + } + +} diff --git a/src/main/java/net/minestom/server/entity/type/monster/EntityPiglin.java b/src/main/java/net/minestom/server/entity/type/monster/EntityPiglin.java new file mode 100644 index 000000000..c695c5e99 --- /dev/null +++ b/src/main/java/net/minestom/server/entity/type/monster/EntityPiglin.java @@ -0,0 +1,54 @@ +package net.minestom.server.entity.type.monster; + +import net.minestom.server.entity.EntityType; +import net.minestom.server.entity.Metadata; +import net.minestom.server.instance.Instance; +import net.minestom.server.utils.Position; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Created by k.shandurenko on 23.02.2021 + */ +public class EntityPiglin extends EntityBasePiglin { + + public EntityPiglin(@NotNull Position spawnPosition) { + super(EntityType.PIGLIN, spawnPosition); + setBoundingBox(.6D, 1.95D, .6D); + } + + public EntityPiglin(@NotNull Position spawnPosition, @Nullable Instance instance) { + super(EntityType.PIGLIN, spawnPosition, instance); + setBoundingBox(.6D, 1.95D, .6D); + } + + public boolean isBaby() { + return this.metadata.getIndex((byte) 16, false); + } + + public void setBaby(boolean value) { + this.metadata.setIndex((byte) 16, Metadata.Boolean(value)); + } + + public boolean isChargingCrossbow() { + return this.metadata.getIndex((byte) 17, false); + } + + public void setChargingCrossbow(boolean value) { + this.metadata.setIndex((byte) 17, Metadata.Boolean(value)); + } + + public boolean isDancing() { + return this.metadata.getIndex((byte) 18, false); + } + + public void setDancing(boolean value) { + this.metadata.setIndex((byte) 18, Metadata.Boolean(value)); + } + + @Override + public double getEyeHeight() { + return isBaby() ? super.getEyeHeight() / 2 : super.getEyeHeight(); + } + +} diff --git a/src/main/java/net/minestom/server/entity/type/monster/EntityPiglinBrute.java b/src/main/java/net/minestom/server/entity/type/monster/EntityPiglinBrute.java new file mode 100644 index 000000000..c10d4325b --- /dev/null +++ b/src/main/java/net/minestom/server/entity/type/monster/EntityPiglinBrute.java @@ -0,0 +1,24 @@ +package net.minestom.server.entity.type.monster; + +import net.minestom.server.entity.EntityType; +import net.minestom.server.instance.Instance; +import net.minestom.server.utils.Position; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Created by k.shandurenko on 23.02.2021 + */ +public class EntityPiglinBrute extends EntityBasePiglin { + + public EntityPiglinBrute(@NotNull Position spawnPosition) { + super(EntityType.PIGLIN_BRUTE, spawnPosition); + setBoundingBox(.6D, 1.95D, .6D); + } + + public EntityPiglinBrute(@NotNull Position spawnPosition, @Nullable Instance instance) { + super(EntityType.PIGLIN_BRUTE, spawnPosition, instance); + setBoundingBox(.6D, 1.95D, .6D); + } + +} diff --git a/src/main/java/net/minestom/server/entity/type/monster/EntityPillager.java b/src/main/java/net/minestom/server/entity/type/monster/EntityPillager.java new file mode 100644 index 000000000..375b256a7 --- /dev/null +++ b/src/main/java/net/minestom/server/entity/type/monster/EntityPillager.java @@ -0,0 +1,24 @@ +package net.minestom.server.entity.type.monster; + +import net.minestom.server.entity.EntityType; +import net.minestom.server.instance.Instance; +import net.minestom.server.utils.Position; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Created by k.shandurenko on 23.02.2021 + */ +public class EntityPillager extends EntityRaider { + + public EntityPillager(@NotNull Position spawnPosition) { + super(EntityType.PILLAGER, spawnPosition); + setBoundingBox(.6D, 1.95D, .6D); + } + + public EntityPillager(@NotNull Position spawnPosition, @Nullable Instance instance) { + super(EntityType.PILLAGER, spawnPosition, instance); + setBoundingBox(.6D, 1.95D, .6D); + } + +} diff --git a/src/main/java/net/minestom/server/entity/type/monster/EntityRaider.java b/src/main/java/net/minestom/server/entity/type/monster/EntityRaider.java new file mode 100644 index 000000000..55cabdf1d --- /dev/null +++ b/src/main/java/net/minestom/server/entity/type/monster/EntityRaider.java @@ -0,0 +1,33 @@ +package net.minestom.server.entity.type.monster; + +import net.minestom.server.entity.EntityCreature; +import net.minestom.server.entity.EntityType; +import net.minestom.server.entity.Metadata; +import net.minestom.server.entity.type.Monster; +import net.minestom.server.instance.Instance; +import net.minestom.server.utils.Position; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Created by k.shandurenko on 23.02.2021 + */ +public class EntityRaider extends EntityCreature implements Monster { + + protected EntityRaider(@NotNull EntityType entityType, @NotNull Position spawnPosition) { + super(entityType, spawnPosition); + } + + protected EntityRaider(@NotNull EntityType entityType, @NotNull Position spawnPosition, @Nullable Instance instance) { + super(entityType, spawnPosition, instance); + } + + public boolean isCelebrating() { + return this.metadata.getIndex((byte) 15, false); + } + + public void setCelebrating(boolean value) { + this.metadata.setIndex((byte) 15, Metadata.Boolean(value)); + } + +} diff --git a/src/main/java/net/minestom/server/entity/type/monster/EntityRavager.java b/src/main/java/net/minestom/server/entity/type/monster/EntityRavager.java new file mode 100644 index 000000000..5212508cc --- /dev/null +++ b/src/main/java/net/minestom/server/entity/type/monster/EntityRavager.java @@ -0,0 +1,24 @@ +package net.minestom.server.entity.type.monster; + +import net.minestom.server.entity.EntityType; +import net.minestom.server.instance.Instance; +import net.minestom.server.utils.Position; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Created by k.shandurenko on 23.02.2021 + */ +public class EntityRavager extends EntityRaider { + + public EntityRavager(@NotNull Position spawnPosition) { + super(EntityType.RAVAGER, spawnPosition); + setBoundingBox(1.95D, 2.2D, 1.95D); + } + + public EntityRavager(@NotNull Position spawnPosition, @Nullable Instance instance) { + super(EntityType.RAVAGER, spawnPosition, instance); + setBoundingBox(1.95D, 2.2D, 1.95D); + } + +} diff --git a/src/main/java/net/minestom/server/entity/type/monster/EntitySkeleton.java b/src/main/java/net/minestom/server/entity/type/monster/EntitySkeleton.java new file mode 100644 index 000000000..79e20476a --- /dev/null +++ b/src/main/java/net/minestom/server/entity/type/monster/EntitySkeleton.java @@ -0,0 +1,34 @@ +package net.minestom.server.entity.type.monster; + +import net.minestom.server.entity.EntityCreature; +import net.minestom.server.entity.EntityType; +import net.minestom.server.entity.type.Monster; +import net.minestom.server.instance.Instance; +import net.minestom.server.utils.Position; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Created by k.shandurenko on 23.02.2021 + */ +public class EntitySkeleton extends EntityCreature implements Monster { + + public EntitySkeleton(@NotNull Position spawnPosition) { + this(EntityType.SKELETON, spawnPosition); + setBoundingBox(.6D, 1.99D, .6D); + } + + public EntitySkeleton(@NotNull Position spawnPosition, @Nullable Instance instance) { + this(EntityType.SKELETON, spawnPosition, instance); + setBoundingBox(.6D, 1.99D, .6D); + } + + EntitySkeleton(@NotNull EntityType entityType, @NotNull Position spawnPosition) { + super(entityType, spawnPosition); + } + + EntitySkeleton(@NotNull EntityType entityType, @NotNull Position spawnPosition, @Nullable Instance instance) { + super(entityType, spawnPosition, instance); + } + +} diff --git a/src/main/java/net/minestom/server/entity/type/monster/EntitySlime.java b/src/main/java/net/minestom/server/entity/type/monster/EntitySlime.java index ab2471bc3..192167f62 100644 --- a/src/main/java/net/minestom/server/entity/type/monster/EntitySlime.java +++ b/src/main/java/net/minestom/server/entity/type/monster/EntitySlime.java @@ -5,11 +5,16 @@ import net.minestom.server.entity.EntityType; import net.minestom.server.entity.Metadata; import net.minestom.server.entity.type.Monster; import net.minestom.server.utils.Position; +import org.jetbrains.annotations.NotNull; public class EntitySlime extends EntityCreature implements Monster { - public EntitySlime(Position spawnPosition) { - super(EntityType.SLIME, spawnPosition); + public EntitySlime(@NotNull Position spawnPosition) { + this(EntityType.SLIME, spawnPosition); + } + + EntitySlime(@NotNull EntityType type, @NotNull Position spawnPosition) { + super(type, spawnPosition); setSize(1); } diff --git a/src/main/java/net/minestom/server/entity/type/monster/EntitySpellcasterIllager.java b/src/main/java/net/minestom/server/entity/type/monster/EntitySpellcasterIllager.java new file mode 100644 index 000000000..4cfb421d3 --- /dev/null +++ b/src/main/java/net/minestom/server/entity/type/monster/EntitySpellcasterIllager.java @@ -0,0 +1,42 @@ +package net.minestom.server.entity.type.monster; + +import net.minestom.server.entity.EntityType; +import net.minestom.server.entity.Metadata; +import net.minestom.server.instance.Instance; +import net.minestom.server.utils.Position; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Created by k.shandurenko on 23.02.2021 + */ +public class EntitySpellcasterIllager extends EntityRaider { + + protected EntitySpellcasterIllager(@NotNull EntityType entityType, @NotNull Position spawnPosition) { + super(entityType, spawnPosition); + } + + protected EntitySpellcasterIllager(@NotNull EntityType entityType, @NotNull Position spawnPosition, @Nullable Instance instance) { + super(entityType, spawnPosition, instance); + } + + public Spell getSpell() { + return Spell.VALUES[this.metadata.getIndex((byte) 16, (byte) 0)]; + } + + public void setSpell(Spell spell) { + this.metadata.setIndex((byte) 16, Metadata.Byte((byte) spell.ordinal())); + } + + public enum Spell { + NONE, + SUMMON_VEX, + ATTACK, + WOLOLO, + DISAPPEAR, + BLINDNESS; + + private final static Spell[] VALUES = values(); + } + +} diff --git a/src/main/java/net/minestom/server/entity/type/monster/EntityStray.java b/src/main/java/net/minestom/server/entity/type/monster/EntityStray.java new file mode 100644 index 000000000..10650ab9f --- /dev/null +++ b/src/main/java/net/minestom/server/entity/type/monster/EntityStray.java @@ -0,0 +1,24 @@ +package net.minestom.server.entity.type.monster; + +import net.minestom.server.entity.EntityType; +import net.minestom.server.instance.Instance; +import net.minestom.server.utils.Position; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Created by k.shandurenko on 23.02.2021 + */ +public class EntityStray extends EntitySkeleton { + + public EntityStray(@NotNull Position spawnPosition) { + super(EntityType.STRAY, spawnPosition); + setBoundingBox(.6D, 1.99D, .6D); + } + + public EntityStray(@NotNull Position spawnPosition, @Nullable Instance instance) { + super(EntityType.STRAY, spawnPosition, instance); + setBoundingBox(.6D, 1.99D, .6D); + } + +} diff --git a/src/main/java/net/minestom/server/entity/type/monster/EntityVex.java b/src/main/java/net/minestom/server/entity/type/monster/EntityVex.java new file mode 100644 index 000000000..a81e60b17 --- /dev/null +++ b/src/main/java/net/minestom/server/entity/type/monster/EntityVex.java @@ -0,0 +1,59 @@ +package net.minestom.server.entity.type.monster; + +import net.minestom.server.entity.EntityCreature; +import net.minestom.server.entity.EntityType; +import net.minestom.server.entity.Metadata; +import net.minestom.server.entity.type.Monster; +import net.minestom.server.instance.Instance; +import net.minestom.server.utils.Position; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Created by k.shandurenko on 23.02.2021 + */ +public class EntityVex extends EntityCreature implements Monster { + + private final static byte ATTACKING_BIT = 0x1; + + public EntityVex(@NotNull Position spawnPosition) { + super(EntityType.VEX, spawnPosition); + setBoundingBox(.4D, .8D, .4D); + } + + public EntityVex(@NotNull Position spawnPosition, @Nullable Instance instance) { + super(EntityType.VEX, spawnPosition, instance); + setBoundingBox(.4D, .8D, .4D); + } + + public boolean isAttacking() { + return (getMask() & ATTACKING_BIT) != 0; + } + + public void setAttacking(boolean value) { + modifyMask(ATTACKING_BIT, value); + } + + private byte getMask() { + return this.metadata.getIndex((byte) 15, (byte) 0); + } + + private void setMask(byte mask) { + this.metadata.setIndex((byte) 15, Metadata.Byte(mask)); + } + + private void modifyMask(byte bit, boolean value) { + byte mask = getMask(); + boolean isPresent = (mask & bit) == bit; + if (isPresent == value) { + return; + } + if (value) { + mask |= bit; + } else { + mask &= ~bit; + } + setMask(mask); + } + +} diff --git a/src/main/java/net/minestom/server/entity/type/monster/EntityVindicator.java b/src/main/java/net/minestom/server/entity/type/monster/EntityVindicator.java new file mode 100644 index 000000000..77fecd0cb --- /dev/null +++ b/src/main/java/net/minestom/server/entity/type/monster/EntityVindicator.java @@ -0,0 +1,24 @@ +package net.minestom.server.entity.type.monster; + +import net.minestom.server.entity.EntityType; +import net.minestom.server.instance.Instance; +import net.minestom.server.utils.Position; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Created by k.shandurenko on 23.02.2021 + */ +public class EntityVindicator extends EntityRaider { + + public EntityVindicator(@NotNull Position spawnPosition) { + super(EntityType.VINDICATOR, spawnPosition); + setBoundingBox(.6D, 1.95D, .6D); + } + + public EntityVindicator(@NotNull Position spawnPosition, @Nullable Instance instance) { + super(EntityType.VINDICATOR, spawnPosition, instance); + setBoundingBox(.6D, 1.95D, .6D); + } + +} diff --git a/src/main/java/net/minestom/server/entity/type/monster/EntityWitherSkeleton.java b/src/main/java/net/minestom/server/entity/type/monster/EntityWitherSkeleton.java new file mode 100644 index 000000000..736d2d0b2 --- /dev/null +++ b/src/main/java/net/minestom/server/entity/type/monster/EntityWitherSkeleton.java @@ -0,0 +1,24 @@ +package net.minestom.server.entity.type.monster; + +import net.minestom.server.entity.EntityType; +import net.minestom.server.instance.Instance; +import net.minestom.server.utils.Position; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Created by k.shandurenko on 23.02.2021 + */ +public class EntityWitherSkeleton extends EntitySkeleton { + + public EntityWitherSkeleton(@NotNull Position spawnPosition) { + super(EntityType.WITHER_SKELETON, spawnPosition); + setBoundingBox(.7D, 2.4D, .7D); + } + + public EntityWitherSkeleton(@NotNull Position spawnPosition, @Nullable Instance instance) { + super(EntityType.WITHER_SKELETON, spawnPosition, instance); + setBoundingBox(.7D, 2.4D, .7D); + } + +} diff --git a/src/main/java/net/minestom/server/entity/type/monster/EntityZoglin.java b/src/main/java/net/minestom/server/entity/type/monster/EntityZoglin.java new file mode 100644 index 000000000..a3c344877 --- /dev/null +++ b/src/main/java/net/minestom/server/entity/type/monster/EntityZoglin.java @@ -0,0 +1,26 @@ +package net.minestom.server.entity.type.monster; + +import net.minestom.server.entity.EntityType; +import net.minestom.server.entity.type.AgeableCreature; +import net.minestom.server.entity.type.Monster; +import net.minestom.server.instance.Instance; +import net.minestom.server.utils.Position; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Created by k.shandurenko on 23.02.2021 + */ +public class EntityZoglin extends AgeableCreature implements Monster { + + public EntityZoglin(@NotNull Position spawnPosition) { + super(EntityType.ZOGLIN, spawnPosition); + setBoundingBox(1.3965D, 1.4D, 1.3965D); + } + + public EntityZoglin(@NotNull Position spawnPosition, @Nullable Instance instance) { + super(EntityType.ZOGLIN, spawnPosition, instance); + setBoundingBox(1.3965D, 1.4D, 1.3965D); + } + +} diff --git a/src/main/java/net/minestom/server/entity/type/monster/EntityZombieVillager.java b/src/main/java/net/minestom/server/entity/type/monster/EntityZombieVillager.java index d6eb795a8..afcf62d4f 100644 --- a/src/main/java/net/minestom/server/entity/type/monster/EntityZombieVillager.java +++ b/src/main/java/net/minestom/server/entity/type/monster/EntityZombieVillager.java @@ -3,6 +3,7 @@ package net.minestom.server.entity.type.monster; import net.minestom.server.entity.EntityType; import net.minestom.server.entity.Metadata; import net.minestom.server.entity.type.ambient.EntityAbstractVillager; +import net.minestom.server.entity.type.ambient.EntityVillager; import net.minestom.server.utils.Position; import org.jetbrains.annotations.NotNull; @@ -23,15 +24,15 @@ public class EntityZombieVillager extends EntityZombie { this.metadata.setIndex((byte) 18, Metadata.Boolean(value)); } - public EntityAbstractVillager.VillagerData getVillagerData() { + public EntityVillager.VillagerData getVillagerData() { int[] data = this.metadata.getIndex((byte) 17, null); if (data == null) { - return new EntityAbstractVillager.VillagerData(EntityAbstractVillager.Type.PLAINS, EntityAbstractVillager.Profession.NONE, EntityAbstractVillager.Level.NOVICE); + return new EntityVillager.VillagerData(EntityVillager.Type.PLAINS, EntityVillager.Profession.NONE, EntityVillager.Level.NOVICE); } - return new EntityAbstractVillager.VillagerData(EntityAbstractVillager.Type.VALUES[data[0]], EntityAbstractVillager.Profession.VALUES[data[1]], EntityAbstractVillager.Level.VALUES[data[2] - 1]); + return new EntityVillager.VillagerData(EntityVillager.Type.VALUES[data[0]], EntityVillager.Profession.VALUES[data[1]], EntityVillager.Level.VALUES[data[2] - 1]); } - public void setVillagerData(EntityAbstractVillager.VillagerData data) { + public void setVillagerData(EntityVillager.VillagerData data) { this.metadata.setIndex((byte) 17, Metadata.VillagerData( data.getType().ordinal(), data.getProfession().ordinal(), diff --git a/src/main/java/net/minestom/server/entity/type/other/EntityShulker.java b/src/main/java/net/minestom/server/entity/type/other/EntityShulker.java new file mode 100644 index 000000000..2470dbd67 --- /dev/null +++ b/src/main/java/net/minestom/server/entity/type/other/EntityShulker.java @@ -0,0 +1,59 @@ +package net.minestom.server.entity.type.other; + +import net.minestom.server.entity.EntityCreature; +import net.minestom.server.entity.EntityType; +import net.minestom.server.entity.Metadata; +import net.minestom.server.entity.type.Constructable; +import net.minestom.server.instance.Instance; +import net.minestom.server.utils.BlockPosition; +import net.minestom.server.utils.Direction; +import net.minestom.server.utils.Position; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Created by k.shandurenko on 23.02.2021 + */ +public class EntityShulker extends EntityCreature implements Constructable { + + public EntityShulker(@NotNull Position spawnPosition) { + super(EntityType.SHULKER, spawnPosition); + } + + public EntityShulker(@NotNull Position spawnPosition, @Nullable Instance instance) { + super(EntityType.SHULKER, spawnPosition, instance); + } + + public Direction getAttachFace() { + return this.metadata.getIndex((byte) 15, Direction.DOWN); + } + + public void setAttachFace(Direction value) { + this.metadata.setIndex((byte) 15, Metadata.Direction(value)); + } + + public BlockPosition getAttachmentPosition() { + return this.metadata.getIndex((byte) 16, null); + } + + public void setAttachmentPosition(BlockPosition value) { + this.metadata.setIndex((byte) 16, Metadata.OptPosition(value)); + } + + public byte getShieldHeight() { + return this.metadata.getIndex((byte) 17, (byte) 0); + } + + public void setShieldHeight(byte value) { + this.metadata.setIndex((byte) 17, Metadata.Byte(value)); + } + + public byte getColor() { + return this.metadata.getIndex((byte) 18, (byte) 0); + } + + public void setColor(byte value) { + this.metadata.setIndex((byte) 18, Metadata.Byte(value)); + } + +}