@@ -902,43 +902,39 @@ class NPCImpl(
902902 return
903903 }
904904
905+ // Mannequins are display entities and don't respond to velocity properly
906+ // Use teleportation for movement instead
905907 val normalizedDirection = direction.normalize()
906- val movementVector = normalizedDirection.multiply(speed)
908+ val moveDistance = speed.coerceAtMost(distance) // Don't overshoot the target
909+ val newPosition = currentLoc.clone().add(normalizedDirection.multiply(moveDistance))
907910
908911 // Check if NPC needs to jump
909912 val needsJump = usePathfinding && Pathfinder .needsJump(entity, target)
910913 if (needsJump) {
911- logDebug(" [NPC] moveTowards: Needs to jump, applying jump velocity" )
912- // Apply upward velocity for jumping
913- val jumpVelocity = Vector (0.0 , 0.42 , 0.0 ) // Standard jump velocity
914- entity.velocity = movementVector.add(jumpVelocity)
914+ logDebug(" [NPC] moveTowards: Needs to jump, adding jump height" )
915+ // Add jump height to the new position
916+ newPosition.y + = 0.42 // Standard jump height
915917 } else {
916- // Normal movement
918+ // Normal movement - handle small steps up
917919 val heightDiff = target.y - currentLoc.y
918920 if (heightDiff > 0.1 && heightDiff <= 0.5 ) {
919- logDebug(" [NPC] moveTowards: Small step up (heightDiff=$heightDiff ), adding step velocity" )
920- // Small step up, add slight upward velocity
921- val stepVelocity = Vector (0.0 , 0.2 , 0.0 )
922- entity.velocity = movementVector.add(stepVelocity)
923- } else {
924- logDebug(" [NPC] moveTowards: Normal movement, velocity=${movementVector.x} ,${movementVector.y} ,${movementVector.z} " )
925- entity.velocity = movementVector
921+ logDebug(" [NPC] moveTowards: Small step up (heightDiff=$heightDiff ), adding step height" )
922+ // Small step up, add slight upward movement
923+ newPosition.y + = 0.2
926924 }
927925 }
928926
929- logDebug(" [NPC] moveTowards: Applied velocity=${entity.velocity.x} ,${entity.velocity.y} ,${entity.velocity.z} " )
930-
931- // Make entity look at target (don't teleport, let velocity handle movement)
932- val lookDirection = target.toVector().subtract(currentLoc.toVector())
927+ // Make entity look at target
928+ val lookDirection = target.toVector().subtract(newPosition.toVector())
933929 val yaw = Math .toDegrees(- atan2(lookDirection.x, lookDirection.z)).toFloat()
934930 val pitch = Math .toDegrees(- Math .asin(lookDirection.y / lookDirection.length())).toFloat()
931+
932+ newPosition.yaw = yaw
933+ newPosition.pitch = pitch.coerceIn(- 90f , 90f )
935934
936- // Update rotation without teleporting (to not override velocity)
937- val rotationLoc = currentLoc.clone()
938- rotationLoc.yaw = yaw
939- rotationLoc.pitch = pitch.coerceIn(- 90f , 90f )
940- entity.teleport(rotationLoc) // Only teleport for rotation, velocity handles position
941- logDebug(" [NPC] moveTowards: Updated rotation - yaw=$yaw , pitch=$pitch " )
935+ // Teleport to new position (Mannequins need teleportation for movement)
936+ entity.teleport(newPosition)
937+ logDebug(" [NPC] moveTowards: Teleported to ${newPosition.blockX} ,${newPosition.blockY} ,${newPosition.blockZ} , yaw=$yaw , pitch=$pitch " )
942938 }
943939
944940 /* *
0 commit comments