Much more entities

This commit is contained in:
Konstantin Shandurenko 2021-02-23 08:25:35 +03:00
parent ca3d36ac0c
commit 07be9d449b
32 changed files with 1063 additions and 13 deletions

View File

@ -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),

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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() {

View File

@ -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();
}
}

View File

@ -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));
}
}

View File

@ -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();
}
}

View File

@ -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));
}
}

View File

@ -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));
}
}

View File

@ -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));
}
}

View File

@ -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));
}
}

View File

@ -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);
}
}

View File

@ -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));
}
}

View File

@ -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);
}
}

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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();
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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));
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}

View File

@ -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();
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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(),

View File

@ -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));
}
}