Class EntityPhysical

All Implemented Interfaces:
EntityAgeable, EntityAsyncPrepare, EntityDamageable, EntityNameable, Metadatable, Cloneable
Direct Known Subclasses:
EntityIntelligent

@PowerNukkitXOnly @Since("1.6.0.0-PNX") public abstract class EntityPhysical extends EntityCreature implements EntityAsyncPrepare
  • Field Details

    • PRECISION

      public static final float PRECISION
      移动精度阈值,绝对值小于此阈值的移动被视为没有移动
      See Also:
    • globalCycleTickSpread

      public static final AtomicInteger globalCycleTickSpread
    • tickSpread

      public final int tickSpread
      时间泛播延迟,用于缓解在同一时间大量提交任务挤占cpu的情况
    • offsetBoundingBox

      protected final AxisAlignedBB offsetBoundingBox
      提供实时最新碰撞箱位置
    • previousCollideMotion

      protected final Vector3 previousCollideMotion
    • previousCurrentMotion

      protected final Vector3 previousCurrentMotion
    • fallingTick

      protected int fallingTick
      实体自由落体运动的时间
    • needsRecalcMovement

      protected boolean needsRecalcMovement
  • Constructor Details

  • Method Details

    • asyncPrepare

      public void asyncPrepare(int currentTick)
      Description copied from interface: EntityAsyncPrepare
      该方法将被并行执行,每一刻都执行一次,并保证每一次onUpdate之前都执行完毕
      Specified by:
      asyncPrepare in interface EntityAsyncPrepare
      Parameters:
      currentTick - 当前游戏刻
    • onUpdate

      public boolean onUpdate(int currentTick)
      Overrides:
      onUpdate in class Entity
    • entityBaseTick

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

      public boolean entityBaseTick(int tickDiff)
      Overrides:
      entityBaseTick in class EntityLiving
    • canBeMovedByCurrents

      public boolean canBeMovedByCurrents()
      Description copied from class: Entity
      Returns whether this entity can be moved by currents in liquids.
      Overrides:
      canBeMovedByCurrents in class Entity
      Returns:
      boolean
    • updateMovement

      public void updateMovement()
      Overrides:
      updateMovement in class Entity
    • isFalling

      @PowerNukkitXOnly @Since("1.19.60-r1") public boolean isFalling()
    • addTmpMoveMotion

      public final void addTmpMoveMotion(Vector3 tmpMotion)
    • addTmpMoveMotionXZ

      public final void addTmpMoveMotionXZ(Vector3 tmpMotion)
    • handleGravity

      protected void handleGravity()
    • handleGroundFrictionMovement

      @Since("1.19.60-r1") protected void handleGroundFrictionMovement()
      计算地面摩擦力
    • handlePassableBlockFrictionMovement

      @Since("1.19.60-r1") protected void handlePassableBlockFrictionMovement()
      计算流体阻力(空气/液体)
    • getGroundFrictionFactor

      @Since("1.19.60-r1") public double getGroundFrictionFactor()
      计算当前位置的地面摩擦因子
      Returns:
      当前位置的地面摩擦因子
    • getPassableBlockFrictionFactor

      @Since("1.19.60-r1") public double getPassableBlockFrictionFactor()
      计算当前位置的流体阻力因子(空气/水)
      Returns:
      当前位置的流体阻力因子
    • handleLiquidMovement

      protected void handleLiquidMovement()
      默认使用nk内置实现,这只是个后备算法
    • addPreviousLiquidMovement

      protected void addPreviousLiquidMovement()
    • handleFloatingMovement

      protected void handleFloatingMovement()
    • getFloatingForceFactor

      @Since("1.19.60-r1") public double getFloatingForceFactor()
      浮力系数
      示例:
       if (hasWaterAt(this.getFloatingHeight())) {//实体指定高度进入水中后实体上浮
           return 1.3;//因为浮力系数>1,该值越大上浮越快
       }
       return 0.7;//实体指定高度没进入水中,实体存在浮力会抵抗部分重力,但是不会上浮。
                  //因为浮力系数<1,该值最好和上值相加等于2,例 1.3+0.7=2
       
      Returns:
      the floating force factor
    • getFloatingHeight

      @PowerNukkitXOnly @Since("1.19.60-r1") public float getFloatingHeight()
      获得浮动到的实体高度 , 0为实体底部 Entity.getCurrentHeight()为实体顶部
      例:
      值为0时,实体的脚接触水平面
      值为getCurrentHeight/2时,实体的中间部分接触水平面
      值为getCurrentHeight时,实体的头部接触水平面
      Returns:
      the float
    • handleCollideMovement

      protected void handleCollideMovement(int currentTick)
    • onCollide

      protected boolean onCollide(int currentTick, List<Entity> collidingEntities)
      Parameters:
      collidingEntities - 碰撞的实体
      Returns:
      false以拦截实体碰撞运动计算
    • getLiquidMovementSpeed

      protected final float getLiquidMovementSpeed(BlockLiquid liquid)
    • getFootHeight

      public float getFootHeight()
    • calculateOffsetBoundingBox

      protected void calculateOffsetBoundingBox()
    • getOffsetBoundingBox

      public AxisAlignedBB getOffsetBoundingBox()
    • resetFallDistance

      public void resetFallDistance()
      Overrides:
      resetFallDistance in class Entity
    • getGravity

      public float getGravity()
      Overrides:
      getGravity in class EntityLiving
    • getFallingTick

      public int getFallingTick()