Skip to main content

Entity

Acts as a proxy for an entity in the Minecraft world

For this page assume:

local thisEntity = thisEntity:getTargetedEntity()

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

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

Example:

thisEntity:getRot()

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

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

Example:

thisEntity:getVelocity()

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

Entity Actions


getPose()

Returns the current pose of the entity

Example:

thisEntity:getPose() == "CROUCHING"

isCrouching()

Returns true if this entity is visually sneaking

Example:

thisEntity:isCrouching()

isSneaking()

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

Example:

thisEntity:isSneaking()

isSprinting()

Returns true if this entity is currently sprinting

Example:

thisEntity:isSprinting()

isLoaded()

Checks if this entity object is still being updated and loaded

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

Example:

thisEntity:isLoaded()

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 server side

Example:

thisEntity:getNbt()

getName()

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

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

Example:

thisEntity:getName()

isAlive()

Returns whether this entity is alive or not

Example:

thisEntity:isAlive()

getType()

Gets the Minecraft identifier of this entity

For instance, "minecraft:pig"

Example:

thisEntity:getType() == "minecraft:pig"

getControlledVehicle()

Return the vehicle that this entity is controlling

Example:

thisEntity:getControlledVehicle()

getControllingPassenger()

Returns the entity that is controlling this entity

Example:

thisEntity:getControllingPassenger()

getPassengers()

Returns a List of entities of all passengers this entity have

Example:

thisEntity:getPassengers()

getFrozenTicks()

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

Example:

thisEntity:getFrozenTicks()

getMaxAir()

Gets the maximum amount of air this entity can have

Example:

thisEntity:getMaxAir()

getDimensionName()

Gets the Minecraft identifier of the dimension this entity is in

Example:

thisEntity:getDimensionName()

isUnderwater()

Returns true if this entity's eyes are touching water

Example:

thisEntity:isUnderwater()

isInWater()

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

Example:

thisEntity:isInWater()

isInRain()

Returns true if this entity is currently standing in rain

Example:

thisEntity:isInRain()

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

Example:

thisEntity:isWet()

isInLava()

Returns true if this entity is currently in lava

Example:

thisEntity:isInLava()

isOnFire()

Returns true if this entity is currently on fire

Example:

thisEntity:isOnFire()

isInvisible()

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

Example:

thisEntity:isInvisible()

getVehicle()

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

If the entity isn't riding anything, returns nil

Example combined with getType and with a nil check, the first thisEntity:getVehicle() is preventing a nil value from being check by getType() after the and:

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

isSilent()

Returns true if this entity is silent

Example:

thisEntity:isSilent()

isGlowing()

Returns true if this entity is currently glowing

Example:

thisEntity:isGlowing()

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

Example:

thisEntity:getBoundingBox()

isOnGround()

Returns whether or not this entity is currently on the ground

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. One workaround is to check the block state of the block directly underneath the entity, like so: world.getBlockState(thisEntity:getPos():add(0,-0.1,0)):isSolidBlock()

Example:

thisEntity:isOnGround()

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

Example:

thisEntity:getEyeY()

getEyeHeight()

Returns the current eye height of this entity

Example:

thisEntity:getEyeHeight()

getTargetedEntity(number)

Returns a proxy for your currently targeted Entity

This Entity appears on the F3 screen

The number is for distance in blocks to check

Maximum and Default distance is 20, Minimum is 0

Example with a nil check:

if thisEntity:getTargetedEntity(4.5) and thisEntity:getTargetedEntity(4.5):getType() == "minecraft:creeper" then
log("You're looking at a creeper")
end

getTargetedBlock(bool, number)

Returns a proxy for your currently targeted BlockState

This BlockState appears on the F3 screen

The bool is for ignoring liquids and the number is the distance in blocks to check

Maximum and Default distance is 20, Minimum is -20

Returns a vararg of the block, the hit position and the block face the hit collided

Example:

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

hasInventory()

Checks if the entity has an inventory (Horses, Camels, Llamas, ...)

Example:

thisEntity:hasInventory()

hasContainer()

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

Example:

thisEntity:hasContainer()

isLiving()

Gets if this entity is a Living Entity

Example:

thisEntity:isLiving()

isPlayer()

Gets if this entity is a Player Entity

Example:

thisEntity:isPlayer()

getPermissionLevel()

Returns the permission level number of this entity

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

Example:

thisEntity:getPermissionLevel()

Item Functions


getItem(integer)

Gets an ItemStack for the item in the given slot

For entities, 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

Example:

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

Miscellaneous


getUUID()

Gets the UUID of the proxied entity

Example:

thisEntity:getUUID()

hasAvatar()

Returns true if Figura has an avatar loaded for this entity

Example:

thisEntity:hasAvatar()

getVariable()

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

Example:

thisEntity:getVariable()