Remove collision from water

This commit is contained in:
2026-09-25 17:21:46 -03:00
parent d07528bd0e
commit 05f80c81ad
9 changed files with 26 additions and 7 deletions
+1 -2
View File
@@ -1,4 +1,3 @@
import { AIR } from "$/common/constants.ts";
import { move_body } from "$/common/physics.ts";
import type { ClientLevel } from "../level/client_level.ts";
@@ -73,7 +72,7 @@ export abstract class Entity {
// falls and moves by its velocity for one tick, see move_body
move() {
const collisions = move_body(this, this.gravity, (x, y, z) => this.level.get_block(x, y, z) !== AIR);
const collisions = move_body(this, this.gravity, (x, y, z) => this.level.has_collision(x, y, z));
this.colliding_x = collisions.x;
this.colliding_y = collisions.y;
this.colliding_z = collisions.z;
+6
View File
@@ -254,6 +254,12 @@ export class ClientLevel {
return chunk.blocks[index] & ID_MASK;
}
// whether entities bump into the block there. unloaded chunks count as solid, so nothing falls out of the world
has_collision(x: number, y: number, z: number) {
const block = this.get_block(x, y, z);
return block === VOID || (block !== AIR && (this.#blocks[block]?.has_collision ?? true));
}
// only changes what this client shows, drops and everything else happen on the server
break_block(x: number, y: number, z: number) {
const block_chunk_x = Math.floor(x / CHUNK_SIZE);