Rename all "liquid" mentions to "fluid"

This commit is contained in:
2026-10-25 13:54:53 -03:00
parent bcca8fa4a5
commit 0cfa4d9b4a
58 changed files with 547 additions and 548 deletions
+22 -22
View File
@@ -15,7 +15,7 @@ import {
TICKS_PER_SECOND,
} from "$/common/constants.ts";
import { BlockRegistry, EverythingRegistry, ItemRegistry } from "$/common/everything_registry.ts";
import { LiquidFlow } from "./liquids.ts";
import { FluidFlow } from "./fluids.ts";
import { Container, ItemData, ItemStack } from "$/common/inventory.ts";
import {
AIR_ID,
@@ -38,8 +38,8 @@ import {
can_stand_on,
chunk_key,
display_name,
fluid_block,
is_waterlogged,
liquid_block,
placement_target,
set_state_value,
waterlog_placement,
@@ -182,8 +182,8 @@ export class GameServer {
recipes: RecipeBook;
// monsters spawning on their own near players, see natural_spawner.ts
spawner: NaturalSpawner;
// water and other liquids flowing, see liquids.ts
liquids: LiquidFlow;
// water and other fluids flowing, see fluids.ts
fluids: FluidFlow;
// minecraft's doMobSpawning game rule. tests turn it off so nothing turns up they didn't put there
do_mob_spawning = true;
// what runs tick(), for /tps. tests call tick() themselves
@@ -215,7 +215,7 @@ export class GameServer {
);
}
this.world = new ServerWorld(saved?.seed ?? default_seed, mods.worldgen);
this.liquids = new LiquidFlow({
this.fluids = new FluidFlow({
value_at: (x, y, z) => {
if (y < 0 || y >= CHUNK_HEIGHT) return undefined;
const loaded = this.world.has_chunk(Math.floor(x / CHUNK_SIZE), Math.floor(z / CHUNK_SIZE));
@@ -280,7 +280,7 @@ export class GameServer {
// players without the chunk get the block with it when they do, like minecraft
this.world.on_block_change = (x, y, z, id, state) => {
this.liquids.changed(x, y, z, this.#tick);
this.fluids.changed(x, y, z, this.#tick);
const data = JSON.stringify(
(state
? { type: "set_block", x, y, z, id, state }
@@ -384,7 +384,7 @@ export class GameServer {
}
this.#new_days();
this.liquids.tick(this.#tick);
this.fluids.tick(this.#tick);
this.#tick_vitals();
for (const player of this.#players.values()) this.#tick_using(player);
this.#tick_entities();
@@ -805,9 +805,9 @@ export class GameServer {
: drops && info.drop_table
? [new ItemStack(info.drop_table)]
: [];
// a waterlogged block leaves its liquid behind, a source
const liquid = is_waterlogged(value, info) ? liquid_block(value, info) : undefined;
this.set_block(x, y, z, liquid?.id ?? AIR_ID, player);
// a waterlogged block leaves its fluid behind, a source
const fluid = is_waterlogged(value, info) ? fluid_block(value, info) : undefined;
this.set_block(x, y, z, fluid?.id ?? AIR_ID, player);
if (!how.collect) { for (const stack of loot) this.pop_item(x, y, z, stack); }
return loot;
}
@@ -1323,8 +1323,8 @@ export class GameServer {
const value = this.world.get_block_value(x, y, z);
const held_slot = player.inventory.get_slot(player.selected_slot);
const held = EverythingRegistry.get<ItemRegistry>("items", held_slot.type_id ?? "");
// an item aimed at liquids, like a bucket, uses the liquid in a waterlogged block instead of the block
const used = (held?.targets_liquids && liquid_block(value, info)) || info;
// an item aimed at fluids, like a bucket, uses the fluid in a waterlogged block instead of the block
const used = (held?.targets_fluids && fluid_block(value, info)) || info;
const block = this.mods.block_ref(x, y, z, used.id);
const interact = { player: player_api, block, item: player_api.held_item };
const before_interact = { ...interact, cancel: false };
@@ -1364,7 +1364,7 @@ export class GameServer {
return;
}
// placing a liquid, like a water bucket, into a block that can hold it fills it, like minecraft's
// placing a fluid, like a water bucket, into a block that can hold it fills it, like minecraft's
if (held?.block_id && info.waterloggable === held.block_id && !is_waterlogged(value, info)) {
this.#waterlog(player, x, y, z, face, hit);
return;
@@ -1399,7 +1399,7 @@ export class GameServer {
this.#correct(player, tx, ty, tz);
return;
}
// put into a source of the liquid it can hold, it holds it
// put into a source of the fluid it can hold, it holds it
const placed_value = waterlog_placement(
ruled_value,
placing,
@@ -1420,7 +1420,7 @@ export class GameServer {
this.mods.after.block_place.emit(place);
}
// the held liquid poured into the block at x y z, which can hold it. it's placing the liquid as far as mods can tell,
// the held fluid poured into the block at x y z, which can hold it. it's placing the fluid as far as mods can tell,
// so a bucket empties like it does placing water anywhere else
#waterlog(player: ServerPlayer, x: number, y: number, z: number, face: Faces, hit: number[]) {
const held_slot = player.inventory.get_slot(player.selected_slot);
@@ -1984,19 +1984,19 @@ export class GameServer {
}
const vitals = player.vitals;
const in_liquid = this.#in_liquid(x, y, z);
const in_fluid = this.#in_fluid(x, y, z);
const sprinting = horizontal / (ticks * TICK_DELTA) > SPRINT_SPEED;
if (in_liquid) {
if (in_fluid) {
vitals.add_exhaustion(EXHAUSTION.swim_per_block * (horizontal + Math.abs(dy)));
player.fall_distance = 0;
} else if (sprinting) {
vitals.add_exhaustion(EXHAUSTION.sprint_per_block * horizontal);
}
if (dy > 0 && !in_liquid && this.#on_ground(player.x, player.y, player.z)) {
if (dy > 0 && !in_fluid && this.#on_ground(player.x, player.y, player.z)) {
vitals.add_exhaustion(sprinting ? EXHAUSTION.sprint_jump : EXHAUSTION.jump);
}
if (dy < 0 && !in_liquid) {
if (dy < 0 && !in_fluid) {
player.fall_distance -= dy;
}
if (player.on_ground) {
@@ -2024,10 +2024,10 @@ export class GameServer {
return !physics.box_is_free(under_feet, 0, 0, 0, (bx, by, bz) => this.world.collision_shape(bx, by, bz));
}
// in liquid, a waterlogged block's too
#in_liquid(x: number, y: number, z: number) {
// in fluid, a waterlogged block's too
#in_fluid(x: number, y: number, z: number) {
const [bx, by, bz] = [Math.floor(x), Math.floor(y), Math.floor(z)];
return liquid_block(this.world.get_block_value(bx, by, bz), this.world.get_block_info(bx, by, bz)) !==
return fluid_block(this.world.get_block_value(bx, by, bz), this.world.get_block_info(bx, by, bz)) !==
undefined;
}