Engine api
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { eyes_in_water, in_water, move_body } from "$/common/physics.ts";
|
||||
import { physics } from "$/common/physics.ts";
|
||||
import type { ClientLevel } from "../level/client_level.ts";
|
||||
|
||||
// anything that exists in the level and moves, like minecraft's Entity. position is the middle of its feet.
|
||||
@@ -61,12 +61,12 @@ export abstract class Entity {
|
||||
|
||||
// in water, like the server's Entity.in_water
|
||||
get in_water() {
|
||||
return in_water(this, (x, y, z) => this.level.is_liquid(x, y, z));
|
||||
return physics.in_water(this, (x, y, z) => this.level.is_liquid(x, y, z));
|
||||
}
|
||||
|
||||
// its eyes are in water
|
||||
get eyes_in_water() {
|
||||
return eyes_in_water(this, this.eye_height, (x, y, z) => this.level.is_liquid(x, y, z));
|
||||
return physics.eyes_in_water(this, this.eye_height, (x, y, z) => this.level.is_liquid(x, y, z));
|
||||
}
|
||||
|
||||
// after moving each tick. full speed is 5 blocks per second, a bit faster than walking
|
||||
@@ -130,7 +130,7 @@ export abstract class Entity {
|
||||
const is_solid = (x: number, y: number, z: number) => this.level.collision_shape(x, y, z);
|
||||
const can_step = this.#air_ticks <= this.step_grace_ticks && this.vy <= 0;
|
||||
const friction = this.horizontal_friction();
|
||||
const collisions = move_body(this, this.gravity, is_solid, this.step_height, can_step);
|
||||
const collisions = physics.move_body(this, this.gravity, is_solid, this.step_height, can_step);
|
||||
this.colliding_x = collisions.x;
|
||||
this.colliding_y = collisions.y;
|
||||
this.colliding_z = collisions.z;
|
||||
|
||||
Reference in New Issue
Block a user