接口 Entity
- 所有超级接口:
CommandSender
,Metadatable
,Nameable
,Permissible
,ServerOperator
- 所有已知子接口:
AbstractHorse
,Ageable
,Ambient
,Animals
,AreaEffectCloud
,ArmorStand
,Arrow
,Bat
,Blaze
,Boat
,CaveSpider
,ChestedHorse
,Chicken
,CommandMinecart
,ComplexEntityPart
,ComplexLivingEntity
,Cow
,Creature
,Creeper
,Damageable
,Donkey
,DragonFireball
,Egg
,ElderGuardian
,EnderCrystal
,EnderDragon
,EnderDragonPart
,Enderman
,Endermite
,EnderPearl
,EnderSignal
,Evoker
,EvokerFangs
,ExperienceOrb
,Explosive
,ExplosiveMinecart
,FallingBlock
,Fireball
,Firework
,Fish
,FishHook
,Flying
,Ghast
,Giant
,Golem
,Guardian
,Hanging
,HopperMinecart
,Horse
,HumanEntity
,Husk
,Illager
,Illusioner
,IronGolem
,Item
,ItemFrame
,LargeFireball
,LeashHitch
,LightningStrike
,LingeringPotion
,LivingEntity
,Llama
,LlamaSpit
,MagmaCube
,Minecart
,Monster
,Mule
,MushroomCow
,NPC
,Ocelot
,Painting
,Parrot
,Pig
,PigZombie
,Player
,PolarBear
,PoweredMinecart
,Projectile
,Rabbit
,RideableMinecart
,Sheep
,Shulker
,ShulkerBullet
,Silverfish
,Skeleton
,SkeletonHorse
,Slime
,SmallFireball
,Snowball
,Snowman
,SpawnerMinecart
,SpectralArrow
,Spellcaster
,Spider
,SplashPotion
,Squid
,StorageMinecart
,Stray
,Tameable
,ThrownExpBottle
,ThrownPotion
,TippedArrow
,TNTPrimed
,Vehicle
,Vex
,Villager
,Vindicator
,WaterMob
,Weather
,Witch
,Wither
,WitherSkeleton
,WitherSkull
,Wolf
,Zombie
,ZombieHorse
,ZombieVillager
-
方法概要
修饰符和类型方法说明boolean
addPassenger
(Entity passenger) Add a passenger to the vehicle.boolean
addScoreboardTag
(String tag) Add a tag to this entity.boolean
eject()
Eject any passenger.int
Returns a unique id for this entityfloat
Returns the distance this entity has fallenint
Returns the entity's current fire ticks (ticks before the entity stops being on fire).double
Gets the entity's heightRetrieve the lastEntityDamageEvent
inflicted on this entity.Gets the entity's current positiongetLocation
(Location loc) Stores the entity's current position in the provided Location object.int
Returns the entity's maximum fire ticks.getNearbyEntities
(double x, double y, double z) Returns a list of entities within a bounding box centered around this entity已过时。Gets a list of passengers of this vehicle.Returns the reaction of the entity when moved by a piston.int
Gets the period of time (in ticks) before this entity can use a portal.Returns a set of tags for this entity.Gets theServer
that contains this Entityint
Gets the amount of ticks this entity has lived for.getType()
Get the type of the entity.Returns a unique and persistent id for this entityGet the vehicle that this player is inside.Gets this entity's current velocitydouble
getWidth()
Gets the entity's widthgetWorld()
Gets the current world this entity resides inboolean
Returns whether gravity applies to this entity.boolean
Gets whether or not the mob's custom name is displayed client side.boolean
isDead()
Returns true if this entity has been marked for removal.boolean
isEmpty()
Check if a vehicle has passengers.boolean
Gets whether the entity is glowing or not.boolean
Returns whether this entity is inside a vehicle.boolean
Gets whether the entity is invulnerable or not.boolean
Returns true if the entity is supported by a block.boolean
isSilent()
Gets whether the entity is silent or not.boolean
isValid()
Returns false if the entity has died or been despawned for some other reason.boolean
Leave the current vehicle.void
playEffect
(EntityEffect type) Performs the specifiedEntityEffect
for this entity.void
remove()
Mark the entity's removal.boolean
removePassenger
(Entity passenger) Remove a passenger from the vehicle.boolean
Removes a given tag from this entity.void
setCustomNameVisible
(boolean flag) Sets whether or not to display the mob's custom name client side.void
setFallDistance
(float distance) Sets the fall distance for this entityvoid
setFireTicks
(int ticks) Sets the entity's current fire ticks (ticks before the entity stops being on fire).void
setGlowing
(boolean flag) Sets whether the entity has a team colored (default: white) glow.void
setGravity
(boolean gravity) Sets whether gravity applies to this entity.void
setInvulnerable
(boolean flag) Sets whether the entity is invulnerable or not.void
Record the lastEntityDamageEvent
inflicted on this entityboolean
setPassenger
(Entity passenger) 已过时。entities may have multiple passengers, usegetPassengers()
void
setPortalCooldown
(int cooldown) Sets the period of time (in ticks) before this entity can use a portal.void
setSilent
(boolean flag) Sets whether the entity is silent or not.void
setTicksLived
(int value) Sets the amount of ticks this entity has lived for.void
setVelocity
(Vector velocity) Sets this entity's velocityboolean
Teleports this entity to the target Entity.boolean
teleport
(Entity destination, PlayerTeleportEvent.TeleportCause cause) Teleports this entity to the target Entity.boolean
Teleports this entity to the given location.boolean
teleport
(Location location, PlayerTeleportEvent.TeleportCause cause) Teleports this entity to the given location.从接口继承的方法 org.bukkit.command.CommandSender
getName, sendMessage, sendMessage
从接口继承的方法 org.bukkit.metadata.Metadatable
getMetadata, hasMetadata, removeMetadata, setMetadata
从接口继承的方法 org.bukkit.Nameable
getCustomName, setCustomName
从接口继承的方法 org.bukkit.permissions.Permissible
addAttachment, addAttachment, addAttachment, addAttachment, getEffectivePermissions, hasPermission, hasPermission, isPermissionSet, isPermissionSet, recalculatePermissions, removeAttachment
从接口继承的方法 org.bukkit.permissions.ServerOperator
isOp, setOp
-
方法详细资料
-
getLocation
Location getLocation()Gets the entity's current position- 返回:
- a new copy of Location containing the position of this entity
-
getLocation
Stores the entity's current position in the provided Location object.If the provided Location is null this method does nothing and returns null.
- 参数:
loc
- the location to copy into- 返回:
- The Location object provided or null
-
setVelocity
Sets this entity's velocity- 参数:
velocity
- New velocity to travel with
-
getVelocity
Vector getVelocity()Gets this entity's current velocity- 返回:
- Current traveling velocity of this entity
-
getHeight
double getHeight()Gets the entity's height- 返回:
- height of entity
-
getWidth
double getWidth()Gets the entity's width- 返回:
- width of entity
-
isOnGround
boolean isOnGround()Returns true if the entity is supported by a block. This value is a state updated by the server and is not recalculated unless the entity moves.- 返回:
- True if entity is on ground.
-
getWorld
World getWorld()Gets the current world this entity resides in- 返回:
- World
-
teleport
Teleports this entity to the given location. If this entity is riding a vehicle, it will be dismounted prior to teleportation.- 参数:
location
- New location to teleport this entity to- 返回:
true
if the teleport was successful
-
teleport
Teleports this entity to the given location. If this entity is riding a vehicle, it will be dismounted prior to teleportation.- 参数:
location
- New location to teleport this entity tocause
- The cause of this teleportation- 返回:
true
if the teleport was successful
-
teleport
Teleports this entity to the target Entity. If this entity is riding a vehicle, it will be dismounted prior to teleportation.- 参数:
destination
- Entity to teleport this entity to- 返回:
true
if the teleport was successful
-
teleport
Teleports this entity to the target Entity. If this entity is riding a vehicle, it will be dismounted prior to teleportation.- 参数:
destination
- Entity to teleport this entity tocause
- The cause of this teleportation- 返回:
true
if the teleport was successful
-
getNearbyEntities
Returns a list of entities within a bounding box centered around this entity- 参数:
x
- 1/2 the size of the box along x axisy
- 1/2 the size of the box along y axisz
- 1/2 the size of the box along z axis- 返回:
List<Entity>
List of entities nearby
-
getEntityId
int getEntityId()Returns a unique id for this entity- 返回:
- Entity id
-
getFireTicks
int getFireTicks()Returns the entity's current fire ticks (ticks before the entity stops being on fire).- 返回:
- int fireTicks
-
getMaxFireTicks
int getMaxFireTicks()Returns the entity's maximum fire ticks.- 返回:
- int maxFireTicks
-
setFireTicks
void setFireTicks(int ticks) Sets the entity's current fire ticks (ticks before the entity stops being on fire).- 参数:
ticks
- Current ticks remaining
-
remove
void remove()Mark the entity's removal. -
isDead
boolean isDead()Returns true if this entity has been marked for removal.- 返回:
- True if it is dead.
-
isValid
boolean isValid()Returns false if the entity has died or been despawned for some other reason.- 返回:
- True if valid.
-
getServer
Server getServer()Gets theServer
that contains this Entity- 指定者:
getServer
在接口中CommandSender
- 返回:
- Server instance running this Entity
-
getPassenger
已过时。entities may have multiple passengers, usegetPassengers()
Gets the primary passenger of a vehicle. For vehicles that could have multiple passengers, this will only return the primary passenger.- 返回:
- an entity
-
setPassenger
已过时。entities may have multiple passengers, usegetPassengers()
Set the passenger of a vehicle.- 参数:
passenger
- The new passenger.- 返回:
- false if it could not be done for whatever reason
-
getPassengers
Gets a list of passengers of this vehicle.The returned list will not be directly linked to the entity's current passengers, and no guarantees are made as to its mutability.
- 返回:
- list of entities corresponding to current passengers.
-
addPassenger
Add a passenger to the vehicle.- 参数:
passenger
- The passenger to add- 返回:
- false if it could not be done for whatever reason
-
removePassenger
Remove a passenger from the vehicle.- 参数:
passenger
- The passenger to remove- 返回:
- false if it could not be done for whatever reason
-
isEmpty
boolean isEmpty()Check if a vehicle has passengers.- 返回:
- True if the vehicle has no passengers.
-
eject
boolean eject()Eject any passenger.- 返回:
- True if there was a passenger.
-
getFallDistance
float getFallDistance()Returns the distance this entity has fallen- 返回:
- The distance.
-
setFallDistance
void setFallDistance(float distance) Sets the fall distance for this entity- 参数:
distance
- The new distance.
-
setLastDamageCause
Record the lastEntityDamageEvent
inflicted on this entity- 参数:
event
- aEntityDamageEvent
-
getLastDamageCause
EntityDamageEvent getLastDamageCause()Retrieve the lastEntityDamageEvent
inflicted on this entity. This event may have been cancelled.- 返回:
- the last known
EntityDamageEvent
or null if hitherto unharmed
-
getUniqueId
UUID getUniqueId()Returns a unique and persistent id for this entity- 返回:
- unique id
-
getTicksLived
int getTicksLived()Gets the amount of ticks this entity has lived for.This is the equivalent to "age" in entities.
- 返回:
- Age of entity
-
setTicksLived
void setTicksLived(int value) Sets the amount of ticks this entity has lived for.This is the equivalent to "age" in entities. May not be less than one tick.
- 参数:
value
- Age of entity
-
playEffect
Performs the specifiedEntityEffect
for this entity.This will be viewable to all players near the entity.
If the effect is not applicable to this class of entity, it will not play.
- 参数:
type
- Effect to play.
-
getType
EntityType getType()Get the type of the entity.- 返回:
- The entity type.
-
isInsideVehicle
boolean isInsideVehicle()Returns whether this entity is inside a vehicle.- 返回:
- True if the entity is in a vehicle.
-
leaveVehicle
boolean leaveVehicle()Leave the current vehicle. If the entity is currently in a vehicle (and is removed from it), true will be returned, otherwise false will be returned.- 返回:
- True if the entity was in a vehicle.
-
getVehicle
Entity getVehicle()Get the vehicle that this player is inside. If there is no vehicle, null will be returned.- 返回:
- The current vehicle.
-
setCustomNameVisible
void setCustomNameVisible(boolean flag) Sets whether or not to display the mob's custom name client side. The name will be displayed above the mob similarly to a player.This value has no effect on players, they will always display their name.
- 参数:
flag
- custom name or not
-
isCustomNameVisible
boolean isCustomNameVisible()Gets whether or not the mob's custom name is displayed client side.This value has no effect on players, they will always display their name.
- 返回:
- if the custom name is displayed
-
setGlowing
void setGlowing(boolean flag) Sets whether the entity has a team colored (default: white) glow.- 参数:
flag
- if the entity is glowing
-
isGlowing
boolean isGlowing()Gets whether the entity is glowing or not.- 返回:
- whether the entity is glowing
-
setInvulnerable
void setInvulnerable(boolean flag) Sets whether the entity is invulnerable or not.When an entity is invulnerable it can only be damaged by players in creative mode.
- 参数:
flag
- if the entity is invulnerable
-
isInvulnerable
boolean isInvulnerable()Gets whether the entity is invulnerable or not.- 返回:
- whether the entity is
-
isSilent
boolean isSilent()Gets whether the entity is silent or not.- 返回:
- whether the entity is silent.
-
setSilent
void setSilent(boolean flag) Sets whether the entity is silent or not.When an entity is silent it will not produce any sound.
- 参数:
flag
- if the entity is silent
-
hasGravity
boolean hasGravity()Returns whether gravity applies to this entity.- 返回:
- whether gravity applies
-
setGravity
void setGravity(boolean gravity) Sets whether gravity applies to this entity.- 参数:
gravity
- whether gravity should apply
-
getPortalCooldown
int getPortalCooldown()Gets the period of time (in ticks) before this entity can use a portal.- 返回:
- portal cooldown ticks
-
setPortalCooldown
void setPortalCooldown(int cooldown) Sets the period of time (in ticks) before this entity can use a portal.- 参数:
cooldown
- portal cooldown ticks
-
getScoreboardTags
Returns a set of tags for this entity.
Entities can have no more than 1024 tags.- 返回:
- a set of tags for this entity
-
addScoreboardTag
Add a tag to this entity.
Entities can have no more than 1024 tags.- 参数:
tag
- the tag to add- 返回:
- true if the tag was successfully added
-
removeScoreboardTag
Removes a given tag from this entity.- 参数:
tag
- the tag to remove- 返回:
- true if the tag was successfully removed
-
getPistonMoveReaction
PistonMoveReaction getPistonMoveReaction()Returns the reaction of the entity when moved by a piston.- 返回:
- reaction
-
getPassengers()