Better block models !
This commit is contained in:
@@ -9,6 +9,7 @@ import { generate_raw_chunk, RawChunk, WorldgenSetup } from "$/common/generation
|
||||
import { AIR_ID, BlockChange } from "$/common/protocol.ts";
|
||||
import { block_value, chunk_key, default_block_value } from "$/common/utils.ts";
|
||||
import { LruMap } from "./lru.ts";
|
||||
import { collision_shape_at, EMPTY_SHAPE, type Shape } from "$/common/block_shapes.ts";
|
||||
import { CYCLE_TICKS } from "$/common/time.ts";
|
||||
import { encode_level_chunk } from "$/common/chunk_streaming.ts";
|
||||
import type { ItemData } from "$/common/inventory.ts";
|
||||
@@ -158,6 +159,14 @@ export class ServerWorld {
|
||||
return this.get_block_info(x, y, z)?.has_collision ?? false;
|
||||
}
|
||||
|
||||
// what entities bump into there, see common/physics.ts
|
||||
collision_shape(x: number, y: number, z: number): Shape {
|
||||
const value = this.get_block_value(x, y, z);
|
||||
const nid = value & ID_MASK;
|
||||
const block = nid === AIR ? undefined : EverythingRegistry.get_by_id<BlockRegistry>("blocks", nid);
|
||||
return block ? collision_shape_at(block, value) : EMPTY_SHAPE;
|
||||
}
|
||||
|
||||
get_block_info(x: number, y: number, z: number): BlockRegistry | undefined {
|
||||
const nid = this.get_block_nid(x, y, z);
|
||||
return nid === AIR ? undefined : EverythingRegistry.get_by_id<BlockRegistry>("blocks", nid);
|
||||
|
||||
Reference in New Issue
Block a user