Rename all "liquid" mentions to "fluid"
This commit is contained in:
+14
-14
@@ -2,11 +2,11 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import { ID_MASK, STATE_SHIFT } from "./constants.ts";
|
||||
import { BlockRegistry, EverythingRegistry, ItemRegistry, liquid_height } from "./everything_registry.ts";
|
||||
import { BlockRegistry, EverythingRegistry, fluid_height, ItemRegistry } from "./everything_registry.ts";
|
||||
import { block_item_texture, cube_face_texture } from "./block_models.ts";
|
||||
import { FULL_SHAPE, type Shape } from "./block_shapes.ts";
|
||||
import type { ItemStack } from "./inventory.ts";
|
||||
import type { LiquidInCell } from "./physics.ts";
|
||||
import type { FluidInCell } from "./physics.ts";
|
||||
import { list_matches } from "./tags.ts";
|
||||
|
||||
export function point_inside_rec(
|
||||
@@ -191,7 +191,7 @@ export function can_place(
|
||||
const into = current?.id ?? "bworld:air";
|
||||
const replaceable = !current || current.replaceable === true;
|
||||
const in_ok = block.place_in ? list_matches("blocks", block.place_in, into) : replaceable;
|
||||
// one that's only ever waterlogged goes into a source of its liquid and nothing else
|
||||
// one that's only ever waterlogged goes into a source of its fluid and nothing else
|
||||
const source_ok = !block.waterlogged_only ||
|
||||
(current !== undefined && current.id === block.waterloggable &&
|
||||
(get_state_value(current_value, current, "level") ?? 0) === 0);
|
||||
@@ -220,31 +220,31 @@ export function chunk_key(x: number, z: number) {
|
||||
return (x + 32768) * 65536 + (z + 32768);
|
||||
}
|
||||
|
||||
// whether a block value is a waterloggable block holding its liquid
|
||||
// whether a block value is a waterloggable block holding its fluid
|
||||
export function is_waterlogged(value: number, block: BlockRegistry | undefined): boolean {
|
||||
return block?.waterloggable !== undefined && get_state_value(value, block, "waterlogged") === 1;
|
||||
}
|
||||
|
||||
// the liquid in a cell with this block value: the block itself, or the liquid it's waterlogged with. undefined for
|
||||
// the fluid in a cell with this block value: the block itself, or the fluid it's waterlogged with. undefined for
|
||||
// none. what entities swim in, see in_water in physics.ts
|
||||
export function liquid_block(value: number, block: BlockRegistry | undefined): BlockRegistry | undefined {
|
||||
if (block?.liquid) return block;
|
||||
export function fluid_block(value: number, block: BlockRegistry | undefined): BlockRegistry | undefined {
|
||||
if (block?.fluid) return block;
|
||||
if (!is_waterlogged(value, block)) return undefined;
|
||||
return EverythingRegistry.get<BlockRegistry>("blocks", block!.waterloggable!);
|
||||
}
|
||||
|
||||
// the liquid in a cell and how high it is, for liquids pushing things (see push_by_liquid in physics.ts). a waterlogged
|
||||
// the fluid in a cell and how high it is, for fluids pushing things (see push_by_fluid in physics.ts). a waterlogged
|
||||
// block holds a source
|
||||
export function liquid_in_cell(value: number, block: BlockRegistry | undefined): LiquidInCell | undefined {
|
||||
if (block?.liquid) {
|
||||
export function fluid_in_cell(value: number, block: BlockRegistry | undefined): FluidInCell | undefined {
|
||||
if (block?.fluid) {
|
||||
const level = get_state_value(value, block, "level") ?? 0;
|
||||
return { id: block.id, height: liquid_height(level, block.liquid.range) };
|
||||
return { id: block.id, height: fluid_height(level, block.fluid.range) };
|
||||
}
|
||||
const liquid = liquid_block(value, block);
|
||||
return liquid && { id: liquid.id, height: 1 };
|
||||
const fluid = fluid_block(value, block);
|
||||
return fluid && { id: fluid.id, height: 1 };
|
||||
}
|
||||
|
||||
// a waterloggable block placed where a source of its liquid is holds it, like minecraft's getStateForPlacement.
|
||||
// a waterloggable block placed where a source of its fluid is holds it, like minecraft's getStateForPlacement.
|
||||
// value is what it's placed as, current_value and current what's there now
|
||||
export function waterlog_placement(
|
||||
value: number,
|
||||
|
||||
Reference in New Issue
Block a user