Class MotionControllerBase

java.lang.Object
com.hypixel.hytale.server.npc.movement.controllers.MotionControllerBase
All Implemented Interfaces:
com.hypixel.hytale.server.npc.movement.controllers.MotionController
Direct Known Subclasses:
MotionControllerDive, MotionControllerFly, MotionControllerWalk

public abstract class MotionControllerBase extends Object implements com.hypixel.hytale.server.npc.movement.controllers.MotionController
  • Field Details

    • FORCE_SCALE

      public static final double FORCE_SCALE
      See Also:
    • BISECT_DIST

      public static final double BISECT_DIST
      See Also:
    • FILTER_COEFFICIENT

      public static final double FILTER_COEFFICIENT
      See Also:
    • DOT_PRODUCT_EPSILON

      public static final double DOT_PRODUCT_EPSILON
      See Also:
    • DEFAULT_BLOCK_DRAG

      public static final double DEFAULT_BLOCK_DRAG
      See Also:
    • LOGGER

      protected static final com.hypixel.hytale.logger.HytaleLogger LOGGER
    • DEBUG_APPLIED_FORCES

      public static final boolean DEBUG_APPLIED_FORCES
      See Also:
    • entity

      @Nonnull protected final NPCEntity entity
    • type

      protected final String type
    • epsilonSpeed

      protected final double epsilonSpeed
    • epsilonAngle

      protected final float epsilonAngle
    • forceVelocityDamping

      protected final double forceVelocityDamping
    • maxHorizontalSpeed

      protected final double maxHorizontalSpeed
    • fastMotionThreshold

      protected final double fastMotionThreshold
    • fastMotionThresholdRange

      protected final double fastMotionThresholdRange
    • maxHeadRotationSpeed

      protected final float maxHeadRotationSpeed
    • role

      protected Role role
    • inertia

      protected double inertia
    • knockbackScale

      protected double knockbackScale
    • gravity

      protected double gravity
    • debugModeSteer

      protected boolean debugModeSteer
    • debugModeMove

      protected boolean debugModeMove
    • debugModeCollisions

      protected boolean debugModeCollisions
    • debugModeBlockCollisions

      protected boolean debugModeBlockCollisions
    • debugModeProbeBlockCollisions

      protected boolean debugModeProbeBlockCollisions
    • debugModeValidatePositions

      protected boolean debugModeValidatePositions
    • debugModeOverlaps

      protected boolean debugModeOverlaps
    • debugModeValidateMath

      protected boolean debugModeValidateMath
    • position

      protected final Vector3d position
    • collisionBoundingBox

      protected final Box collisionBoundingBox
    • collisionResult

      protected final CollisionResult collisionResult
    • translation

      protected final Vector3d translation
    • bisectValidPosition

      protected final Vector3d bisectValidPosition
    • bisectInvalidPosition

      protected final Vector3d bisectInvalidPosition
    • lastValidPosition

      protected final Vector3d lastValidPosition
    • forceVelocity

      protected final Vector3d forceVelocity
    • appliedForce

      protected final Vector3d appliedForce
    • ignoreDamping

      protected boolean ignoreDamping
    • appliedVelocities

      protected final List<MotionControllerBase.AppliedVelocity> appliedVelocities
    • isObstructed

      protected boolean isObstructed
    • throttleDuration

      protected double throttleDuration
    • targetDeltaSquared

      protected double targetDeltaSquared
    • recomputePath

      protected boolean recomputePath
    • worldNormal

      protected final Vector3d worldNormal
    • worldAntiNormal

      protected final Vector3d worldAntiNormal
    • componentSelector

      protected final Vector3d componentSelector
    • planarComponentSelector

      protected final Vector3d planarComponentSelector
    • enableTriggers

      protected boolean enableTriggers
    • enableBlockDamage

      protected boolean enableBlockDamage
    • isReceivingBlockDamage

      protected boolean isReceivingBlockDamage
    • isAvoidingBlockDamage

      protected boolean isAvoidingBlockDamage
    • requiresPreciseMovement

      protected boolean requiresPreciseMovement
    • requiresDepthProbing

      protected boolean requiresDepthProbing
    • havePreciseMovementTarget

      protected boolean havePreciseMovementTarget
    • preciseMovementTarget

      @Nonnull protected Vector3d preciseMovementTarget
    • isRelaxedMoveConstraints

      protected boolean isRelaxedMoveConstraints
    • isBlendingHeading

      protected boolean isBlendingHeading
    • blendHeading

      protected double blendHeading
    • haveBlendHeadingPosition

      protected boolean haveBlendHeadingPosition
    • blendHeadingPosition

      @Nonnull protected Vector3d blendHeadingPosition
    • blendLevelAtTargetPosition

      protected double blendLevelAtTargetPosition
    • fastMotionKind

      protected boolean fastMotionKind
    • idleMotionKind

      protected boolean idleMotionKind
    • horizontalIdleKind

      protected boolean horizontalIdleKind
    • moveSpeed

      protected double moveSpeed
    • previousSpeed

      protected double previousSpeed
    • motionKind

      protected MotionKind motionKind
    • lastMovementStateUpdatedMotionKind

      protected MotionKind lastMovementStateUpdatedMotionKind
    • previousMotionKind

      protected MotionKind previousMotionKind
    • effectHorizontalSpeedMultiplier

      protected double effectHorizontalSpeedMultiplier
    • cachedMovementBlocked

      protected boolean cachedMovementBlocked
    • yaw

      private float yaw
    • pitch

      private float pitch
    • roll

      private float roll
    • beforeTriggerForce

      private final Vector3d beforeTriggerForce
    • beforeTriggerPosition

      private final Vector3d beforeTriggerPosition
    • processTriggersHasMoved

      private boolean processTriggersHasMoved
    • movementSettings

      protected MovementSettings movementSettings
  • Constructor Details

  • Method Details

    • getRole

      public Role getRole()
      Specified by:
      getRole in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • setRole

      public void setRole(Role role)
      Specified by:
      setRole in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • setInertia

      public void setInertia(double inertia)
      Specified by:
      setInertia in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • setKnockbackScale

      public void setKnockbackScale(double knockbackScale)
      Specified by:
      setKnockbackScale in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • updateModelParameters

      public void updateModelParameters(Ref<EntityStore> ref, Model model, @Nonnull Box boundingBox, ComponentAccessor<EntityStore> componentAccessor)
      Specified by:
      updateModelParameters in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • readEntityPosition

      protected void readEntityPosition(@Nonnull Ref<EntityStore> ref, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
    • postReadPosition

      public void postReadPosition(Ref<EntityStore> ref, ComponentAccessor<EntityStore> componentAccessor)
    • moveEntity

      public void moveEntity(@Nonnull Ref<EntityStore> ref, double dt, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
    • getYaw

      public float getYaw()
    • getPitch

      public float getPitch()
    • getRoll

      public float getRoll()
    • touchesWater

      public boolean touchesWater(boolean defaultValue, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
    • updateMovementState

      public void updateMovementState(@Nonnull Ref<EntityStore> ref, @Nonnull MovementStates movementStates, @Nonnull Steering steering, @Nonnull Vector3d velocity, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
      Specified by:
      updateMovementState in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • isFastMotionKind

      protected abstract boolean isFastMotionKind(double var1)
    • updateFlyingStates

      protected void updateFlyingStates(@Nonnull MovementStates movementStates, boolean idle, boolean fastMotionKind)
    • updateSwimmingStates

      protected void updateSwimmingStates(@Nonnull MovementStates movementStates, boolean idle, boolean fastMotionKind, boolean horizontalIdleKind)
    • updateMovingStates

      protected static void updateMovingStates(@Nonnull Ref<EntityStore> ref, @Nonnull MovementStates movementStates, boolean fastMotionKind, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
    • updateAscendingStates

      protected void updateAscendingStates(@Nonnull Ref<EntityStore> ref, @Nonnull MovementStates movementStates, boolean fastMotionKind, boolean horizontalIdleKind, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
    • updateDescendingStates

      protected void updateDescendingStates(@Nonnull Ref<EntityStore> ref, @Nonnull MovementStates movementStates, boolean fastMotionKind, boolean hovering, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
    • updateDroppingStates

      protected void updateDroppingStates(@Nonnull MovementStates movementStates)
    • updateStandingStates

      protected void updateStandingStates(@Nonnull MovementStates movementStates, @Nonnull MotionKind motionKind, boolean hovering)
    • steer

      public double steer(@Nonnull Ref<EntityStore> ref, @Nonnull Role role, @Nonnull Steering bodySteering, @Nonnull Steering headSteering, double interval, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
      Specified by:
      steer in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • steer0

      public double steer0(@Nonnull Ref<EntityStore> ref, @Nonnull Role role, @Nonnull Steering bodySteering, @Nonnull Steering headSteering, double interval, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
    • shouldDampenAppliedVelocitiesY

      protected boolean shouldDampenAppliedVelocitiesY()
    • shouldAlwaysUseGroundResistance

      protected boolean shouldAlwaysUseGroundResistance()
    • calculateYaw

      protected void calculateYaw(@Nonnull Ref<EntityStore> ref, @Nonnull Steering bodySteering, @Nonnull Steering headSteering, float maxHeadRotation, float maxBodyRotation, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
    • blendBodyYaw

      protected float blendBodyYaw(@Nonnull Ref<EntityStore> ref, float yawOffset, float maxBodyRotation, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
    • calculatePitch

      protected void calculatePitch(@Nonnull Ref<EntityStore> ref, @Nonnull Steering bodySteering, @Nonnull Steering headSteering, float maxHeadRotation, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
    • calculateRoll

      protected void calculateRoll(@Nonnull Steering bodySteering, @Nonnull Steering headSteering)
    • dampForceVelocity

      protected void dampForceVelocity(@Nonnull Vector3d forceVelocity, double forceVelocityDamping, double interval, ComponentAccessor<EntityStore> componentAccessor)
    • convertToNewRange

      private static double convertToNewRange(double value, double oldMinRange, double oldMaxRange, double newMinRange, double newMaxRange)
    • probeMove

      public double probeMove(@Nonnull Ref<EntityStore> ref, @Nonnull Vector3d position, @Nonnull Vector3d direction, @Nonnull ProbeMoveData probeMoveData, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
      Specified by:
      probeMove in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • postExecuteMove

      protected void postExecuteMove()
    • adjustReadPosition

      protected void adjustReadPosition(Ref<EntityStore> ref, ComponentAccessor<EntityStore> componentAccessor)
    • adjustWritePosition

      protected void adjustWritePosition(Ref<EntityStore> ref, double dt, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
    • isInProgress

      public boolean isInProgress()
      Specified by:
      isInProgress in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • isObstructed

      public boolean isObstructed()
      Specified by:
      isObstructed in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • getNavState

      public NavState getNavState()
      Specified by:
      getNavState in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • getThrottleDuration

      public double getThrottleDuration()
      Specified by:
      getThrottleDuration in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • getTargetDeltaSquared

      public double getTargetDeltaSquared()
      Specified by:
      getTargetDeltaSquared in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • setNavState

      public void setNavState(NavState navState, double throttleDuration, double targetDeltaSquared)
      Specified by:
      setNavState in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • isForceRecomputePath

      public boolean isForceRecomputePath()
      Specified by:
      isForceRecomputePath in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • setForceRecomputePath

      public void setForceRecomputePath(boolean recomputePath)
      Specified by:
      setForceRecomputePath in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • beforeInstructionSensorsAndActions

      public void beforeInstructionSensorsAndActions(double physicsTickDuration)
      Specified by:
      beforeInstructionSensorsAndActions in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • beforeInstructionMotion

      public void beforeInstructionMotion(double physicsTickDuration)
      Specified by:
      beforeInstructionMotion in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • isHorizontalIdle

      public boolean isHorizontalIdle(double speed)
    • canAct

      public boolean canAct(@Nonnull Ref<EntityStore> ref, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
      Specified by:
      canAct in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • isMovementBlocked

      public boolean isMovementBlocked(@Nonnull Ref<EntityStore> ref, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
    • computeMove

      protected abstract double computeMove(@Nonnull Ref<EntityStore> var1, @Nonnull Role var2, Steering var3, double var4, Vector3d var6, @Nonnull ComponentAccessor<EntityStore> var7)
    • executeMove

      protected abstract double executeMove(@Nonnull Ref<EntityStore> var1, @Nonnull Role var2, double var3, Vector3d var5, @Nonnull ComponentAccessor<EntityStore> var6)
    • bisect

      public <T> double bisect(@Nonnull Vector3d validPosition, @Nonnull Vector3d invalidPosition, @Nonnull T t, @Nonnull BiPredicate<T,Vector3d> validate, @Nonnull Vector3d result)
    • bisect

      public <T> double bisect(@Nonnull Vector3d validPosition, @Nonnull Vector3d invalidPosition, @Nonnull T t, @Nonnull BiPredicate<T,Vector3d> validate, double maxDistance, @Nonnull Vector3d result)
    • getForce

      @Nonnull public Vector3d getForce()
      Specified by:
      getForce in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • addForce

      public void addForce(@Nonnull Vector3d force, VelocityConfig velocityConfig)
      Specified by:
      addForce in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • forceVelocity

      public void forceVelocity(@Nonnull Vector3d velocity, @Nullable VelocityConfig velocityConfig, boolean ignoreDamping)
      Specified by:
      forceVelocity in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • clearForce

      public void clearForce()
    • dumpCollisionResults

      protected void dumpCollisionResults()
    • setEnableTriggers

      public void setEnableTriggers(boolean enableTriggers)
    • setEnableBlockDamage

      public void setEnableBlockDamage(boolean enableBlockDamage)
    • willReceiveBlockDamage

      public boolean willReceiveBlockDamage()
      Specified by:
      willReceiveBlockDamage in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • setAvoidingBlockDamage

      public void setAvoidingBlockDamage(boolean avoid)
      Specified by:
      setAvoidingBlockDamage in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • isAvoidingBlockDamage

      public boolean isAvoidingBlockDamage()
      Specified by:
      isAvoidingBlockDamage in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • processTriggers

      public void processTriggers(@Nonnull Ref<EntityStore> ref, @Nonnull CollisionResult collisionResult, double t, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
    • isDebugMode

      protected boolean isDebugMode(RoleDebugFlags mode)
    • isProcessTriggersHasMoved

      public boolean isProcessTriggersHasMoved()
    • isAlive

      protected boolean isAlive(@Nonnull Ref<EntityStore> ref, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
    • activate

      public void activate()
      Specified by:
      activate in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • resetNavState

      public void resetNavState()
    • resetObstructedFlags

      public void resetObstructedFlags()
    • deactivate

      public void deactivate()
      Specified by:
      deactivate in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • getEpsilonSpeed

      public double getEpsilonSpeed()
    • getEpsilonAngle

      public float getEpsilonAngle()
    • getComponentSelector

      @Nonnull public Vector3d getComponentSelector()
      Specified by:
      getComponentSelector in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • getPlanarComponentSelector

      @Nonnull public Vector3d getPlanarComponentSelector()
      Specified by:
      getPlanarComponentSelector in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • setComponentSelector

      public void setComponentSelector(@Nonnull Vector3d componentSelector)
      Specified by:
      setComponentSelector in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • getWorldNormal

      public Vector3d getWorldNormal()
      Specified by:
      getWorldNormal in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • getWorldAntiNormal

      public Vector3d getWorldAntiNormal()
      Specified by:
      getWorldAntiNormal in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • waypointDistance

      public double waypointDistance(@Nonnull Vector3d p, @Nonnull Vector3d q)
      Specified by:
      waypointDistance in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • waypointDistanceSquared

      public double waypointDistanceSquared(@Nonnull Vector3d p, @Nonnull Vector3d q)
      Specified by:
      waypointDistanceSquared in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • waypointDistance

      public double waypointDistance(@Nonnull Ref<EntityStore> ref, @Nonnull Vector3d p, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
      Specified by:
      waypointDistance in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • waypointDistanceSquared

      public double waypointDistanceSquared(@Nonnull Ref<EntityStore> ref, @Nonnull Vector3d p, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
      Specified by:
      waypointDistanceSquared in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • isValidPosition

      public boolean isValidPosition(@Nonnull Vector3d position, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
      Specified by:
      isValidPosition in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • isValidPosition

      public boolean isValidPosition(@Nonnull Vector3d position, @Nonnull CollisionResult collisionResult, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
    • getInvalidOverlapMaterials

      public int getInvalidOverlapMaterials()
    • saveMotionKind

      protected void saveMotionKind()
    • switchedToMotionKind

      protected boolean switchedToMotionKind(MotionKind motionKind)
    • getMotionKind

      public MotionKind getMotionKind()
    • setMotionKind

      public void setMotionKind(MotionKind motionKind)
    • getGravity

      public double getGravity()
      Specified by:
      getGravity in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • setGravity

      public void setGravity(double gravity)
    • translateToAccessiblePosition

      public boolean translateToAccessiblePosition(Vector3d position, Box boundingBox, double minYValue, double maxYValue, ComponentAccessor<EntityStore> componentAccessor)
      Specified by:
      translateToAccessiblePosition in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • standingOnBlockOfType

      public boolean standingOnBlockOfType(int blockSet)
      Specified by:
      standingOnBlockOfType in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • requirePreciseMovement

      public void requirePreciseMovement(@Nullable Vector3d positionHint)
      Specified by:
      requirePreciseMovement in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • clearRequirePreciseMovement

      public void clearRequirePreciseMovement()
    • isRequiresPreciseMovement

      public boolean isRequiresPreciseMovement()
    • requireDepthProbing

      public void requireDepthProbing()
      Specified by:
      requireDepthProbing in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • clearRequireDepthProbing

      public void clearRequireDepthProbing()
    • isRequiresDepthProbing

      public boolean isRequiresDepthProbing()
    • enableHeadingBlending

      public void enableHeadingBlending(double heading, @Nullable Vector3d targetPosition, double blendLevel)
      Specified by:
      enableHeadingBlending in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • enableHeadingBlending

      public void enableHeadingBlending()
      Specified by:
      enableHeadingBlending in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • clearBlendHeading

      public void clearBlendHeading()
    • setRelaxedMoveConstraints

      public void setRelaxedMoveConstraints(boolean relax)
      Specified by:
      setRelaxedMoveConstraints in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • isRelaxedMoveConstraints

      public boolean isRelaxedMoveConstraints()
      Specified by:
      isRelaxedMoveConstraints in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController
    • updatePhysicsValues

      public void updatePhysicsValues(PhysicsValues values)
      Specified by:
      updatePhysicsValues in interface com.hypixel.hytale.server.npc.movement.controllers.MotionController