Skip to main content

Entity

The main entity object for BeAPI

warning

You should never have to construct this class yourself.

Constructor​

new Entity(client, entity);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
clientClient❌nullConstructed Client instance.
entityIEntity❌nullMinecraft IEntity Object.

Methods​

destroy​

Destroys the entity object.

destroy();

Returns​

void


getIEntity​

Returns the vanilla entity object.

getIEntity();

Returns​

IEntity


getRuntimeId​

Returns the entity's runtime id.

getRuntimeId();

Returns​

number


getId​

Returns the entity's mob id.

getId();

Returns​

string


getNameTag​

Returns the entity's above head name.

getNameTag();

Returns​

string


setNameTag​

Sets the entity's above head name.

setNameTag(nametag);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
nametagstring❌undefinedNametag for the entity.

Returns​

void


getTags​

Returns the all the tags on the entity.

getTags();

Returns​

string[]


hasTag​

Checks if a entity has a specific tag.

hasTag(tag);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
tagstring❌undefinedThe tag to check for.

Returns​

boolean


addTag​

Adds a tag to the entity.

addTag(tag);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
tagstring❌undefinedThe tag to add.

Returns​

boolean


removeTag​

Removes a tag from the entity.

removeTag(tag);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
tagstring❌undefinedThe tag to remove.

Returns​

boolean


executeCommand​

Executes a command as the entity.

executeCommand(cmd, debug);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
cmdstring❌undefinedMinecraft command to execute.
debugboolean?✔️falsePipe logs to debug console.

Returns​

ServerCommandResponse


getScore​

Gets the score of an objective.

getScore(objective);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
objectivestring❌undefinedThe scoreboard objective name.

Returns​

number


getLocation​

Gets the entity's current location.

getLocation();

Returns​

Location


getDimension​

Gets the entity's current dimension.

getDimension();

Returns​

IDimension


getDimensionName​

Gets the entity's current dimension name.

getDimensionName();

Returns​

Dimension


getInventory​

Gets the entity's inventory.

getInventory();

Returns​

Inventory | undefined


getHealth​

Gets the entity's health.

getHealth();

Returns​

Health


getVelocity​

Gets the entity's current velocity.

getVelocity();

Returns​

Vector


setVelocity​

Sets the entity's velocity.

setVelocity(velocity);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
velocityVector❌undefinedThe velocity vector.

Returns​

void


teleport​

Teleports the entity.

teleport(location, dimension, xrot, yrot);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
locationILocation❌undefinedThe location to be teleported.
dimensionIDimension❌undefinedThe dimension to be teleported.
xrotnumber❌undefinedThe xrot of the entity.
yrotnumber❌undefinedThe yrot of the entity.

Returns​

void


teleportFacing​

Teleports the entity facing a direction.

teleportFacing(location, dimension, facingLocaton);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
locationILocation❌undefinedThe location to be teleported.
dimensionIDimension❌undefinedThe dimension to be teleported.
facingLocationILocation❌undefinedThe facing location to be teleported.

Returns​

void


triggerEvent​

Triggers a entity event from the entity.json.

triggerEvent(event);
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
eventstring❌undefinedThe event to be triggered.

Returns​

void


getRotation​

Gets the rotation of the entity.

getRotation();

Returns​

number


getHeadLocation​

Gets the location of the entity's head.

getHeadLocation();

Returns​

ILocation