Skip to main content

Action On Mouse Movement (Power Type)

Runs an entity action when the player with the power moves their mouse. It can be limited to chosen directions, and it can still fire when apoli:modify_cursor_speed has stopped the movement from turning the player.

Type ID: apoli:action_on_mouse_movement

Fields

FieldTypeDefaultDescription
entity_actionEntity ActionrequiredRuns on the player when the mouse moves.
upBooleanfalseFire when the mouse moves the view up.
downBooleanfalseFire when the mouse moves the view down.
leftBooleanfalseFire when the mouse moves the view left.
rightBooleanfalseFire when the mouse moves the view right.
thresholdFloat0How many degrees the view has to move in an enabled direction within one tick before the action fires. Raise it so a resting hand doesn't trigger anything.
ignore_modify_cursor_speedBooleanfalseReads the raw mouse movement instead of how far the player turned after any cursor speed change.
cooldownInteger or Expression0Ticks before the action can fire again.
hud_renderHUD Rendernot renderedHow the cooldown is drawn on the HUD.

With all four directions left false, any movement fires the action. Set one or more and only movement along those axes counts. up and left together fire on up-left, up-right and down-left movement, because each enabled direction is tested on its own.

Movement is added up over each tick and measured in degrees of view rotation, the same unit threshold uses. The action runs at most once per tick for each power.

Reading how far the mouse moved

Two expression variables are set while the action runs:

VariableMeaning
mouse_xDegrees moved horizontally this tick. Positive is right and negative is left.
mouse_yDegrees moved vertically this tick. Positive is down and negative is up.

ignore_modify_cursor_speed

apoli:modify_cursor_speed scales mouse input before it turns the player, and a multiplier of 0 freezes their view completely. By default this power sees the result, so at speed 0 it never fires, because nothing moved.

Set ignore_modify_cursor_speed: true and the power reads the movement the mouse made, before any cursor speed change. Combine a modify_cursor_speed of 0 with this power and the view stays locked while flicking the mouse still does something, so the mouse works as a gesture control instead of a camera.

note

Mouse movement is client input, so the power only fires for players.

Examples

{
    "type": "apoli:action_on_mouse_movement",
    "left": true,
    "right": true,
    "threshold": 25,
    "cooldown": 10,
    "entity_action": {
        "type": "apoli:execute_command",
        "command": "playsound minecraft:entity.player.attack.sweep master @s"
    }
}

A fast sideways flick plays a sweep sound. Small aiming movements stay below the threshold and do nothing.

{
    "type": "apoli:action_on_mouse_movement",
    "up": true,
    "threshold": 10,
    "ignore_modify_cursor_speed": true,
    "entity_action": {
        "type": "apoli:add_velocity",
        "y": "mouse_y / -40",
        "space": "world"
    },
    "condition": {
        "type": "apoli:power_active",
        "power": "example:hover"
    }
}

While the player is hovering, with their view frozen by a modify_cursor_speed of 0, pulling the mouse up lifts them, and the harder they pull, the faster they rise.