Interface MotionController

All Superinterfaces:
DebugSupport.DebugFlagsChangeListener
All Known Implementing Classes:
MotionControllerBase, MotionControllerDive, MotionControllerFly, MotionControllerWalk

public interface MotionController extends DebugSupport.DebugFlagsChangeListener
The main task of the MotionController is to compute a (directional) velocity from a steering input and interpret the velocity within the constraints of the movement model (like walking, swimming or flying) ensuring maximum speeds and accelerations are considered.
  • Method Details

    • getType

      @Nonnull String getType()
    • getSupportedMovementModes

      @Nonnull Set<MovementMode> getSupportedMovementModes()
    • getDefaultSpawnMovementModes

      @Nonnull Set<MovementMode> getDefaultSpawnMovementModes()
    • getRole

      @Nonnull Role getRole()
    • setRole

      void setRole(@Nonnull Role role)
    • setDebugEntityId

      default void setDebugEntityId(int entityId)
    • setInertia

      void setInertia(double inertia)
    • setKnockbackScale

      void setKnockbackScale(double knockbackScale)
    • setUseFixedKnockback

      void setUseFixedKnockback(boolean useFixedKnockback)
    • getGravity

      double getGravity()
    • setHeadPitchAngleRange

      void setHeadPitchAngleRange(@Nullable float[] headPitchAngleRange)
    • spawned

      void spawned()
    • activate

      void activate()
    • deactivate

      void deactivate()
    • updateModelParameters

      void updateModelParameters(@Nullable Ref<EntityStore> ref, Model model, Box boundingBox, @Nullable ComponentAccessor<EntityStore> componentAccessor)
    • steer

      double steer(@Nonnull Ref<EntityStore> ref, @Nonnull Role role, @Nonnull Steering bodySteering, @Nonnull Steering headSteering, double dt, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
      Compute velocity vector from steering and move entity.

      Might do partial move when entity gets blocked. Time remaining to simulate is returned in this case else value <=0.

      Parameters:
      ref - The index of the NPC entity
      role - The NPC role
      bodySteering - Desired body steering to perform
      headSteering - Desired head steering to perform
      dt - Time interval to compute movement
      componentAccessor - The archetype chunk of this tick
      Returns:
      Time interval left to simulate when motion was blocked.
    • probeMove

      double probeMove(@Nonnull Ref<EntityStore> ref, @Nonnull org.joml.Vector3dc position, @Nonnull org.joml.Vector3dc direction, @Nonnull ProbeMoveData probeMoveData, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
    • probeMove

      double probeMove(@Nonnull Ref<EntityStore> ref, @Nonnull ProbeMoveData probeMoveData, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
    • applyRailStep

      default void applyRailStep(@Nonnull Ref<EntityStore> ref, @Nonnull Role role, @Nonnull org.joml.Vector3dc translation, @Nonnull RailStepConfig config, @Nonnull RailStepResult result, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
      Apply a "rail-mode" step: translates the entity by translation without running the normal physics pipeline (no gravity, no speed caps, no appliedVelocities). Block collisions that do not match RailStepConfig.ignoredBlockFilter clamp the motion and flag the controller as obstructed. Filter-rejected blocks and (when RailStepConfig.candidateEntities is non-null) entity hits are reported back via result. Triggers / damage blocks still fire through the normal pipeline.
      Parameters:
      ref - the NPC entity reference.
      role - the NPC role.
      translation - requested world-space translation for this step.
      config - per-step configuration, owned by the caller.
      result - output carrier for obstruction / pass-through / entity hits, cleared by this method.
      componentAccessor - component accessor for this tick.
    • constrainRotations

      void constrainRotations(Role role, TransformComponent transform)
    • getCurrentMaxBodyRotationSpeed

      double getCurrentMaxBodyRotationSpeed()
    • updateMovementState

      void updateMovementState(@Nonnull Ref<EntityStore> ref, @Nonnull MovementStates movementStates, @Nonnull Steering steering, @Nonnull org.joml.Vector3d velocity, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
    • isValidPosition

      boolean isValidPosition(@Nonnull org.joml.Vector3dc position, ComponentAccessor<EntityStore> componentAccessor)
    • canSteer

      boolean canSteer(@Nonnull Ref<EntityStore> ref, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
    • isForcePushed

      boolean isForcePushed()
      Returns:
      true when an external velocity source (knockback, applied velocity, etc.) is currently acting on the controller, so callers that own per-tick motion can hand control back to the regular steer pipeline.
    • canSteerFailReason

      @Nullable String canSteerFailReason(@Nonnull Ref<EntityStore> ref, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
      If canSteer(Ref, ComponentAccessor) returns false, this method can be called to get a human-readable reason for why the motion controller cannot steer.
      Parameters:
      ref - NPC entity reference
      componentAccessor - Accessor to get components of the NPC entity
      Returns:
      A human-readable reason for why the motion controller cannot steer, or null if the motion controller can steer
    • isInProgress

      boolean isInProgress()
    • isObstructed

      boolean isObstructed()
    • inAir

      boolean inAir()
    • inWater

      boolean inWater()
    • onGround

      boolean onGround()
    • standingOnBlockOfType

      boolean standingOnBlockOfType(int blockSet)
    • getMaximumSpeed

      double getMaximumSpeed()
    • getCurrentSpeed

      double getCurrentSpeed()
    • estimateVelocity

      boolean estimateVelocity(Steering steering, org.joml.Vector3d velocityOut)
    • getCurrentTurnRadius

      double getCurrentTurnRadius()
    • waypointDistance

      double waypointDistance(org.joml.Vector3dc p, org.joml.Vector3dc q)
    • waypointDistanceSquared

      double waypointDistanceSquared(org.joml.Vector3dc p, org.joml.Vector3dc q)
    • waypointDistance

      double waypointDistance(@Nonnull Ref<EntityStore> ref, org.joml.Vector3d p, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
    • waypointDistanceSquared

      double waypointDistanceSquared(@Nonnull Ref<EntityStore> ref, org.joml.Vector3d p, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
    • getMaxClimbAngle

      float getMaxClimbAngle()
    • getMaxSinkAngle

      float getMaxSinkAngle()
    • getMaxClimbHeight

      default double getMaxClimbHeight()
      Maximum vertical distance the controller can climb in a single step (e.g. on some block). Default 0 for controllers without a climb concept; overridden by ground-based controllers like MotionControllerWalk.
    • getMaxDropHeight

      default double getMaxDropHeight()
      Maximum vertical distance the controller can drop in a single step (e.g. off a ledge). Default 0 for controllers without a drop concept; overridden by ground-based controllers like MotionControllerWalk.
    • translateToAccessiblePosition

      boolean translateToAccessiblePosition(org.joml.Vector3d position, Box boundingBox, double minYValue, double maxYValue, ComponentAccessor<EntityStore> componentAccessor)
    • getCollisionBoundingBox

      @Nonnull Box getCollisionBoundingBox()
    • getComponentSelector

      org.joml.Vector3d getComponentSelector()
    • getPlanarComponentSelector

      org.joml.Vector3d getPlanarComponentSelector()
    • setComponentSelector

      void setComponentSelector(org.joml.Vector3d componentSelector)
    • is2D

      boolean is2D()
    • getWorldNormal

      org.joml.Vector3dc getWorldNormal()
    • getWorldAntiNormal

      org.joml.Vector3dc getWorldAntiNormal()
    • addVelocity

      default void addVelocity(@Nonnull org.joml.Vector3d velocity, @Nullable VelocityConfig velocityConfig)
    • addVelocity

      void addVelocity(@Nonnull org.joml.Vector3d velocity, @Nullable VelocityConfig velocityConfig, float preMultiplier)
    • preScaleKnockback

      org.joml.Vector3d preScaleKnockback(@Nonnull org.joml.Vector3dc velocity)
    • getExternalVelocity

      org.joml.Vector3d getExternalVelocity()
      Returns only the controller's external velocity accumulator.

      This intentionally excludes split/applied velocities.

    • getCombinedExternalVelocityLength

      double getCombinedExternalVelocityLength()
      Returns:
      Length of the vector sum of forceVelocity and all active applied velocities.
    • clearExternalForces

      void clearExternalForces()
      Clears all external force/knockback velocities currently tracked by this motion controller.
    • setVelocity

      void setVelocity(@Nonnull org.joml.Vector3dc velocity, @Nullable VelocityConfig velocityConfig, boolean overrideDamping)
    • setVelocity

      default void setVelocity(@Nonnull org.joml.Vector3dc velocity, @Nullable VelocityConfig velocityConfig, boolean overrideDamping, float preMultiplier)
    • getDesiredVerticalRange

      MotionController.VerticalRange getDesiredVerticalRange(@Nonnull Ref<EntityStore> ref, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
    • getWanderVerticalMovementRatio

      double getWanderVerticalMovementRatio()
    • isAvoidingBlockDamage

      boolean isAvoidingBlockDamage()
    • willReceiveBlockDamage

      boolean willReceiveBlockDamage()
    • requirePreciseMovement

      void requirePreciseMovement(org.joml.Vector3d positionHint)
    • enableHeadingBlending

      void enableHeadingBlending(double heading, org.joml.Vector3d targetPosition, double blendLevelAtTargetPosition)
    • enableHeadingBlending

      void enableHeadingBlending()
    • setRelaxedMoveConstraints

      void setRelaxedMoveConstraints(@Nonnull EnumSet<RelaxedConstraint> constraints)
    • getRelaxedConstraints

      @Nonnull EnumSet<RelaxedConstraint> getRelaxedConstraints()
    • getNavState

      NavState getNavState()
    • getThrottleDuration

      double getThrottleDuration()
    • getTargetDeltaSquared

      double getTargetDeltaSquared()
    • setNavState

      void setNavState(NavState navState, double throttleDuration, double targetDeltaSquared)
    • setForceRecomputePath

      void setForceRecomputePath(boolean recomputePath)
    • isForceRecomputePath

      boolean isForceRecomputePath()
    • canRestAtPlace

      boolean canRestAtPlace()
    • beforeInstructionSensorsAndActions

      void beforeInstructionSensorsAndActions(double physicsTickDuration)
    • beforeInstructionMotion

      void beforeInstructionMotion(double physicsTickDuration)
    • matchesType

      default boolean matchesType(@Nonnull Class<? extends MotionController> clazz)
      Performs a runtime type check to determine whether the given class is the same instance as this
      Parameters:
      clazz - The given class type to check
      Returns:
      true if they are identical, false otherwise
    • getDesiredAltitudeWeight

      double getDesiredAltitudeWeight()
    • getHeightOverGround

      double getHeightOverGround()
    • clearOverrides

      default void clearOverrides()
    • getSquaredDistance

      default double getSquaredDistance(@Nonnull org.joml.Vector3d p1, @Nonnull org.joml.Vector3d p2, boolean useProjectedDistance)
    • updatePhysicsValues

      void updatePhysicsValues(PhysicsValues values)
    • isInMovementState

      static boolean isInMovementState(@Nonnull Ref<EntityStore> ref, @Nonnull MovementState state, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
    • onDebugFlagsChanged

      default void onDebugFlagsChanged(EnumSet<RoleDebugFlags> newFlags)
      Specified by:
      onDebugFlagsChanged in interface DebugSupport.DebugFlagsChangeListener