MCEntity
Link to mcentity
导入类
Link to 导入类
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.
ZenScript Copyimport crafttweaker.api.entity.MCEntity;
Extending CapabilityProvider<MCEntity>
Link to extending-capabilityprovidermcentity
MCEntity extends CapabilityProvider<MCEntity>. That means all methods available in CapabilityProvider<MCEntity> are also available in MCEntity
使用方式
Link to 使用方式
Name: addTag
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.fandom.com/wiki/Commands/tag
Returns: True if the tag could ba added, and it did not replace a preexisting tag. False otherwise.
Return Type: boolean
ZenScript Copy// MCEntity.addTag(tag as string) as boolean
myMCEntity.addTag("foundMesa");
参数 | 类型 | 描述 |
---|---|---|
参数 tag #标签 | 类型 string | 描述 The name of the tag to add. |
Name: addVelocity
Adds velocity to this Entity.
Return Type: void
ZenScript Copy// MCEntity.addVelocity(x as double, y as double, z as double) as void
myMCEntity.addVelocity(5, 9, -1);
参数 | 类型 | 描述 |
---|---|---|
参数 x | 类型 double | 描述 The amount of X velocity to add. |
参数 y | 类型 double | 描述 The amount of Y velocity to add. |
参数 z | 类型 double | 描述 The amount of Z velocity to add. |
Name: applyEntityCollision
Applies entity collision between this Entity and the other Entity, pushing them away from each other.
Return Type: void
ZenScript Copy// MCEntity.applyEntityCollision(other as MCEntity) as void
myMCEntity.applyEntityCollision(entity);
参数 | 类型 | 描述 |
---|---|---|
参数 other | 类型 MCEntity | 描述 The Entity to collide with. |
Name: canSwim
Checks if this Entity can swim.
Returns: True if this Entity can swim. False otherwise.
Return Type: boolean
ZenScript Copy// MCEntity.canSwim() as boolean
myMCEntity.canSwim();
Name: changeDimension
Teleports this Entity to the given world.
Return Type: void
ZenScript Copy// MCEntity.changeDimension(world as MCServerWorld) as void
myMCEntity.changeDimension(world);
参数 | 类型 | 描述 |
---|---|---|
参数 world | 类型 MCServerWorld | 描述 The new world for the Entity. |
Name: dismount
Return Type: void
ZenScript Copy// MCEntity.dismount() as void
myMCEntity.dismount();
Name: extinguish
Extinguishes the Entity if it is on fire.
Return Type: void
ZenScript Copy// MCEntity.extinguish() as void
myMCEntity.extinguish();
Name: forceFireTicks
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
ZenScript Copy// MCEntity.forceFireTicks(ticks as int) as void
myMCEntity.forceFireTicks(25);
参数 | 类型 | 描述 |
---|---|---|
参数 ticks | 类型 int | 描述 The amount of ticks the Entity should burn for. |
Name: forceSetPosition
Forcefully sets this Entity to the new position.
Return Type: void
ZenScript Copy// MCEntity.forceSetPosition(x as double, y as double, z as double) as void
myMCEntity.forceSetPosition(5, 2, 9);
参数 | 类型 | 描述 |
---|---|---|
参数 x | 类型 double | 描述 The new X value. |
参数 y | 类型 double | 描述 The new Y value. |
参数 z | 类型 double | 描述 The new Z value. |
Name: getAir
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
ZenScript Copy// MCEntity.getAir() as int
myMCEntity.getAir();
Name: getBrightness
Gets how bright this Entity is.
Returns: How bright the Entity is.
Return Type: float
ZenScript Copy// MCEntity.getBrightness() as float
myMCEntity.getBrightness();
Name: getData
Gets the NBT data of this Entity.
Returns: The NBT data of this Entity.
Return Type: MapData
ZenScript Copy// MCEntity.getData() as MapData
myMCEntity.getData();
Name: getDistance
Gets the distance between this Entity and the given Entity.
Returns: The distance between this Entity and the other Entity.
Return Type: float
ZenScript Copy// MCEntity.getDistance(other as MCEntity) as float
myMCEntity.getDistance(entity);
参数 | 类型 | 描述 |
---|---|---|
参数 other | 类型 MCEntity | 描述 The Entity to get the distance to. |
Name: getDistanceSq
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
ZenScript Copy// MCEntity.getDistanceSq(other as MCEntity) as double
myMCEntity.getDistanceSq(entity);
参数 | 类型 | 描述 |
---|---|---|
参数 other | 类型 MCEntity | 描述 The other Entity to check the squared distance to. |
Name: getDistanceSq
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
ZenScript Copy// MCEntity.getDistanceSq(x as double, y as double, z as double) as double
myMCEntity.getDistanceSq(5, 6, 3);
参数 | 类型 | 描述 |
---|---|---|
参数 x | 类型 double | 描述 The X value of the position to check against. |
参数 y | 类型 double | 描述 The Y value of the position to check against. |
参数 z | 类型 double | 描述 The Z value of the position to check against. |
Name: getEntityId
Gets this Entity's id that can be used to reference this Entity.
Returns: The id of this Entity.
Return Type: int
ZenScript Copy// MCEntity.getEntityId() as int
myMCEntity.getEntityId();
Name: getFacingDirections
Gets which directions the Entity is currently facing.
Returns: An array of direction that the Entity is currently facing
Return Type: Direction[]
ZenScript Copy// MCEntity.getFacingDirections() as Direction[]
myMCEntity.getFacingDirections();
Name: getFireTimer
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
ZenScript Copy// MCEntity.getFireTimer() as int
myMCEntity.getFireTimer();
Name: getMaxInPortalTime
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
ZenScript Copy// MCEntity.getMaxInPortalTime() as int
myMCEntity.getMaxInPortalTime();
Name: getName
Gets the name of the Entity.
Returns: The name of the Entity.
Return Type: string
ZenScript Copy// MCEntity.getName() as string
myMCEntity.getName();
Name: getPersistentData
Gets the persisted NBT tag.
Return Type: MapData
ZenScript Copy// MCEntity.getPersistentData() as MapData
myMCEntity.getPersistentData();
Name: getPosition
Gets this Entity's position in the world.
Returns: This Entity's position in the world.
Return Type: BlockPos
ZenScript Copy// MCEntity.getPosition() as BlockPos
myMCEntity.getPosition();
Name: getPositionVec
Return Type: MCVector3d
ZenScript Copy// MCEntity.getPositionVec() as MCVector3d
myMCEntity.getPositionVec();
Name: getRotationPitch
Return Type: float
ZenScript Copy// MCEntity.getRotationPitch() as float
myMCEntity.getRotationPitch();
Name: getRotationYaw
Return Type: float
ZenScript Copy// MCEntity.getRotationYaw() as float
myMCEntity.getRotationYaw();
Name: getTags
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.fandom.com/wiki/Commands/tag
Returns: A set of all the Tags that an Entity has.
Return Type: Set<string>
ZenScript Copy// MCEntity.getTags() as Set<string>
myMCEntity.getTags();
Name: getType
Gets this Entity's type.
Returns: The type of this Entity.
Return Type: MCEntityType
ZenScript Copy// MCEntity.getType() as MCEntityType
myMCEntity.getType();
Name: getUUID
Gets the UUID of this Entity.
Returns: The UUID of this Entity.
Return Type: string
ZenScript Copy// MCEntity.getUUID() as string
myMCEntity.getUUID();
Name: getWorld
Gets the World that this Entity is in.
Returns: The World this Entity is in.
Return Type: MCWorld
ZenScript Copy// MCEntity.getWorld() as MCWorld
myMCEntity.getWorld();
Name: hasNoGravity
Checks if this Entity has no gravity.
Returns: True if this Entity does not have gravity. False otherwise.
Return Type: boolean
ZenScript Copy// MCEntity.hasNoGravity() as boolean
myMCEntity.hasNoGravity();
Name: isEntityInRange
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
ZenScript Copy// MCEntity.isEntityInRange(entity as MCEntity, distance as double) as boolean
myMCEntity.isEntityInRange(entity, 2.5);
参数 | 类型 | 描述 |
---|---|---|
参数 entity | 类型 MCEntity | 描述 The Entity to check if it is in range. |
参数 distance | 类型 double | 描述 The distance to check for. |
Name: isImmuneToFire
Checks if this Entity is immune to fire.
Returns: True if this Entity is immune to fire. False otherwise.
Return Type: boolean
ZenScript Copy// MCEntity.isImmuneToFire() as boolean
myMCEntity.isImmuneToFire();
Name: isInLava
Checks if this Entity is in lava or not.
Returns: True if the this Entity is in lava.
Return Type: boolean
ZenScript Copy// MCEntity.isInLava() as boolean
myMCEntity.isInLava();
Name: isInWater
Checks if this Entity is in water.
Returns: True if this Entity is in water. False otherwise.
Return Type: boolean
ZenScript Copy// MCEntity.isInWater() as boolean
myMCEntity.isInWater();
Name: isInWaterOrBubbleColumn
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
ZenScript Copy// MCEntity.isInWaterOrBubbleColumn() as boolean
myMCEntity.isInWaterOrBubbleColumn();
Name: isInWaterRainOrBubbleColumn
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
ZenScript Copy// MCEntity.isInWaterRainOrBubbleColumn() as boolean
myMCEntity.isInWaterRainOrBubbleColumn();
Name: isOffsetPositionInLiquid
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
ZenScript Copy// MCEntity.isOffsetPositionInLiquid(x as double, y as double, z as double) as boolean
myMCEntity.isOffsetPositionInLiquid(5, 4, 5);
参数 | 类型 | 描述 |
---|---|---|
参数 x | 类型 double | 描述 The X offset. |
参数 y | 类型 double | 描述 The Y offset. |
参数 z | 类型 double | 描述 The Z offset. |
Name: isOnGround
Checks whether the Entity is on the ground or not.
Returns: True if the Entity is on the ground. False otherwise.
Return Type: boolean
ZenScript Copy// MCEntity.isOnGround() as boolean
myMCEntity.isOnGround();
Name: isSilent
Checks if this Entity is silent.
Silent Entities do not play sounds.
Returns: True if this Entity is silent. False otherwise.
Return Type: boolean
ZenScript Copy// MCEntity.isSilent() as boolean
myMCEntity.isSilent();
Name: isSneaking
Checks if this Entity is sneaking or not.
Returns: True if sneaking. False otherwise.
Return Type: boolean
ZenScript Copy// MCEntity.isSneaking() as boolean
myMCEntity.isSneaking();
Name: isSpectator
Checks if this Entity is in spectator mode.
Returns: True if this Entity is in spectator mode. False otherwise.
Return Type: boolean
ZenScript Copy// MCEntity.isSpectator() as boolean
myMCEntity.isSpectator();
Name: isWet
Checks if this Entity is wet.
Returns: True if this Entity is wet. False otherwise.
Return Type: boolean
ZenScript Copy// MCEntity.isWet() as boolean
myMCEntity.isWet();
Name: moveForced
Forcefully moves this Entity to the new position.
Return Type: void
ZenScript Copy// MCEntity.moveForced(x as double, y as double, z as double) as void
myMCEntity.moveForced(5, 2, 9);
参数 | 类型 | 描述 |
---|---|---|
参数 x | 类型 double | 描述 The new X value. |
参数 y | 类型 double | 描述 The new Y value. |
参数 z | 类型 double | 描述 The new Z value. |
Name: onCollideWithPlayer
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
ZenScript Copy// MCEntity.onCollideWithPlayer(playerEntity as MCPlayerEntity) as void
myMCEntity.onCollideWithPlayer(player);
参数 | 类型 | 描述 |
---|---|---|
参数 playerEntity | 类型 MCPlayerEntity #MC玩家实体 | 描述 The player to collide with. |
Name: onKillCommand
Can be used to simulate the /kill
command being used on the Entity.
Return Type: void
ZenScript Copy// MCEntity.onKillCommand() as void
myMCEntity.onKillCommand();
Name: onLivingFall
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
ZenScript Copy// MCEntity.onLivingFall(distance as float, damageMultiplier as float) as boolean
myMCEntity.onLivingFall(5, 5);
参数 | 类型 | 描述 |
---|---|---|
参数 distance | 类型 float | 描述 The distance the Entity has fallen. |
参数 damageMultiplier | 类型 float | 描述 The damage multiplier. |
Name: remove
Removes the entity from the world.
Return Type: void
ZenScript Copy// MCEntity.remove() as void
myMCEntity.remove();
Name: removePassengers
Return Type: void
ZenScript Copy// MCEntity.removePassengers() as void
myMCEntity.removePassengers();
Name: removeTag
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.fandom.com/wiki/Commands/tag
Returns: True if the Entity had the tag and it was removed. False otherwise.
Return Type: boolean
ZenScript Copy// MCEntity.removeTag(tag as string) as boolean
myMCEntity.removeTag("foundMesa");
参数 | 类型 | 描述 |
---|---|---|
参数 tag #标签 | 类型 string | 描述 The name of the tag to remove. |
Name: setAir
Sets the air value for the Entity
Return Type: void
ZenScript Copy// MCEntity.setAir(air as int) as void
myMCEntity.setAir(20);
参数 | 类型 | 描述 |
---|---|---|
参数 air | 类型 int | 描述 The new air value. |
Name: setEntityId
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
ZenScript Copy// MCEntity.setEntityId(id as int) as void
myMCEntity.setEntityId(0);
参数 | 类型 | 描述 |
---|---|---|
参数 id | 类型 int | 描述 0 |
Name: setFire
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
ZenScript Copy// MCEntity.setFire(seconds as int) as void
myMCEntity.setFire(5);
参数 | 类型 | 描述 |
---|---|---|
参数 seconds | 类型 int | 描述 The amount of seconds the Entity should be on fire for. |
Name: setLocationAndAngles
Sets the location and looking angles of the entity.
Return Type: void
ZenScript Copy// MCEntity.setLocationAndAngles(x as double, y as double, z as double, yaw as float, pitch as float) as void
myMCEntity.setLocationAndAngles(5, 1, 9, 90, 120);
参数 | 类型 | 描述 |
---|---|---|
参数 x | 类型 double | 描述 The new x position. |
参数 y | 类型 double | 描述 The new y position. |
参数 z | 类型 double | 描述 The new z position. |
参数 yaw | 类型 float | 描述 The new yaw value. |
参数 pitch | 类型 float | 描述 The new pitch value. |
Name: setNoGravity
Sets this Entity to have no gravity.
Return Type: void
ZenScript Copy// MCEntity.setNoGravity(noGravity as boolean) as void
myMCEntity.setNoGravity(true);
参数 | 类型 | 描述 |
---|---|---|
参数 noGravity | 类型 布尔值 | 描述 The new gravity value. |
Name: setOnGround
Sets if the Entity should be considered on the ground or not.
Return Type: void
ZenScript CopyMCEntity.setOnGround(grounded as boolean) as void
参数 | 类型 | 描述 |
---|---|---|
参数 grounded | 类型 布尔值 | 描述 If the Entity is on the ground or not. |
Name: setPosition
Sets the position of this Entity.
Return Type: void
ZenScript Copy// MCEntity.setPosition(x as double, y as double, z as double) as void
myMCEntity.setPosition(5, 2, 59);
参数 | 类型 | 描述 |
---|---|---|
参数 x | 类型 double | 描述 The new X position of the Entity. |
参数 y | 类型 double | 描述 The new Y position of the Entity. |
参数 z | 类型 double | 描述 The new Z position of the Entity. |
Name: setPositionAndUpdate
Return Type: void
ZenScript CopyMCEntity.setPositionAndUpdate(x as double, y as double, z as double) as void
参数 | 类型 | 描述 |
---|---|---|
参数 x | 类型 double | 描述 No Description Provided |
参数 y | 类型 double | 描述 No Description Provided |
参数 z | 类型 double | 描述 No Description Provided |
Name: setRotationPitch
Return Type: void
ZenScript CopyMCEntity.setRotationPitch(newPitch as float) as void
参数 | 类型 | 描述 |
---|---|---|
参数 newPitch | 类型 float | 描述 No Description Provided |
Name: setRotationYaw
Return Type: void
ZenScript CopyMCEntity.setRotationYaw(newYaw as float) as void
参数 | 类型 | 描述 |
---|---|---|
参数 newYaw | 类型 float | 描述 No Description Provided |
Name: setSilent
Sets if this Entity is silent or not.
silent Entities do not play sounds.
Return Type: void
ZenScript Copy// MCEntity.setSilent(isSilent as boolean) as void
myMCEntity.setSilent(true);
参数 | 类型 | 描述 |
---|---|---|
参数 isSilent | 类型 布尔值 | 描述 If the Entity should be silent or not. |
Name: setSneaking
Sets the sneaking value of this Entity.
Return Type: void
ZenScript Copy// MCEntity.setSneaking(value as boolean) as void
myMCEntity.setSneaking(true);
参数 | 类型 | 描述 |
---|---|---|
参数 value | 类型 布尔值 | 描述 The new sneaking value |
Name: startRiding
Return Type: boolean
ZenScript CopyMCEntity.startRiding(other as MCEntity, forced as boolean) as boolean
参数 | 类型 | 描述 | 可选 | DefaultValue |
---|---|---|---|---|
参数 other | 类型 MCEntity | 描述 No Description Provided | 可选 false | DefaultValue |
参数 forced | 类型 布尔值 | 描述 No Description Provided | 可选 true | DefaultValue false |
Name: teleportKeepLoaded
Teleports the entity, forcing the destination to stay loaded for a short time
Return Type: void
ZenScript Copy// MCEntity.teleportKeepLoaded(x as double, y as double, z as double) as void
myMCEntity.teleportKeepLoaded(20, 40, 60);
参数 | 类型 | 描述 |
---|---|---|
参数 x | 类型 double | 描述 No Description Provided |
参数 y | 类型 double | 描述 No Description Provided |
参数 z | 类型 double | 描述 No Description Provided |
Name: updateData
Updates the NBT data of this Entity.
Return Type: void
ZenScript Copy// MCEntity.updateData(data as MapData) as void
myMCEntity.updateData({key: "value"});
参数 | 类型 | 描述 |
---|---|---|
参数 data | 类型 MapData #地图数据 | 描述 The new Data for this Entity |
Name: updatePersistentData
Updates the persisted data.
Return Type: void
ZenScript CopyMCEntity.updatePersistentData(data as MapData) as void
参数 | 类型 | 描述 |
---|---|---|
参数 data | 类型 MapData #地图数据 | 描述 No Description Provided |
名称 | 类型 | 可获得 | 可设置 | 描述 |
---|---|---|---|---|
名称 air | 类型 int | 可获得 true | 可设置 true | 描述 Gets the air value for the Entity. The air value is used to determine when the Entity will start drowning when swimming. |
名称 canSwim #是否可以游泳 | 类型 布尔值 | 可获得 true | 可设置 false | 描述 Checks if this Entity can swim. |
名称 data | 类型 MapData #地图数据 | 可获得 true | 可设置 false | 描述 Gets the NBT data of this Entity. |
名称 facingDirections | 类型 Direction[] | 可获得 true | 可设置 false | 描述 Gets which directions the Entity is currently facing. |
名称 id | 类型 int | 可获得 true | 可设置 false | 描述 Gets this Entity's id that can be used to reference this Entity. |
名称 inLava | 类型 布尔值 | 可获得 true | 可设置 false | 描述 Checks if this Entity is in lava or not. |
名称 inWater | 类型 布尔值 | 可获得 true | 可设置 false | 描述 Checks if this Entity is in water. |
名称 isWet | 类型 布尔值 | 可获得 true | 可设置 false | 描述 Checks if this Entity is wet. |
名称 name(名称) | 类型 string | 可获得 true | 可设置 false | 描述 Gets the name of the Entity. |
名称 onGround | 类型 MCEntity | 可获得 true | 可设置 true | 描述 Sets if the Entity should be considered on the ground or not. |
名称 persistedData | 类型 MapData #地图数据 | 可获得 true | 可设置 false | 描述 Gets the persisted NBT tag. |
名称 position | 类型 BlockPos | 可获得 true | 可设置 false | 描述 Gets this Entity's position in the world. |
名称 positionVec | 类型 MCVector3d | 可获得 true | 可设置 false | 描述 No Description Provided |
名称 rotationPitch | 类型 float | 可获得 true | 可设置 true | 描述 No Description Provided |
名称 rotationYaw | 类型 float | 可获得 true | 可设置 true | 描述 No Description Provided |
名称 silent | 类型 布尔值 | 可获得 true | 可设置 true | 描述 Checks if this Entity is silent. Silent Entities do not play sounds. |
名称 sneaking | 类型 布尔值 | 可获得 true | 可设置 true | 描述 Checks if this Entity is sneaking or not. |
名称 spectator | 类型 布尔值 | 可获得 true | 可设置 false | 描述 Checks if this Entity is in spectator mode. |
名称 类型 | 类型 MCEntityType #MC实体类型 | 可获得 true | 可设置 false | 描述 Gets this Entity's type. |
名称 uuid | 类型 string | 可获得 true | 可设置 false | 描述 Gets the UUID of this Entity. |
名称 world | 类型 MCWorld | 可获得 true | 可设置 false | 描述 Gets the World that this Entity is in. |