Class EntityLiving

All Implemented Interfaces:
EntityDamageable, Metadatable, Cloneable
Direct Known Subclasses:
EntityCreature, EntityNPCEntity

public abstract class EntityLiving extends Entity implements EntityDamageable
Author:
MagicDroidX (Nukkit Project)
  • Field Details

    • DEFAULT_SPEED

      public static final float DEFAULT_SPEED
      See Also:
    • attackTime

      protected int attackTime
    • invisible

      protected boolean invisible
    • movementSpeed

      protected float movementSpeed
    • turtleTicks

      protected int turtleTicks
  • Constructor Details

  • Method Details

    • getGravity

      protected float getGravity()
      Overrides:
      getGravity in class Entity
    • getDrag

      protected float getDrag()
      Overrides:
      getDrag in class Entity
    • initEntity

      protected void initEntity()
      Description copied from class: Entity
      实体初始化顺序,先初始化Entity类字段->Entity构造函数->进入init方法->调用initEntity方法->子类字段初始化->子类构造函数

      用于初始化实体的NBT和实体字段的方法

      Entity initialization order, first initialize the Entity class field->Entity constructor->Enter the init method->Call the init Entity method-> subclass field initialization-> subclass constructor

      The method used to initialize the NBT and entity fields of the entity

      Overrides:
      initEntity in class Entity
    • setHealth

      public void setHealth(float health)
      Overrides:
      setHealth in class Entity
    • saveNBT

      public void saveNBT()
      Overrides:
      saveNBT in class Entity
    • hasLineOfSight

      public boolean hasLineOfSight(Entity entity)
    • collidingWith

      public void collidingWith(Entity ent)
    • attack

      @PowerNukkitDifference(info="Using new method to play sounds", since="1.4.0.0-PN") public boolean attack(EntityDamageEvent source)
      Description copied from class: Entity
      当一个实体被攻击时(即接受一个实体伤害事件 这个事件可以是由其他实体攻击导致,也可能是自然伤害)调用.

      Called when an entity is attacked (i.e. receives an entity damage event. This event can be caused by an attack by another entity, or it can be a natural damage).

      Overrides:
      attack in class Entity
      Parameters:
      source - 记录伤害源的事件
      Record the event of the source of the attack
      Returns:
      是否攻击成功
      Whether the attack was successful
    • knockBack

      public void knockBack(Entity attacker, double damage, double x, double z)
    • knockBack

      public void knockBack(Entity attacker, double damage, double x, double z, double base)
    • kill

      public void kill()
      Overrides:
      kill in class Entity
    • entityBaseTick

      public boolean entityBaseTick()
      Overrides:
      entityBaseTick in class Entity
    • entityBaseTick

      public boolean entityBaseTick(int tickDiff)
      Overrides:
      entityBaseTick in class Entity
    • getDrops

      public Item[] getDrops()
    • getLineOfSight

      public Block[] getLineOfSight(int maxDistance)
    • getLineOfSight

      public Block[] getLineOfSight(int maxDistance, int maxLength)
    • getLineOfSight

      @Deprecated public Block[] getLineOfSight(int maxDistance, int maxLength, Map<Integer,Object> transparent)
      Deprecated.
    • getLineOfSight

      public Block[] getLineOfSight(int maxDistance, int maxLength, Integer[] transparent)
    • getTargetBlock

      public Block getTargetBlock(int maxDistance)
    • getTargetBlock

      @Deprecated public Block getTargetBlock(int maxDistance, Map<Integer,Object> transparent)
      Deprecated.
    • getTargetBlock

      public Block getTargetBlock(int maxDistance, Integer[] transparent)
    • getMovementSpeed

      public float getMovementSpeed()
    • setMovementSpeed

      public void setMovementSpeed(float speed)
      设置该有生命实体的移动速度

      Set the movement speed of this Entity.

      Parameters:
      speed - 速度大小
      Speed value
    • getAirTicks

      public int getAirTicks()
    • setAirTicks

      public void setAirTicks(int ticks)
    • blockedByShield

      @PowerNukkitOnly @Since("1.4.0.0-PN") protected boolean blockedByShield(EntityDamageEvent source)
    • onBlock

      @PowerNukkitOnly @PowerNukkitXDifference(since="1.19.21-r4", info="add EntityDamageEvent param to help cal the armor damage") protected void onBlock(Entity entity, EntityDamageEvent event, boolean animate)
    • isBlocking

      @PowerNukkitOnly public boolean isBlocking()
    • setBlocking

      @PowerNukkitOnly public void setBlocking(boolean value)
    • isPersistent

      @PowerNukkitOnly @Since("1.4.0.0-PN") public boolean isPersistent()
    • setPersistent

      @PowerNukkitOnly @Since("1.4.0.0-PN") public void setPersistent(boolean persistent)
    • preAttack

      @PowerNukkitOnly @Since("1.4.0.0-PN") public void preAttack(Player player)
    • postAttack

      @PowerNukkitOnly @Since("1.4.0.0-PN") public void postAttack(Player player)
    • getAttackTime

      @PowerNukkitXOnly @Since("1.6.0.0-PNX") public int getAttackTime()
    • isAttackTimeByShieldKb

      @PowerNukkitXOnly @Since("1.6.0.0-PNX") public boolean isAttackTimeByShieldKb()
    • getAttackTimeBefore

      @PowerNukkitXOnly @Since("1.6.0.0-PNX") public int getAttackTimeBefore()