Interface Entity

    • Method Detail

      • 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,
                                       java.util.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
      • 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

        java.util.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,
                               java.util.function.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 java.util.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:
        EntityVolume.nearbyEntities(Vector3d, double)
      • nearbyEntities

        default java.util.Collection<? extends Entity> nearbyEntities​(double distance,
                                                                      java.util.function.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:
        EntityVolume.entities(AABB, Predicate)
      • 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
      • baseVehicle

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

        default Value<java.lang.Boolean> onGround()
        Returns:
        Whether this entity is on the ground
      • creator

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

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

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

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

        default Value<java.lang.Double> height()
        Returns:
        The height of the entity
      • wet

        default Value<java.lang.Boolean> wet()
        Returns:
        Whether the entity is wet
      • swiftness

        default java.util.Optional<Value.Mutable<java.lang.Double>> swiftness()
        Returns:
        The current swiftness of the entity