接口 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

public interface Entity extends Metadatable, CommandSender, Nameable
Represents a base entity in the world
  • 方法详细资料

    • getLocation

      Location getLocation()
      Gets the entity's current position
      返回:
      a new copy of Location containing the position of this entity
    • getLocation

      Location getLocation(Location loc)
      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

      void setVelocity(Vector velocity)
      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

      boolean teleport(Location location)
      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

      boolean teleport(Location location, PlayerTeleportEvent.TeleportCause cause)
      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
      cause - The cause of this teleportation
      返回:
      true if the teleport was successful
    • teleport

      boolean teleport(Entity destination)
      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

      boolean teleport(Entity destination, PlayerTeleportEvent.TeleportCause cause)
      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
      cause - The cause of this teleportation
      返回:
      true if the teleport was successful
    • getNearbyEntities

      List<Entity> getNearbyEntities(double x, double y, double z)
      Returns a list of entities within a bounding box centered around this entity
      参数:
      x - 1/2 the size of the box along x axis
      y - 1/2 the size of the box along y axis
      z - 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 the Server that contains this Entity
      指定者:
      getServer 在接口中 CommandSender
      返回:
      Server instance running this Entity
    • getPassenger

      @Deprecated Entity getPassenger()
      已过时。
      entities may have multiple passengers, use getPassengers()
      Gets the primary passenger of a vehicle. For vehicles that could have multiple passengers, this will only return the primary passenger.
      返回:
      an entity
    • setPassenger

      @Deprecated boolean setPassenger(Entity passenger)
      已过时。
      entities may have multiple passengers, use getPassengers()
      Set the passenger of a vehicle.
      参数:
      passenger - The new passenger.
      返回:
      false if it could not be done for whatever reason
    • getPassengers

      List<Entity> 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

      boolean addPassenger(Entity passenger)
      Add a passenger to the vehicle.
      参数:
      passenger - The passenger to add
      返回:
      false if it could not be done for whatever reason
    • removePassenger

      boolean removePassenger(Entity passenger)
      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

      void setLastDamageCause(EntityDamageEvent event)
      Record the last EntityDamageEvent inflicted on this entity
      参数:
      event - a EntityDamageEvent
    • getLastDamageCause

      EntityDamageEvent getLastDamageCause()
      Retrieve the last EntityDamageEvent 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

      void playEffect(EntityEffect type)
      Performs the specified EntityEffect 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

      Set<String> 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

      boolean addScoreboardTag(String tag)
      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

      boolean removeScoreboardTag(String tag)
      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