Water flowing
This commit is contained in:
+12
-4
@@ -1,7 +1,7 @@
|
||||
// block models, in the shape of minecraft's block model json: boxes ("elements") with a texture per face.
|
||||
// a block picks one with "model" and fills in its texture variables with "textures". baking turns a model
|
||||
// into quads in block space (0 to 1) that the chunk mesher and the item renderers draw
|
||||
import type { BlockRegistry, BlockTextures } from "./everything_registry.ts";
|
||||
import { type BlockRegistry, type BlockTextures, liquid_textures } from "./everything_registry.ts";
|
||||
import { tint_without_biome } from "./worldgen/biome_colors.ts";
|
||||
import { get_state_value } from "./utils.ts";
|
||||
|
||||
@@ -190,7 +190,7 @@ export function block_variant(block: BlockRegistry, states?: Record<string, numb
|
||||
}
|
||||
return {
|
||||
model: model ?? block.model ?? DEFAULT_MODEL,
|
||||
textures: textures ?? block.textures,
|
||||
textures: textures ?? cube_textures(block),
|
||||
y: y ?? 0,
|
||||
shape: shape ?? block.shape,
|
||||
collision_shape: collision_shape ?? block.collision_shape,
|
||||
@@ -263,13 +263,21 @@ export function block_item_texture(block: BlockRegistry): string | undefined {
|
||||
}
|
||||
|
||||
export function cube_face_texture(block: BlockRegistry, face: "top" | "bottom" | "front" | "side") {
|
||||
return resolve_texture(`#${face}`, block.textures, BUILTIN_MODELS[DEFAULT_MODEL]);
|
||||
return resolve_texture(`#${face}`, cube_textures(block), BUILTIN_MODELS[DEFAULT_MODEL]);
|
||||
}
|
||||
|
||||
// the block's textures as engine:cube's. a liquid's { still, flowing } are its top and bottom, and its sides, for its
|
||||
// item and its particles. the chunk mesher draws liquids itself
|
||||
export function cube_textures(block: BlockRegistry): BlockTextures {
|
||||
if (!block.liquid) return block.textures;
|
||||
// through the variables, so a "tint" on still or flowing still finds them
|
||||
return { ...liquid_textures(block.textures), top: "#still", bottom: "#still", side: "#flowing" };
|
||||
}
|
||||
|
||||
// the color to draw a face of a block's item in, as r g b from 0 to 1. items aren't in a biome, so a biome "tint"
|
||||
// gets the default grass or foliage color, like minecraft's grass block item
|
||||
export function cube_face_tint(block: BlockRegistry, face: "top" | "bottom" | "front" | "side"): number[] {
|
||||
return item_tint(block, texture_variables(`#${face}`, block.textures, BUILTIN_MODELS[DEFAULT_MODEL]));
|
||||
return item_tint(block, texture_variables(`#${face}`, cube_textures(block), BUILTIN_MODELS[DEFAULT_MODEL]));
|
||||
}
|
||||
|
||||
// the color to draw a part of a block's item in that got its texture through these variables, see cube_face_tint
|
||||
|
||||
Reference in New Issue
Block a user