MCEntity
Importing the class
It might be required for you to import the package if you encounter any issues (like casting an Array), so better be safe than sorry and add the import at the very top of the file.
Extending CapabilityProvider<MCEntity>
MCEntity extends CapabilityProvider<MCEntity>. That means all methods available in CapabilityProvider<MCEntity> are also available in MCEntity
Methods
Adds a new tag to the Entity.
There is a limit of 1024 tags per Entity.
These are not tags like MCTag
You can read more about how they can be used here: https://minecraft.wiki/w/Commands/tag
Returns: True if the tag could ba added, and it did not replace a preexisting tag. False otherwise.
Return Type: boolean
Parameter | Type | Description |
---|---|---|
Parameter tag | Type string | Description The name of the tag to add. |
Adds velocity to this Entity.
Return Type: void
Parameter | Type | Description |
---|---|---|
Parameter x | Type double | Description The amount of X velocity to add. |
Parameter y | Type double | Description The amount of Y velocity to add. |
Parameter z | Type double | Description The amount of Z velocity to add. |
Applies entity collision between this Entity and the other Entity, pushing them away from each other.
Return Type: void
Parameter | Type | Description |
---|---|---|
Parameter other | Type MCEntity | Description The Entity to collide with. |
Checks if this Entity can swim.
Returns: True if this Entity can swim. False otherwise.
Return Type: boolean
Teleports this Entity to the given world.
Return Type: void
Parameter | Type | Description |
---|---|---|
Parameter world | Type MCServerWorld | Description The new world for the Entity. |
Return Type: void
Extinguishes the Entity if it is on fire.
Return Type: void
Sets the Entity on fire for the given amount of ticks.
This method can be used to override how long the Entity is on fire for.
Return Type: void
Parameter | Type | Description |
---|---|---|
Parameter ticks | Type int | Description The amount of ticks the Entity should burn for. |
Forcefully sets this Entity to the new position.
Return Type: void
Parameter | Type | Description |
---|---|---|
Parameter x | Type double | Description The new X value. |
Parameter y | Type double | Description The new Y value. |
Parameter z | Type double | Description The new Z value. |
Gets the air value for the Entity. The air value is used to determine when the Entity will start drowning when swimming.
Returns: The air value of the Entity.
Return Type: int
Gets how bright this Entity is.
Returns: How bright the Entity is.
Return Type: float
Gets the NBT data of this Entity.
Returns: The NBT data of this Entity.
Return Type: MapData
Gets the distance between this Entity and the given Entity.
Returns: The distance between this Entity and the other Entity.
Return Type: float
Parameter | Type | Description |
---|---|---|
Parameter other | Type MCEntity | Description The Entity to get the distance to. |
Gets the squared distance from this Entity to the given Entity.
Returns: The squared distance between this Entity and the other Entity.
Return Type: double
Parameter | Type | Description |
---|---|---|
Parameter other | Type MCEntity | Description The other Entity to check the squared distance to. |
Gets the squared distance from this Entity’s position to the given position.
Returns: The squared distance from this Entity to the given position.
Return Type: double
Parameter | Type | Description |
---|---|---|
Parameter x | Type double | Description The X value of the position to check against. |
Parameter y | Type double | Description The Y value of the position to check against. |
Parameter z | Type double | Description The Z value of the position to check against. |
Gets this Entity’s id that can be used to reference this Entity.
Returns: The id of this Entity.
Return Type: int
Gets which directions the Entity is currently facing.
Returns: An array of direction that the Entity is currently facing
Return Type: Direction[]
Gets the amount of ticks the Entity will be on fire for.
Returns: The amount of ticks the Entity will be on fire for.
Return Type: int
Gets the maximum amount of time the Entity needs to be in the portal before they are teleported.
Returns: The amount of time required for the Entity to be in the nether portal before being teleported.
Return Type: int
Gets the name of the Entity.
Returns: The name of the Entity.
Return Type: string
Gets the persisted NBT tag.
Return Type: MapData
Gets this Entity’s position in the world.
Returns: This Entity’s position in the world.
Return Type: BlockPos
Return Type: MCVector3d
Return Type: float
Return Type: float
Gets all the tags that are attached to the entity.
These are not tags like MCTag
You can read more about how they can be used here: https://minecraft.wiki/w/Commands/tag
Returns: A set of all the Tags that an Entity has.
Return Type: Set<string>
Gets this Entity’s type.
Returns: The type of this Entity.
Return Type: MCEntityType
Gets the UUID of this Entity.
Returns: The UUID of this Entity.
Return Type: string
Gets the World that this Entity is in.
Returns: The World this Entity is in.
Return Type: MCWorld
Checks if this Entity has no gravity.
Returns: True if this Entity does not have gravity. False otherwise.
Return Type: boolean
Checks if this Entity is in the given range (distance) of the other Entity.
Returns: True if this Entity is in range. False otherwise.
Return Type: boolean
Parameter | Type | Description |
---|---|---|
Parameter entity | Type MCEntity | Description The Entity to check if it is in range. |
Parameter distance | Type double | Description The distance to check for. |
Checks if this Entity is immune to fire.
Returns: True if this Entity is immune to fire. False otherwise.
Return Type: boolean
Checks if this Entity is in lava or not.
Returns: True if the this Entity is in lava.
Return Type: boolean
Checks if this Entity is in water.
Returns: True if this Entity is in water. False otherwise.
Return Type: boolean
Checks if this Entity is in water or a bubble column.
Returns: True if this entity is in water or a bubble column. False otherwise.
Return Type: boolean
Checks if this Entity is in rain or a bubble column.
Returns: True if this entity is in rain or a bubble column. False otherwise.
Return Type: boolean
Checks if the offset position from the Entity’s current position is inside of a liquid.
Returns: True if the offset position is in a liquid. False otherwise.
Return Type: boolean
Parameter | Type | Description |
---|---|---|
Parameter x | Type double | Description The X offset. |
Parameter y | Type double | Description The Y offset. |
Parameter z | Type double | Description The Z offset. |
Checks whether the Entity is on the ground or not.
Returns: True if the Entity is on the ground. False otherwise.
Return Type: boolean
Checks if this Entity is silent.
Silent Entities do not play sounds.
Returns: True if this Entity is silent. False otherwise.
Return Type: boolean
Checks if this Entity is sneaking or not.
Returns: True if sneaking. False otherwise.
Return Type: boolean
Checks if this Entity is in spectator mode.
Returns: True if this Entity is in spectator mode. False otherwise.
Return Type: boolean
Checks if this Entity is wet.
Returns: True if this Entity is wet. False otherwise.
Return Type: boolean
Forcefully moves this Entity to the new position.
Return Type: void
Parameter | Type | Description |
---|---|---|
Parameter x | Type double | Description The new X value. |
Parameter y | Type double | Description The new Y value. |
Parameter z | Type double | Description The new Z value. |
Triggers the collide effect between this Entity and the player.
Some examples of collide effects are: Puffer fish damaging and applying poison. Experience orbs being collected.
Return Type: void
Parameter | Type | Description |
---|---|---|
Parameter playerEntity | Type MCPlayerEntity | Description The player to collide with. |
Can be used to simulate the /kill
command being used on the Entity.
Return Type: void
Can be used to simulate the Entity falling the given distance with the given damage multiplier.
Returns: True if the Entity took damage. False otherwise.
Return Type: boolean
Parameter | Type | Description |
---|---|---|
Parameter distance | Type float | Description The distance the Entity has fallen. |
Parameter damageMultiplier | Type float | Description The damage multiplier. |
Removes the entity from the world.
Return Type: void
Return Type: void
Removes a tag from the Entity.
These are not tags like MCTag
You can read more about how they can be used here: https://minecraft.wiki/w/Commands/tag
Returns: True if the Entity had the tag and it was removed. False otherwise.
Return Type: boolean
Parameter | Type | Description |
---|---|---|
Parameter tag | Type string | Description The name of the tag to remove. |
Sets the air value for the Entity
Return Type: void
Parameter | Type | Description |
---|---|---|
Parameter air | Type int | Description The new air value. |
This method is marked for removal next breaking change.
It sets the ID of the entity, which is only used in networking code and should never have to be called by mods or scripts.
Return Type: void
Parameter | Type | Description |
---|---|---|
Parameter id | Type int | Description 0 |
Sets the Entity on fire for the given amount of seconds.
This does not take ticks, it only takes full seconds, and you cannot lower the amount of fire ticks the entity has.
Return Type: void
Parameter | Type | Description |
---|---|---|
Parameter seconds | Type int | Description The amount of seconds the Entity should be on fire for. |
Sets the location and looking angles of the entity.
Return Type: void
Parameter | Type | Description |
---|---|---|
Parameter x | Type double | Description The new x position. |
Parameter y | Type double | Description The new y position. |
Parameter z | Type double | Description The new z position. |
Parameter yaw | Type float | Description The new yaw value. |
Parameter pitch | Type float | Description The new pitch value. |
Sets this Entity to have no gravity.
Return Type: void
Parameter | Type | Description |
---|---|---|
Parameter noGravity | Type boolean | Description The new gravity value. |
Sets if the Entity should be considered on the ground or not.
Return Type: void
Parameter | Type | Description |
---|---|---|
Parameter grounded | Type boolean | Description If the Entity is on the ground or not. |
Sets the position of this Entity.
Return Type: void
Parameter | Type | Description |
---|---|---|
Parameter x | Type double | Description The new X position of the Entity. |
Parameter y | Type double | Description The new Y position of the Entity. |
Parameter z | Type double | Description The new Z position of the Entity. |
Return Type: void
Parameter | Type | Description |
---|---|---|
Parameter x | Type double | Description No Description Provided |
Parameter y | Type double | Description No Description Provided |
Parameter z | Type double | Description No Description Provided |
Return Type: void
Parameter | Type | Description |
---|---|---|
Parameter newPitch | Type float | Description No Description Provided |
Return Type: void
Parameter | Type | Description |
---|---|---|
Parameter newYaw | Type float | Description No Description Provided |
Sets if this Entity is silent or not.
silent Entities do not play sounds.
Return Type: void
Parameter | Type | Description |
---|---|---|
Parameter isSilent | Type boolean | Description If the Entity should be silent or not. |
Sets the sneaking value of this Entity.
Return Type: void
Parameter | Type | Description |
---|---|---|
Parameter value | Type boolean | Description The new sneaking value |
Return Type: boolean
Parameter | Type | Description | Optional | DefaultValue |
---|---|---|---|---|
Parameter other | Type MCEntity | Description No Description Provided | Optional false | DefaultValue |
Parameter forced | Type boolean | Description No Description Provided | Optional true | DefaultValue false |
Teleports the entity, forcing the destination to stay loaded for a short time
Return Type: void
Parameter | Type | Description |
---|---|---|
Parameter x | Type double | Description No Description Provided |
Parameter y | Type double | Description No Description Provided |
Parameter z | Type double | Description No Description Provided |
Updates the NBT data of this Entity.
Return Type: void
Parameter | Type | Description |
---|---|---|
Parameter data | Type MapData | Description The new Data for this Entity |
Updates the persisted data.
Return Type: void
Parameter | Type | Description |
---|---|---|
Parameter data | Type MapData | Description No Description Provided |
Properties
Name | Type | Has Getter | Has Setter | Description |
---|---|---|---|---|
Name air | Type int | Has Getter true | Has Setter true | Description Gets the air value for the Entity. The air value is used to determine when the Entity will start drowning when swimming. |
Name canSwim | Type boolean | Has Getter true | Has Setter false | Description Checks if this Entity can swim. |
Name data | Type MapData | Has Getter true | Has Setter false | Description Gets the NBT data of this Entity. |
Name facingDirections | Type Direction[] | Has Getter true | Has Setter false | Description Gets which directions the Entity is currently facing. |
Name id | Type int | Has Getter true | Has Setter false | Description Gets this Entity’s id that can be used to reference this Entity. |
Name inLava | Type boolean | Has Getter true | Has Setter false | Description Checks if this Entity is in lava or not. |
Name inWater | Type boolean | Has Getter true | Has Setter false | Description Checks if this Entity is in water. |
Name isWet | Type boolean | Has Getter true | Has Setter false | Description Checks if this Entity is wet. |
Name name | Type string | Has Getter true | Has Setter false | Description Gets the name of the Entity. |
Name onGround | Type MCEntity | Has Getter true | Has Setter true | Description Sets if the Entity should be considered on the ground or not. |
Name persistedData | Type MapData | Has Getter true | Has Setter false | Description Gets the persisted NBT tag. |
Name position | Type BlockPos | Has Getter true | Has Setter false | Description Gets this Entity’s position in the world. |
Name positionVec | Type MCVector3d | Has Getter true | Has Setter false | Description No Description Provided |
Name rotationPitch | Type float | Has Getter true | Has Setter true | Description No Description Provided |
Name rotationYaw | Type float | Has Getter true | Has Setter true | Description No Description Provided |
Name silent | Type boolean | Has Getter true | Has Setter true | Description Checks if this Entity is silent. Silent Entities do not play sounds. |
Name sneaking | Type boolean | Has Getter true | Has Setter true | Description Checks if this Entity is sneaking or not. |
Name spectator | Type boolean | Has Getter true | Has Setter false | Description Checks if this Entity is in spectator mode. |
Name type | Type MCEntityType | Has Getter true | Has Setter false | Description Gets this Entity’s type. |
Name uuid | Type string | Has Getter true | Has Setter false | Description Gets the UUID of this Entity. |
Name world | Type MCWorld | Has Getter true | Has Setter false | Description Gets the World that this Entity is in. |