Interface Entity

All Superinterfaces:
CopyableDataHolder, DataHolder, DataHolder.Mutable, DataSerializable, EntityProjectileSource, HoverEventSource<HoverEvent.ShowEntity>, Identifiable, Locatable, ProjectileSource, RandomProvider, SerializableDataHolder, SerializableDataHolder.Mutable, Sound.Emitter, ValueContainer
All Known Subinterfaces:
Aerial, Ageable, Agent, Ambient, Animal, Aquatic, AreaEffectCloud, ArmorStand, Arrow, ArrowEntity, Axolotl, Bat, Bee, Blaze, BlockOccupiedMinecart, Boat, Boss, CarrierMinecart<M>, Cat, CaveSpider, ChestMinecart, Chicken, ClientPlayer, Cod, CommandBlockMinecart, ComplexLiving<T>, ComplexLivingPart<P>, Cow, Creature, Creeper, DamagingProjectile, Dolphin, Donkey, DragonFireball, Drowned, Egg, ElderGuardian, EndCrystal, EnderDragon, EnderDragonPart, Enderman, Endermite, EnderPearl, EntityTargetingProjectile, Evoker, EvokerFangs, ExperienceBottle, ExperienceOrb, Explosive, ExplosiveFireball, EyeOfEnder, FallingBlock, FireballEntity, FireworkRocket, Fish, FishingBobber, Fox, FurnaceMinecart, FusedExplosive, Ghast, Giant, GlowSquid, Goat, Golem, Guardian, Hanging, Hoglin, HopperMinecart, Horse, HorseLike, Hostile, Human, Humanoid, Husk, Illager, Illusioner, IronGolem, Item, ItemFrame, LeashKnot, LightningBolt, Living, Llama, LlamaLike, LlamaSpit, LocalPlayer, MagmaCube, Marker, Minecart, MinecartLike, Monster, Mooshroom, Mule, Ocelot, PackHorse, Painting, Panda, Parrot, Patroller, Phantom, Pig, Piglin, PiglinBrute, PiglinLike, Pillager, Player, PolarBear, Potion, PrimedTNT, Projectile, Pufferfish, Rabbit, Raider, Ranger, Ravager, RemotePlayer, Salmon, SchoolingFish, ServerPlayer, Sheep, Shulker, ShulkerBullet, Silverfish, Sittable, Skeleton, SkeletonHorse, SkeletonLike, Slime, SmallFireball, Snowball, SnowGolem, SpawnerMinecart, SpectralArrow, Spellcaster, Spider, Squid, Stray, Strider, TameableAnimal, TameableHorse, TNTMinecart, Trader, TraderLlama, Trident, TropicalFish, Turtle, Vehicle, Vex, Villager, Vindicator, WanderingTrader, WeatherEffect, Witch, Wither, WitherSkeleton, WitherSkull, Wolf, Zoglin, Zombie, ZombieHorse, ZombieLike, ZombieVillager, ZombifiedPiglin

An entity is a Minecraft entity.

Examples of entities include:

  • Zombies
  • Sheep
  • Players
  • Dropped items
  • Dropped experience points
  • etc.

Blocks and items (when they are in inventories) are not entities.

  • Method Details

    • type

      EntityType<?> type()
      Gets the EntityType.
      Returns:
      The type
    • createSnapshot

      EntitySnapshot createSnapshot()
      Creates an EntitySnapshot.
      Returns:
      The snapshot
    • copy

      Entity copy()
      Description copied from interface: CopyableDataHolder
      Creates a clone copy of this CopyableDataHolder as a new CopyableDataHolder such that all the Values are safely duplicated to the new instance. It is not guaranteed that the returning container is of the same type as this container.
      Specified by:
      copy in interface CopyableDataHolder
      Specified by:
      copy in interface SerializableDataHolder
      Specified by:
      copy in interface SerializableDataHolder.Mutable
      Returns:
      The new copy
    • createArchetype

      EntityArchetype createArchetype()
      Creates an EntityArchetype for use with Schematics.
      Returns:
      The archetype
    • position

      Vector3d position()
      Gets the position of this entity
      Returns:
      The position of this entity
    • setPosition

      boolean setPosition(Vector3d position)
      Sets the position of this entity.
      Parameters:
      position - The position to set
      Returns:
      True if set, false if not
    • setLocation

      boolean setLocation(ServerLocation location)
      Sets the location of this entity.
      Parameters:
      location - The location to set
      Returns:
      True if location was set successfully, false otherwise
    • rotation

      Vector3d rotation()
      Gets the rotation.

      The format of the rotation is represented by:

      x -> pitch, y -> yaw, z -> roll

      Returns:
      The rotation
    • setRotation

      void setRotation(Vector3d rotation)
      Sets the rotation of this entity.

      The format of the rotation is represented by:

      x -> pitch, y -> yaw, z -> roll

      Parameters:
      rotation - The rotation to set the entity to
    • direction

      default Vector3d direction()
      Gets the unit vector representing the direction of this entity.
      Returns:
      The direction
    • setLocationAndRotation

      boolean setLocationAndRotation(ServerLocation location, Vector3d rotation)
      Moves the entity to the specified location and sets the rotation.

      The format of the rotation is represented by:

      x -> pitch, y -> yaw, z -> roll

      Parameters:
      location - The location to set
      rotation - The rotation to set
      Returns:
      True if location was set successfully, false otherwise
    • setLocationAndRotation

      boolean setLocationAndRotation(ServerLocation location, Vector3d rotation, EnumSet<RelativePositions> relativePositions)
      Moves the entity to the specified location and sets the rotation. RelativePositions listed inside the EnumSet are considered relative.

      The format of the rotation is represented by:

      x -> pitch, y -> yaw, z -> roll

      Parameters:
      location - The location to set
      rotation - The rotation to set
      relativePositions - The coordinates to set relatively
      Returns:
      True if location was set successfully, false otherwise
    • scale

      Vector3d scale()
      Gets the scale.
      Returns:
      The entity scale
    • setScale

      void setScale(Vector3d scale)
      Sets the scale.
      Parameters:
      scale - The scale
    • transform

      Transform transform()
      Gets the Transform.
      Returns:
      The transform
    • setTransform

      boolean setTransform(Transform transform)
      Sets the Transform.
      Parameters:
      transform - The transform to set
      Returns:
      True if the transform was set successfully, false if the transform couldn't be set
    • transferToWorld

      default boolean transferToWorld(ServerWorld world)
      Sets the ServerLocation of this entity to the ServerWorld's spawn point.
      Parameters:
      world - The world to transfer to
      Returns:
      Whether the transfer was successful, returns false if the action is cancelled or not possible (eg. because the entity has been removed)
    • transferToWorld

      boolean transferToWorld(ServerWorld world, Vector3d position)
      Sets the ServerLocation of this entity to a new position in a world.
      Parameters:
      world - The world to transfer to
      position - The position in the target world
      Returns:
      Whether the transfer was successful, returns false if the action is cancelled or not possible (eg. because the entity has been removed)
    • boundingBox

      Optional<AABB> boundingBox()
      Gets the entity's bounding box, usually for collisions and interaction. The box has an offset matching the entity's positions. That is to say, it is absolutely positioned and not relative to the entity.
      Returns:
      The axis aligned bounding box
    • isRemoved

      boolean isRemoved()
      Returns whether this entity has been removed.
      Returns:
      True if this entity has been removed
    • isLoaded

      boolean isLoaded()
      Returns whether this entity is still loaded in a world/chunk.
      Returns:
      True if this entity is still loaded
    • remove

      void remove()
      Mark this entity for removal in the very near future, preferably within one game tick.
    • damage

      default boolean damage(double damage, Supplier<? extends DamageSource> damageSource)
      Damages this Entity with the given DamageSource.
      Parameters:
      damage - The damage to deal
      damageSource - The cause of the damage
      Returns:
      True if damaging the entity was successful
    • damage

      boolean damage(double damage, DamageSource damageSource)
      Damages this Entity with the given DamageSource.
      Parameters:
      damage - The damage to deal
      damageSource - The cause of the damage
      Returns:
      True if damaging the entity was successful
    • nearbyEntities

      default Collection<? extends Entity> nearbyEntities(double distance)
      Gets the nearby entities within the desired distance.
      Parameters:
      distance - The distance
      Returns:
      The collection of nearby entities
      See Also:
    • nearbyEntities

      default Collection<? extends Entity> nearbyEntities(double distance, Predicate<? super Entity> predicate)
      Gets the nearby entities that satisfy the desired predicate.
      Parameters:
      distance - The distance
      predicate - The predicate to use
      Returns:
      The collection of entities
      See Also:
    • canSee

      default boolean canSee(Entity entity)
      Returns whether this entity can see the provided Entity.
      Parameters:
      entity - The entity to check visibility for
      Returns:
      true if this entity can see the provided entity
    • lookAt

      void lookAt(Vector3d targetPos)
      Makes the entity look at the specified target position.
      Parameters:
      targetPos - Position to target
    • displayName

      default Value.Mutable<Component> displayName()
      Returns:
      The display name of this entity
    • fallDistance

      default Value.Mutable<Double> fallDistance()
      Returns:
      The fall distance
    • passengers

      default ListValue.Mutable<Entity> passengers()
      Returns:
      The list of passengers that may be riding this entity
    • vehicle

      default Optional<Value.Mutable<Entity>> vehicle()
      Returns:
      The vehicle this entity may be riding
    • baseVehicle

      default Optional<Value<Entity>> baseVehicle()
      Returns:
      The "base vehicle" of the entity vehicle riding chain
    • onGround

      default Value<Boolean> onGround()
      Returns:
      Whether this entity is on the ground
    • velocity

      default Value.Mutable<Vector3d> velocity()
      Returns:
      The velocity of this entity
    • gravityAffected

      default Value.Mutable<Boolean> gravityAffected()
      Returns:
      Whether this entity is affected by gravity
    • silent

      default Value.Mutable<Boolean> silent()
      Returns:
      Whether this entity is silent
    • creator

      default Optional<Value.Mutable<UUID>> creator()
      Returns:
      The unique id of the creator of this entity
    • notifier

      default Optional<Value.Mutable<UUID>> notifier()
      Returns:
      The unique id of the notifier of this entity
    • fireTicks

      default Optional<Value.Mutable<Ticks>> fireTicks()
      Returns:
      The amount of time in ticks the entity is will continue burn for
    • fireImmuneTicks

      default Value.Mutable<Ticks> fireImmuneTicks()
      Returns:
      The amount of time to delay in ticks before the entity will be burned by fire
    • isTransient

      default Value.Mutable<Boolean> isTransient()
      Returns:
      The transient state
    • age

      default Value.Mutable<Integer> age()
      Returns:
      The age of this entity
    • baseSize

      default Value<Double> baseSize()
      Returns:
      The base size of the entity
    • eyeHeight

      default Value<Double> eyeHeight()
      Returns:
      The height of the eyes
    • eyePosition

      default Value<Vector3d> eyePosition()
      Returns:
      The position of the eyes
    • height

      default Value<Double> height()
      Returns:
      The height of the entity
    • invulnerabilityTicks

      default Value.Mutable<Ticks> invulnerabilityTicks()
      Returns:
      The amount of ticks the entity will remain invulnerable for
    • customNameVisible

      default Value.Mutable<Boolean> customNameVisible()
      Returns:
      Whether a custom name is visible on the entity
    • glowing

      default Value.Mutable<Boolean> glowing()
      Returns:
      Whether the entity has a glowing outline
    • invisible

      default Value.Mutable<Boolean> invisible()
      Returns:
      Whether the entity is currently invisible
    • invulnerable

      default Value.Mutable<Boolean> invulnerable()
      Returns:
      Whether the entity is invulnerable
    • sneaking

      default Value.Mutable<Boolean> sneaking()
      Returns:
      Whether the entity is sneaking
    • sprinting

      default Value.Mutable<Boolean> sprinting()
      Returns:
      Whether the entity is sprinting
    • wet

      default Value<Boolean> wet()
      Returns:
      Whether the entity is wet
    • maxAir

      default Value.Mutable<Integer> maxAir()
      Returns:
      The max air supply
    • remainingAir

      default Value.Mutable<Integer> remainingAir()
      Returns:
      The remaining air supply
    • scoreboardTags

      default SetValue.Mutable<String> scoreboardTags()
      Returns:
      The scoreboard tags applied to the entity
    • vanishState

      default Value.Mutable<VanishState> vanishState()
      Returns:
      The current vanish state of the entity
    • customName

      default Optional<Value.Mutable<Component>> customName()
      Returns:
      The custom name of the entity
    • swiftness

      default Optional<Value.Mutable<Double>> swiftness()
      Returns:
      The current swiftness of the entity
    • asHoverEvent

      Specified by:
      asHoverEvent in interface HoverEventSource<HoverEvent.ShowEntity>