class Rosegold::Physics

Overview

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

Defined in:

rosegold/control/physics.cr

Constant Summary

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

Block slipperiness values

DRAG = 0.98
FRICTION_CONSTANT = 0.21600002
GRAVITY = 0.08
ICE_SLIP = 0.98
JUMP_FORCE = 0.42
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

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(client : Rosegold::Client) #

[View source]

Class Method Detail

def self.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, including boxes 0.5m higher for stepping. entity_aabb is at 0,0,0; the returned AABBs are grown by entity_aabb so collision checks are just raytracing.


[View source]
def self.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.


[View source]
def self.predict_movement_collision(start : Vec3d, velocity : Vec3d, obstacles : Array(AABBd)) #

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


[View source]

Instance Method Detail

def block_slip : Float64 #

[View source]
def handle_disconnect #

[View source]
def handle_reset #

[View source]
def jump_queued=(jump_queued : Bool) #

[View source]
def jump_queued? : Bool #

[View source]
def last_sent_feet : Vec3d #

Movement packet rate limiting


[View source]
def last_sent_feet=(last_sent_feet : Vec3d) #

Movement packet rate limiting


[View source]
def last_sent_look : Look #

[View source]
def last_sent_look=(last_sent_look : Look) #

[View source]
def last_sent_on_ground : Bool #

[View source]
def last_sent_on_ground=(last_sent_on_ground : Bool) #

[View source]
def look=(target : Look) #

[View source]
def look_target #

[View source]
def 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.


[View source]
def movement_target #

[View source]
def pause #

[View source]
def paused=(paused : Bool) #

[View source]
def paused? : Bool #

[View source]
def reset_jump_delay #

[View source]
def running? #

[View source]
def sneak(sneaking = true) #

[View source]
def sprint(sprinting = true) #

[View source]
def tick(virtual_input : Rosegold::VirtualInput | Nil = nil) #

[View source]
def unpause_for_spawn_chunk #

[View source]
def very_close_to?(target : Vec3d) #

[View source]