Contents
- Description
- Nested Class Summary
- Method Summary
- Method Details
- getType()
- getSupportedMovementModes()
- getDefaultSpawnMovementModes()
- getRole()
- setRole(Role)
- setDebugEntityId(int)
- setInertia(double)
- setKnockbackScale(double)
- setUseFixedKnockback(boolean)
- getGravity()
- setHeadPitchAngleRange(float[])
- spawned()
- activate()
- deactivate()
- updateModelParameters(Ref, Model, Box, ComponentAccessor)
- steer(Ref, Role, Steering, Steering, double, ComponentAccessor)
- probeMove(Ref, Vector3dc, Vector3dc, ProbeMoveData, ComponentAccessor)
- probeMove(Ref, ProbeMoveData, ComponentAccessor)
- applyRailStep(Ref, Role, Vector3dc, RailStepConfig, RailStepResult, ComponentAccessor)
- constrainRotations(Role, TransformComponent)
- getCurrentMaxBodyRotationSpeed()
- updateMovementState(Ref, MovementStates, Steering, Vector3d, ComponentAccessor)
- isValidPosition(Vector3dc, ComponentAccessor)
- canSteer(Ref, ComponentAccessor)
- isForcePushed()
- canSteerFailReason(Ref, ComponentAccessor)
- isInProgress()
- isObstructed()
- inAir()
- inWater()
- onGround()
- standingOnBlockOfType(int)
- getMaximumSpeed()
- getCurrentSpeed()
- estimateVelocity(Steering, Vector3d)
- getCurrentTurnRadius()
- waypointDistance(Vector3dc, Vector3dc)
- waypointDistanceSquared(Vector3dc, Vector3dc)
- waypointDistance(Ref, Vector3d, ComponentAccessor)
- waypointDistanceSquared(Ref, Vector3d, ComponentAccessor)
- getMaxClimbAngle()
- getMaxSinkAngle()
- getMaxClimbHeight()
- getMaxDropHeight()
- translateToAccessiblePosition(Vector3d, Box, double, double, ComponentAccessor)
- getCollisionBoundingBox()
- getComponentSelector()
- getPlanarComponentSelector()
- setComponentSelector(Vector3d)
- is2D()
- getWorldNormal()
- getWorldAntiNormal()
- addVelocity(Vector3d, VelocityConfig)
- addVelocity(Vector3d, VelocityConfig, float)
- preScaleKnockback(Vector3dc)
- getExternalVelocity()
- getCombinedExternalVelocityLength()
- clearExternalForces()
- setVelocity(Vector3dc, VelocityConfig, boolean)
- setVelocity(Vector3dc, VelocityConfig, boolean, float)
- getDesiredVerticalRange(Ref, ComponentAccessor)
- getWanderVerticalMovementRatio()
- isAvoidingBlockDamage()
- willReceiveBlockDamage()
- requirePreciseMovement(Vector3d)
- enableHeadingBlending(double, Vector3d, double)
- enableHeadingBlending()
- setRelaxedMoveConstraints(EnumSet)
- getRelaxedConstraints()
- getNavState()
- getThrottleDuration()
- getTargetDeltaSquared()
- setNavState(NavState, double, double)
- setForceRecomputePath(boolean)
- isForceRecomputePath()
- canRestAtPlace()
- beforeInstructionSensorsAndActions(double)
- beforeInstructionMotion(double)
- matchesType(Class)
- getDesiredAltitudeWeight()
- getHeightOverGround()
- clearOverrides()
- getSquaredDistance(Vector3d, Vector3d, boolean)
- updatePhysicsValues(PhysicsValues)
- isInMovementState(Ref, MovementState, ComponentAccessor)
- onDebugFlagsChanged(EnumSet)
Interface MotionController
- All Superinterfaces:
DebugSupport.DebugFlagsChangeListener
- All Known Implementing Classes:
MotionControllerBase, MotionControllerDive, MotionControllerFly, MotionControllerWalk
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.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionvoidactivate()default voidaddVelocity(org.joml.Vector3d velocity, VelocityConfig velocityConfig) voidaddVelocity(org.joml.Vector3d velocity, VelocityConfig velocityConfig, float preMultiplier) default voidapplyRailStep(Ref<EntityStore> ref, Role role, org.joml.Vector3dc translation, RailStepConfig config, RailStepResult result, ComponentAccessor<EntityStore> componentAccessor) Apply a "rail-mode" step: translates the entity bytranslationwithout running the normal physics pipeline (no gravity, no speed caps, no appliedVelocities).voidbeforeInstructionMotion(double physicsTickDuration) voidbeforeInstructionSensorsAndActions(double physicsTickDuration) booleanbooleancanSteer(Ref<EntityStore> ref, ComponentAccessor<EntityStore> componentAccessor) canSteerFailReason(Ref<EntityStore> ref, ComponentAccessor<EntityStore> componentAccessor) IfcanSteer(Ref, ComponentAccessor)returns false, this method can be called to get a human-readable reason for why the motion controller cannot steer.voidClears all external force/knockback velocities currently tracked by this motion controller.default voidvoidconstrainRotations(Role role, TransformComponent transform) voidvoidvoidenableHeadingBlending(double heading, org.joml.Vector3d targetPosition, double blendLevelAtTargetPosition) booleanestimateVelocity(Steering steering, org.joml.Vector3d velocityOut) doubleorg.joml.Vector3ddoubledoubledoubledoublegetDesiredVerticalRange(Ref<EntityStore> ref, ComponentAccessor<EntityStore> componentAccessor) org.joml.Vector3dReturns only the controller's external velocity accumulator.doubledoublefloatdefault doubleMaximum vertical distance the controller can climb in a single step (e.g. on some block).default doubleMaximum vertical distance the controller can drop in a single step (e.g. off a ledge).doublefloatorg.joml.Vector3dgetRole()default doublegetSquaredDistance(org.joml.Vector3d p1, org.joml.Vector3d p2, boolean useProjectedDistance) doubledoublegetType()doubleorg.joml.Vector3dcorg.joml.Vector3dcbooleaninAir()booleaninWater()booleanis2D()booleanbooleanbooleanstatic booleanisInMovementState(Ref<EntityStore> ref, MovementState state, ComponentAccessor<EntityStore> componentAccessor) booleanbooleanbooleanisValidPosition(org.joml.Vector3dc position, ComponentAccessor<EntityStore> componentAccessor) default booleanmatchesType(Class<? extends MotionController> clazz) Performs a runtime type check to determine whether the given class is the same instance as thisdefault voidonDebugFlagsChanged(EnumSet<RoleDebugFlags> newFlags) booleanonGround()org.joml.Vector3dpreScaleKnockback(org.joml.Vector3dc velocity) doubleprobeMove(Ref<EntityStore> ref, ProbeMoveData probeMoveData, ComponentAccessor<EntityStore> componentAccessor) doubleprobeMove(Ref<EntityStore> ref, org.joml.Vector3dc position, org.joml.Vector3dc direction, ProbeMoveData probeMoveData, ComponentAccessor<EntityStore> componentAccessor) voidrequirePreciseMovement(org.joml.Vector3d positionHint) voidsetComponentSelector(org.joml.Vector3d componentSelector) default voidsetDebugEntityId(int entityId) voidsetForceRecomputePath(boolean recomputePath) voidsetHeadPitchAngleRange(float[] headPitchAngleRange) voidsetInertia(double inertia) voidsetKnockbackScale(double knockbackScale) voidsetNavState(NavState navState, double throttleDuration, double targetDeltaSquared) voidsetRelaxedMoveConstraints(EnumSet<RelaxedConstraint> constraints) voidvoidsetUseFixedKnockback(boolean useFixedKnockback) voidsetVelocity(org.joml.Vector3dc velocity, VelocityConfig velocityConfig, boolean overrideDamping) default voidsetVelocity(org.joml.Vector3dc velocity, VelocityConfig velocityConfig, boolean overrideDamping, float preMultiplier) voidspawned()booleanstandingOnBlockOfType(int blockSet) doublesteer(Ref<EntityStore> ref, Role role, Steering bodySteering, Steering headSteering, double dt, ComponentAccessor<EntityStore> componentAccessor) Compute velocity vector from steering and move entity.booleantranslateToAccessiblePosition(org.joml.Vector3d position, Box boundingBox, double minYValue, double maxYValue, ComponentAccessor<EntityStore> componentAccessor) voidupdateModelParameters(Ref<EntityStore> ref, Model model, Box boundingBox, ComponentAccessor<EntityStore> componentAccessor) voidupdateMovementState(Ref<EntityStore> ref, MovementStates movementStates, Steering steering, org.joml.Vector3d velocity, ComponentAccessor<EntityStore> componentAccessor) voidupdatePhysicsValues(PhysicsValues values) doublewaypointDistance(Ref<EntityStore> ref, org.joml.Vector3d p, ComponentAccessor<EntityStore> componentAccessor) doublewaypointDistance(org.joml.Vector3dc p, org.joml.Vector3dc q) doublewaypointDistanceSquared(Ref<EntityStore> ref, org.joml.Vector3d p, ComponentAccessor<EntityStore> componentAccessor) doublewaypointDistanceSquared(org.joml.Vector3dc p, org.joml.Vector3dc q) boolean
-
Method Details
-
getType
-
getSupportedMovementModes
-
getDefaultSpawnMovementModes
-
getRole
-
setRole
-
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 entityrole- The NPC rolebodySteering- Desired body steering to performheadSteering- Desired head steering to performdt- Time interval to compute movementcomponentAccessor- 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 bytranslationwithout running the normal physics pipeline (no gravity, no speed caps, no appliedVelocities). Block collisions that do not matchRailStepConfig.ignoredBlockFilterclamp the motion and flag the controller as obstructed. Filter-rejected blocks and (whenRailStepConfig.candidateEntitiesis non-null) entity hits are reported back viaresult. 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
-
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:
truewhen 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) IfcanSteer(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 referencecomponentAccessor- 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
-
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). Default0for controllers without a climb concept; overridden by ground-based controllers likeMotionControllerWalk. -
getMaxDropHeight
default double getMaxDropHeight()Maximum vertical distance the controller can drop in a single step (e.g. off a ledge). Default0for controllers without a drop concept; overridden by ground-based controllers likeMotionControllerWalk. -
translateToAccessiblePosition
boolean translateToAccessiblePosition(org.joml.Vector3d position, Box boundingBox, double minYValue, double maxYValue, ComponentAccessor<EntityStore> componentAccessor) -
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
forceVelocityand 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
-
getRelaxedConstraints
-
getThrottleDuration
double getThrottleDuration() -
getTargetDeltaSquared
double getTargetDeltaSquared() -
setForceRecomputePath
void setForceRecomputePath(boolean recomputePath) -
isForceRecomputePath
boolean isForceRecomputePath() -
canRestAtPlace
boolean canRestAtPlace() -
beforeInstructionSensorsAndActions
void beforeInstructionSensorsAndActions(double physicsTickDuration) -
beforeInstructionMotion
void beforeInstructionMotion(double physicsTickDuration) -
matchesType
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:
trueif they are identical,falseotherwise
-
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
-
isInMovementState
static boolean isInMovementState(@Nonnull Ref<EntityStore> ref, @Nonnull MovementState state, @Nonnull ComponentAccessor<EntityStore> componentAccessor) -
onDebugFlagsChanged
- Specified by:
onDebugFlagsChangedin interfaceDebugSupport.DebugFlagsChangeListener
-