Rename engine to cubi

This commit is contained in:
2026-11-03 17:17:37 -03:00
parent 68b78f053a
commit 98fa45ebd1
109 changed files with 643 additions and 788 deletions
+11 -11
View File
@@ -169,7 +169,7 @@ export interface PlacedModel {
collision_shape?: number[][];
}
export const DEFAULT_MODEL = "engine:cube";
export const DEFAULT_MODEL = "cubi:cube";
const cube_face = (texture: string, cullface: ModelFace): ModelFaceJson => ({ texture, cullface });
@@ -177,8 +177,8 @@ const cube_face = (texture: string, cullface: ModelFace): ModelFaceJson => ({ te
export const BUILTIN_MODELS: Record<string, ModelJson> = {
// a full block. "textures" can be one texture, { top, bottom, side } or { front, side }. the front is north, like
// minecraft's furnace, so a facing state turns it towards whoever placed it
"engine:cube": {
id: "engine:cube",
"cubi:cube": {
id: "cubi:cube",
textures: { top: "#side", bottom: "#side", front: "#side" },
elements: [{
from: [0, 0, 0],
@@ -194,16 +194,16 @@ export const BUILTIN_MODELS: Record<string, ModelJson> = {
}],
},
// two crossed planes, like flowers and saplings. uses the "cross" texture
"engine:cross": {
id: "engine:cross",
"cubi:cross": {
id: "cubi:cross",
elements: [
cross_plane(45),
cross_plane(-45),
],
},
// four planes in a # shape, like wheat. uses the "crop" texture
"engine:crop": {
id: "engine:crop",
"cubi:crop": {
id: "cubi:crop",
elements: [
{ from: [4, 0, 0], to: [4, 16, 16], shade: false, faces: both_ways("west", "east", "#crop") },
{ from: [12, 0, 0], to: [12, 16, 16], shade: false, faces: both_ways("west", "east", "#crop") },
@@ -241,10 +241,10 @@ export function resolve_texture(reference: string, textures: BlockTextures | und
const name = reference.slice(1);
if (typeof textures === "string") return textures;
const next = (textures as Record<string, string> | undefined)?.[name] ?? model?.textures?.[name];
if (next === undefined) return "engine:missing";
if (next === undefined) return "cubi:missing";
reference = next;
}
return reference.startsWith("#") ? "engine:missing" : reference;
return reference.startsWith("#") ? "cubi:missing" : reference;
}
// the variables a texture reference goes through before it's a texture id, "#front" on a cube is front then side
@@ -358,14 +358,14 @@ export function block_item_texture(block: BlockRegistry): string | undefined {
}
const textures = block.textures;
if (typeof textures === "string") return textures;
return Object.values(textures)[0] ?? "engine:missing";
return Object.values(textures)[0] ?? "cubi:missing";
}
export function cube_face_texture(block: BlockRegistry, face: "top" | "bottom" | "front" | "side") {
return resolve_texture(`#${face}`, cube_textures(block), BUILTIN_MODELS[DEFAULT_MODEL]);
}
// the block's textures as engine:cube's. a fluid's { still, flowing } are its top and bottom, and its sides, for its
// the block's textures as cubi:cube's. a fluid's { still, flowing } are its top and bottom, and its sides, for its
// item and its particles. the chunk mesher draws fluids itself
export function cube_textures(block: BlockRegistry): BlockTextures {
if (!block.fluid) return block.textures;