Undergarden mod !

This commit is contained in:
2026-09-30 17:30:14 -03:00
parent cbc9edfd60
commit 0052faa24d
21 changed files with 545 additions and 46 deletions
+19
View File
@@ -36,6 +36,10 @@ export abstract class Entity {
step_grace_ticks = 0;
// ticks since it was last on the ground
#air_ticks = 0;
// how far the limbs have swung and how hard they swing (0 to 1), like minecraft's WalkAnimationState
walk_position = 0;
walk_speed = 0;
prev_walk_speed = 0;
// which way it hit something on each axis in the last move: 1 or -1, 0 for nothing.
// 1 on y means it's standing on something
@@ -55,6 +59,21 @@ export abstract class Entity {
return this.colliding_y === 1;
}
// after moving each tick. full speed is 5 blocks per second, a bit faster than walking
update_walk_animation() {
const moved = Math.hypot(this.x - this.prev_x, this.z - this.prev_z);
this.prev_walk_speed = this.walk_speed;
this.walk_speed += (Math.min(moved * 4, 1) - this.walk_speed) * 0.4;
this.walk_position += this.walk_speed;
}
walk_animation(partial_tick: number) {
return {
position: this.walk_position - this.walk_speed * (1 - partial_tick),
speed: this.prev_walk_speed + (this.walk_speed - this.prev_walk_speed) * partial_tick,
};
}
// jumps there, without interpolating from where it was
set_position(x: number, y: number, z: number) {
this.x = this.prev_x = x;