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
+11 -11
View File
@@ -12,7 +12,7 @@ import type { BlockRegistry } from "$/common/everything_registry.ts";
import type { ItemStack } from "$/common/inventory.ts";
import type { Shape } from "$/common/block_shapes.ts";
import type { Season } from "$/common/worldgen/biomes.ts";
import { type Collisions, type LiquidInCell, physics } from "$/common/physics.ts";
import { type Collisions, type FluidInCell, physics } from "$/common/physics.ts";
import type { EntityData, EntityEvent, EntityInfo } from "$/common/protocol.ts";
import type { ServerPlayer } from "../player.ts";
@@ -70,9 +70,9 @@ export interface EntityLevel {
// what it bumps into at a block, see common/physics.ts
collision_shape(x: number, y: number, z: number): boolean | Shape;
// water, and other blocks you're in instead of on
is_liquid(x: number, y: number, z: number): boolean;
// the liquid there and how high it is, for liquids pushing things along
liquid_at(x: number, y: number, z: number): LiquidInCell | undefined;
is_fluid(x: number, y: number, z: number): boolean;
// the fluid there and how high it is, for fluids pushing things along
fluid_at(x: number, y: number, z: number): FluidInCell | undefined;
get_block_info(x: number, y: number, z: number): BlockRegistry | undefined;
// the column's biome, like "bworld:plains"
biome_at(x: number, z: number): string;
@@ -241,10 +241,10 @@ export abstract class Entity {
this.fall_distance = 0;
this.fire = 0;
}
if (this.pushed_by_liquid) {
physics.push_by_liquid(
if (this.pushed_by_fluid) {
physics.push_by_fluid(
this,
(x, y, z) => this.level.liquid_at(x, y, z),
(x, y, z) => this.level.fluid_at(x, y, z),
(x, y, z) => this.level.collision_shape(x, y, z),
false,
);
@@ -266,18 +266,18 @@ export abstract class Entity {
}
}
// flowing liquid pushes it along, like minecraft's isPushedByFluid
get pushed_by_liquid() {
// flowing fluid pushes it along, like minecraft's isPushedByFluid
get pushed_by_fluid() {
return true;
}
update_in_water() {
this.in_water = physics.in_water(this, (x, y, z) => this.level.is_liquid(x, y, z));
this.in_water = physics.in_water(this, (x, y, z) => this.level.is_fluid(x, y, z));
}
// its eyes are in water, so it can't breathe
get eyes_in_water() {
return physics.eyes_in_water(this, this.eye_height, (x, y, z) => this.level.is_liquid(x, y, z));
return physics.eyes_in_water(this, this.eye_height, (x, y, z) => this.level.is_fluid(x, y, z));
}
// falls and moves by its velocity for one tick (see move_body), and counts how far it fell. returns what it hit
+5 -5
View File
@@ -6,7 +6,7 @@
// when those move or change, and forgets them when they leave it
import { CHUNK_SIZE } from "$/common/constants.ts";
import { is_within_view } from "$/common/chunk_streaming.ts";
import { liquid_block, liquid_in_cell } from "$/common/utils.ts";
import { fluid_block, fluid_in_cell } from "$/common/utils.ts";
import { biome_season } from "$/common/worldgen/biomes.ts";
import type { ItemStack } from "$/common/inventory.ts";
import type { EntityEvent, EntityInfo, ServerMessage } from "$/common/protocol.ts";
@@ -99,9 +99,9 @@ export class EntityManager implements EntityLevel {
return this.#host.world.collision_shape(x, y, z);
}
is_liquid(x: number, y: number, z: number) {
is_fluid(x: number, y: number, z: number) {
const world = this.#host.world;
return liquid_block(world.get_block_value(x, y, z), world.get_block_info(x, y, z)) !== undefined;
return fluid_block(world.get_block_value(x, y, z), world.get_block_info(x, y, z)) !== undefined;
}
get_block_info(x: number, y: number, z: number) {
@@ -116,9 +116,9 @@ export class EntityManager implements EntityLevel {
return biome_season(this.biome_at(x, z), this.#host.world.time);
}
liquid_at(x: number, y: number, z: number) {
fluid_at(x: number, y: number, z: number) {
const world = this.#host.world;
return liquid_in_cell(world.get_block_value(x, y, z), world.get_block_info(x, y, z));
return fluid_in_cell(world.get_block_value(x, y, z), world.get_block_info(x, y, z));
}
nearest_player(x: number, y: number, z: number, max_distance: number): ServerPlayer | undefined {
+1 -1
View File
@@ -363,7 +363,7 @@ function is_alive(target: LivingEntity) {
// undefined when the tries all fail
export function random_stand_position(mob: Mob, range: number, vertical: number, tries = 10) {
const level = mob.level;
const free = (x: number, y: number, z: number) => !level.has_collision(x, y, z) && !level.is_liquid(x, y, z);
const free = (x: number, y: number, z: number) => !level.has_collision(x, y, z) && !level.is_fluid(x, y, z);
for (let i = 0; i < tries; i++) {
const x = Math.floor(mob.x + (mob.random() * 2 - 1) * range);
const z = Math.floor(mob.z + (mob.random() * 2 - 1) * range);
+1 -1
View File
@@ -89,7 +89,7 @@ export class ItemEntity extends Entity {
// like minecraft's ItemEntity.tick, gravity goes on its speed before it moves, not along the way like
// move_body's. the floating numbers are made for that: an item bobbing up out of the water drops straight back
// in, instead of hanging above it a tick longer and falling twice as fast
if (physics.liquid_depth(this, (x, y, z) => level.liquid_at(x, y, z)) > FLOAT_DEPTH) {
if (physics.fluid_depth(this, (x, y, z) => level.fluid_at(x, y, z)) > FLOAT_DEPTH) {
this.vx *= WATER_DRAG;
this.vz *= WATER_DRAG;
if (this.vy < FLOAT_SPEED) this.vy += FLOAT_ACCELERATION;