class

Rosegold::Physics

Inherits Reference / Object

Updates the player feet/look/velocity/on_ground by sending movement packets.

Constants

AIR_SLIP = 1.0
BASE_MOVEMENT_SPEED = 0.1
BLUE_ICE_SLIP = 0.989
DEFAULT_SLIP = 0.6

Block slipperiness values

DRAG = 0.98
EPSILON_COLLISION = 1.0e-7

Epsilon constants for floating point precision

EPSILON_HORIZONTAL = 0.003
EPSILON_MOVEMENT = 1.0e-6
EPSILON_STUCK = 0.001
FRICTION_CONSTANT = 0.21600002
GRAVITY = 0.08
ICE_SLIP = 0.98
JUMP_FORCE = 0.42
MAX_UP_STEP = 0.6
MOVEMENT_PACKET_KEEP_ALIVE_INTERVAL = 20

Send a keep-alive movement packet every 20 ticks (1 second) even when stationary This prevents server timeouts while avoiding packet spam

SLIME_SLIP = 0.8
SNEAK_MULTIPLIER = 0.3
SPRINT_MULTIPLIER = 1.3
VERY_CLOSE = 0.1
WATER_DRAG = 0.8
WATER_GRAVITY = 0.005
WATER_SWIM_UP_SPEED = 0.04

Constructors

Class methods

get_grown_obstacles(start : Vec3d, movement : Vec3d, entity_aabb : AABBf, dimension : Dimension) : Array(AABBd)

Returns all block collision boxes that may intersect entity_aabb during the movement from start by vec. entity_aabb is at 0,0,0; the returned AABBs are grown by entity_aabb so collision checks are just raytracing.

Source
maybe_back_off_from_edge(feet : Vec3d, velocity : Vec3d, entity_aabb : AABBf, &would_fall : AABBd -> Bool) : Vec3d
Source
predict_movement_collision(start : Vec3d, velocity : Vec3d, entity_aabb : AABBf, dimension : Dimension)

Applies collision handling including stepping. Returns adjusted movement vector and adjusted post-movement velocity.

Source
predict_movement_collision(start : Vec3d, velocity : Vec3d, obstacles : Array(AABBd))

Applies collision handling including stepping. Returns adjusted movement vector and adjusted post-movement velocity.

Source

Instance methods

block_slip
Source
handle_disconnect
Source
handle_reset
Source
jump_queued=(jump_queued : Bool)
Source
jump_queued?
Source
keys
Source
last_sent_feet

Movement packet rate limiting

Source
last_sent_feet=(last_sent_feet : Vec3d)

Movement packet rate limiting

Source
last_sent_look
Source
last_sent_look=(last_sent_look : Look)
Source
last_sent_on_ground
Source
last_sent_on_ground=(last_sent_on_ground : Bool)
Source
look=(target : Look)
Source
look_target
Source
move(target : Vec3d | Nil, stuck_timeout_ticks : Int32 = 10)

Set the movement target location and wait until it is achieved. If there is already a movement target, it is cancelled, and replaced with this new target. Set target=nil to stop moving and cancel any current movement. stuck_timeout_ticks specifies how many consecutive stuck ticks before throwing MovementStuck.

Source
movement_target
Source
pause
Source
paused=(paused : Bool)
Source
paused?
Source
pending_velocity=(velocity : Vec3d)
Source
reset_jump_delay
Source
running?
Source
sneak(sneaking = true)
Source
sprint(sprinting : Bool = true)
Source
stop_moving
Source
tick
Source
unpause_for_spawn_chunk
Source
very_close_to?(target : Vec3d)
Source

Nested types