Implement tags !
This commit is contained in:
+3
-2
@@ -2,6 +2,7 @@ import { ID_MASK, STATE_SHIFT } from "./constants.ts";
|
||||
import { BlockRegistry, EverythingRegistry, ItemRegistry } from "./everything_registry.ts";
|
||||
import { block_item_texture, cube_face_texture } from "./block_models.ts";
|
||||
import type { ItemStack } from "./inventory.ts";
|
||||
import { list_matches } from "./tags.ts";
|
||||
|
||||
export function point_inside_rec(
|
||||
point_x: number,
|
||||
@@ -134,7 +135,7 @@ function compile_block_states(block_info: BlockRegistry) {
|
||||
|
||||
// whether a block can be at a spot with below under it, see place_on
|
||||
export function can_stand_on(block: BlockRegistry | undefined, below: string): boolean {
|
||||
return !block?.place_on || block.place_on.includes(below);
|
||||
return !block?.place_on || list_matches("blocks", block.place_on, below);
|
||||
}
|
||||
|
||||
// where a block placed by clicking a face of another goes: into the clicked block when it can be replaced (like water),
|
||||
@@ -158,7 +159,7 @@ export function can_place(
|
||||
if (!block) return false;
|
||||
const into = current?.id ?? "bworld:air";
|
||||
const replaceable = !current || current.replaceable === true;
|
||||
const in_ok = block.place_in ? block.place_in.includes(into) : replaceable;
|
||||
const in_ok = block.place_in ? list_matches("blocks", block.place_in, into) : replaceable;
|
||||
return in_ok && can_stand_on(block, below);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user