Skip to main content

LivingEntity

Acts as a proxy for a living entity in the Minecraft world

warning

This page is a WIP. It contains all the information in Figura's documentation but we're working on adding more helpful descriptions.

For this page assume:

local thisEntity = thisEntity:getTargetedEntity()

Living Entity Transformations

getPos()

Gets the position of the entity in the world

If delta is passed in, then it will be used to linearly interpolate the position of the entity between the previous tick and the current tick

The default value of delta is 1

getPos()

Returns:

TypeDescription
Vector3-

Example:

thisEntity:getPos()

getRot()

Gets the rotation of the entity in degrees

If delta is passed in, then it will be used to linearly interpolate the rotation of the entity between the previous tick and the current tick

The default value of delta is 1

getRot()

Returns:

TypeDescription
Vector2-

Example:

thisEntity:getRot()

getBodyYaw()

Gets the yaw of this entity's body in degrees

If delta is passed in, then it will be used to linearly interpolate the rotation of the body between the previous tick and the current tick

The default value of delta is 1

getBodyYaw()

Returns:

TypeDescription
Number-

Example:

thisEntity:getBodyYaw()

getLookDir()

Returns a unit vector pointing in the direction that this entity is looking

See the blue line in the F3+B screen for an example

getLookDir()

Returns:

TypeDescription
Vector3-

Example:

thisEntity:getLookDir()

getVelocity()

Gets the current velocity of this entity in world coordinates, calculated as its position this tick minus its position last tick

getVelocity()

Returns:

TypeDescription
Vector3-

Example:

thisEntity:getVelocity()

Living Entity Actions

getPose()

Returns the current pose of the player

This can be one of: "STANDING", "FALL_FLYING", "SLEEPING", "SWIMMING", "SPIN_ATTACK", "CROUCHING", "LONG_JUMPING", or "DYING"

getPose()

Returns:

TypeDescription
String-

Example:

thisEntity:getPose() == "CROUCHING"

isBlocking()

Return if this entity is blocking with a shield

isBlocking()

Returns:

TypeDescription
Boolean-

Example:

thisEntity:isBlocking()

isClimbing()

Returns true if the entity is currently using a climbable block, like a ladder or vine

isClimbing()

Returns:

TypeDescription
Boolean-

Example:

thisEntity:isClimbing()

isCrouching()

Returns true if this entity is visually sneaking

isCrouching()

Returns:

TypeDescription
Boolean-

Example:

thisEntity:isCrouching()

isGliding()

Returns if this entity is gliding with an elytra

isGliding()

Returns:

TypeDescription
Boolean-

Example:

thisEntity:isGliding()

isSneaking()

Returns true if this entity is logically sneaking (can't fall from blocks edges, can't see nameplate behind walls, etc)

isSneaking()

Returns:

TypeDescription
Boolean-

Example:

thisEntity:isSneaking()

isSprinting()

Returns true if this entity is currently sprinting

isSprinting()

Returns:

TypeDescription
Boolean-

Example:

thisEntity:isSprinting()

isVisuallySwimming()

Returns if this entity has the swimming pose

isVisuallySwimming()

Returns:

TypeDescription
Boolean-

Example:

thisEntity:isVisuallySwimming()

riptideSpinning()

Returns if this entity is riptide spinning

riptideSpinning()

Returns:

TypeDescription
Boolean-

Example:

thisEntity:riptideSpinning()

Living Entity Data

getAbsorptionAmount()

Returns the amount of this entity's absorption (yellow hearts)

getAbsorptionAmount()

Returns:

TypeDescription
Number-

Example:

thisEntity:getAbsorptionAmount()

getArmor()

Returns the amount of armor points this entity has

getArmor()

Returns:

TypeDescription
Number-

Example:

thisEntity:getArmor()

getArrowCount()

Returns the number of arrows sticking out of this entity

getArrowCount()

Returns:

TypeDescription
Integer-

Example:

thisEntity:getArrowCount()

getBoundingBox()

Returns the size of this entity's bounding box as a Vector3

{x, y, z} are the width, height, and width

Minecraft entity hitboxes always have square bases

getBoundingBox()

Returns:

TypeDescription
Vector3-

Example:

thisEntity:getBoundingBox()

getControlledVehicle()

Return the vehicle that this entity is controlling

getControlledVehicle()

Returns:

TypeDescription
EntityAPI-

Example:

thisEntity:getControlledVehicle()

getControllingPassenger()

Returns the entity that is controlling this entity

getControllingPassenger()

Returns:

TypeDescription
EntityAPI-

Example:

thisEntity:getControllingPassenger()

getDeathTime()

Returns the number of ticks this entity has been dead for

getDeathTime()

Returns:

TypeDescription
Number-

Example:

thisEntity:getDeathTime()

getDimensionName()

Gets the Minecraft identifier of the dimension this entity is in

getDimensionName()

Returns:

TypeDescription
String-

Example:

thisEntity:getDimensionName()

getEntityCategory()

Returns the category of this entity

The categories are: "ARTHROPOD", "UNDEAD", "WATER", "ILLAGER" and by default, "UNDEFINED"

getEntityCategory()

Returns:

TypeDescription
String-

Example:

thisEntity:getEntityCategory() == "UNDEAD"

getEyeHeight()

Returns the current eye height of this entity

getEyeHeight()

Returns:

TypeDescription
Number-

Example:

thisEntity:getEyeHeight()

getEyeY()

Returns the Y level of this entity's eyes

Not to be confused with getEyeHeight, this function also takes the entity itself's Y position into account

getEyeY()

Returns:

TypeDescription
Number-

Example:

thisEntity:getEyeY()

getFrozenTicks()

Gets the number of ticks this entity has been freezing in powder snow for

getFrozenTicks()

Returns:

TypeDescription
Integer-

Example:

thisEntity:getFrozenTicks()

getHealth()

Returns the amount of health this entity has remaining

getHealth()

Returns:

TypeDescription
Number-

Example:

thisEntity:getHealth()

getMaxAir()

Gets the maximum amount of air this entity can have

getMaxAir()

Returns:

TypeDescription
Integer-

Example:

thisEntity:getMaxAir()

getMaxHealth()

Returns the maximum amount of health this entity can have

getMaxHealth()

Returns:

TypeDescription
Number-

Example:

thisEntity:getMaxHealth()

getName()

Gets the name of this entity, if it has a custom name

If it doesn't, returns a translated form of getType()

getName()

Returns:

TypeDescription
String-

Example:

thisEntity:getName()

getNbt()

Gets a table containing the NBT of this entity

Please note that not all values in the entity's NBT may be synced, as some are handled only on the server side

getNbt()

Returns:

TypeDescription
Table-

Example:

thisEntity:getNbt()

getPassengers()

Returns a List of entities of all passengers this entity has

getPassengers()

Returns:

TypeDescription
Table-

Example:

thisEntity:getPassengers()

getPermissionLevel()

Returns the permission level number of this entity

Server Operators, by default, have the permission level of 4

getPermissionLevel()

Returns:

TypeDescription
Integer-

Example:

thisEntity:getPermissionLevel()

getStingerCount()

Returns the number of bee stingers sticking out of this entity

getStingerCount()

Returns:

TypeDescription
Integer-

Example:

thisEntity:getStingerCount()

getTargetedBlock()

Returns a proxy for your currently targeted BlockState

This BlockState appears on the F3 screen

The maximum (and default) distance is 20, minimum is -20

Returns the block, the hit position, and the targeted block face as three separate values

getTargetedBlock()

Returns:

TypeDescription
BlockStateTargeted block
Vector3Hit position
StringTargeted block face

Example:

local block, hitPos, side = thisEntity:getTargetedBlock(true, 4.5)
if block.id == "minecraft:grass_block" then
log("You're looking at grass")
end

getTargetedEntity()

Returns a proxy for your currently targeted Entity

This Entity appears on the F3 screen

Maximum and Default distance is 20, Minimum is 0

getTargetedEntity()

Returns:

TypeDescription
EntityTargeted entity
Vector3Hit position

Example:

local entity, hitPos = thisEntity:getTargetedEntity()

getType()

Gets the Minecraft identifier of this entity

For instance, "minecraft:pig"

getType()

Returns:

TypeDescription
String-

Example:

thisEntity:getType()

getVehicle()

Returns a proxy for the entity that this player is currently riding

If the player isn't riding anything, returns nil

getVehicle()

Returns:

TypeDescription
EntityAPI-

Example:

if thisEntity:getVehicle() and thisEntity:getVehicle():getType() == "minecraft:pig" then
log("You're riding a pig")
end

hasContainer()

Checks if the entity has a container (Chest Boats, Minecarts with Chests, …)

hasContainer()

Returns:

TypeDescription
Boolean-

Example:

thisEntity:hasContainer()

hasInventory()

Checks if the entity has an inventory (Horses, Camels, LLamas, …)

hasInventory()

Returns:

TypeDescription
Boolean-

Example:

thisEntity:hasInventory()

isAlive()

Returns whether this entity is alive or not

isAlive()

Returns:

TypeDescription
Boolean-

Example:

thisEntity:isAlive()

isGlowing()

Returns true if this entity is currently glowing

isGlowing()

Returns:

TypeDescription
Boolean-

Example:

thisEntity:isGlowing()

isInLava()

Returns true if this entity is currently in lava

isInLava()

Returns:

TypeDescription
Boolean-

Example:

thisEntity:isInLava()

isInRain()

Returns true if this entity is currently standing in rain

isInRain()

Returns:

TypeDescription
Boolean-

Example:

thisEntity:isInRain()

isInWater()

Returns true if this entity is currently in a water block, including waterlogging

isInWater()

Returns:

TypeDescription
Boolean-

Example:

thisEntity:isInWater()

isInvisible()

Returns true if this entity is invisible, for one reason or another

isInvisible()

Returns:

TypeDescription
Boolean-

Example:

thisEntity:isInvisible()

isLiving()

Gets if this entity is a Living Entity

isLiving()

Returns:

TypeDescription
Boolean-

Example:

thisEntity:isLiving()

isLoaded()

Checks if this entity object is still being updated and loaded

A non-loaded entity would be someone or something which is in another dimension or out of the render distance for example

isLoaded()

Returns:

TypeDescription
Boolean-

Example:

thisEntity:isLoaded()

isOnFire()

Returns true if this entity is currently on fire

isOnFire()

Returns:

TypeDescription
Boolean-

Example:

thisEntity:isOnFire()

isOnGround()

caution

Due to a glitch in Minecraft's code this function is unreliable, and will misfire in multiple situations such as being underwater, standing on a boat, or standing on a slime block.

Work Around:

-- check the blockstate of the block directly underneath the entity
world.getBlockState(thisEntity:getPos():add(0, -0.1, 0)):isSolidBlock()

Returns whether or not this entity is currently on the ground

isOnGround()

Returns:

TypeDescription
Boolean-

Example:

thisEntity:isOnGround()

isPlayer()

Gets if this entity is a Player Entity

isPlayer()

Returns:

TypeDescription
Boolean-

Example:

thisEntity:isPlayer()

isSensitiveToWater()

Returns if this entity takes damage to water

isSensitiveToWater()

Returns:

TypeDescription
Boolean-

Example:

thisEntity:isSensitiveToWater()

isSilent()

Returns true if this entity is silent

isSilent()

Returns:

TypeDescription
Boolean-

Example:

thisEntity:isSilent()

isUnderwater()

Returns true if this entity's eyes are touching water

isUnderwater()

Returns:

TypeDescription
Boolean-

Example:

thisEntity:isUnderwater()

isWet()

Returns true in any of three conditions: if the entity is in water, if the entity is in rain, or if the entity is in a bubble column

Otherwise, returns false

isWet()

Returns:

TypeDescription
Boolean-

Example:

thisEntity:isWet()

Item Functions

getActiveItem()

Returns an ItemStack representing the item the entity is currently using

If they're not using any item, returns air

getActiveItem()

Returns:

TypeDescription
ItemStack-

Example:

thisEntity:getActiveItem()

getActiveItemTime()

Returns the ticks this entity's active item has been used for

getActiveItemTime()

Returns:

TypeDescription
Integer-

Example:

thisEntity:getActiveItemTime()

getHeldItem()

Returns an ItemStack representing the item in this entity's main hand

If true is passed in for "offhand", then it will instead look at the item in the entity's offhand

If the entity isn't holding an item in that hand, returns air

getHeldItem()

Returns:

TypeDescription
ItemStack-

Example:

if thisEntity:getHeldItem(false).id ~= "minecraft:air" then
log("Item in mainhand")
end
if thisEntity:getHeldItem(true).id ~= "minecraft:air" then
log("Item in offhand")
end

getItem()

Gets an ItemStack for the item in the given slot

For the player, slots are indexed with 1 as the main hand, 2 as the off hand, and 3,4,5,6 as the 4 armor slots from the boots to the helmet

If an invalid slot number is given, this will return nil

getItem(index)

Parameters:

NameTypeDescriptionDefault
indexInteger--

Returns:

TypeDescription
ItemStack-

Example:

if thisEntity:getItem(5).id == "minecraft:elytra" then
log("You're wearing an elytra")
end

isUsingItem()

Returns true if the entity is currently using an item

isUsingItem()

Returns:

TypeDescription
Boolean-

Example:

thisEntity:isUsingItem()

Hand Functions

getActiveHand()

Returns "OFF_HAND" or "MAIN_HAND", depending on which hand this entity uses an item with

getActiveHand()

Returns:

TypeDescription
String-

Example:

thisEntity:getActiveHand() == "MAIN_HAND"

getSwingArm()

Returns "OFF_HAND" or "MAIN_HAND", based on the arm this entity is currently swinging

getSwingArm()

Returns:

TypeDescription
String-

Example:

thisEntity:getSwingArm() == "OFF_HAND"

getSwingDuration()

Returns the number of ticks this entity will have while swinging its arms

getSwingDuration()

Returns:

TypeDescription
Integer-

Example:

thisEntity:getSwingDuration()

getSwingTime()

Returns the number of ticks this entity has the arm swinging

getSwingTime()

Returns:

TypeDescription
Integer-

Example:

thisEntity:getSwingTime()

isLeftHanded()

Returns true if the entity's main hand is its left

isLeftHanded()

Returns:

TypeDescription
Boolean-

Example:

thisEntity:isLeftHanded()

isSwingingArm()

Returns true if the entity is currently swinging its arm

isSwingingArm()

Returns:

TypeDescription
Boolean-

Example:

thisEntity:isSwingingArm()

Miscellaneous

getUUID()

Gets the UUID of the proxied entity

getUUID()

Returns:

TypeDescription
String-

Example:

thisEntity:getUUID()

getVariable()

Gets the value of a variable this entity stored in themselves using the Avatar API's store() function

getVariable()

Returns:

TypeDescription
AnyType-

Example:

thisEntity:getVariable()

hasAvatar()

Returns true if Figura has an avatar loaded for this entity

hasAvatar()

Returns:

TypeDescription
Boolean-

Example:

thisEntity:hasAvatar()