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
+4
View File
@@ -9,6 +9,10 @@ as any other mod.
Always ask before making even the simplest models, unless it's coming from ports/
## Names
- The engine is called `cubi`, all engine names should use the `cubi` namespace like `cubi:air`
## Layout
- `server/`: the game server, world, saves and server-side game logic
+2 -2
View File
@@ -375,8 +375,8 @@ use its blocks. Generic: boats with decks, falling structures and elevators woul
placement and interaction rules, for blocks like `DirectionalKineticBlock` that sneaking places the other way round.
Like Minecraft's secondary use, sneaking with an item in hand skips the clicked block's interactions and uses or places
the item, and an item's `on_use` gets the block it was used on, for the wrench's pickup. Reach is the
`bworld:block_interaction_range` and `bworld:entity_interaction_range` attributes, which clients aim with, so the
extendo grip is a modifier while it's held. `player.start_using(ticks)` uses an item over time, with `on_use_tick`,
`cubi:block_interaction_range` and `cubi:entity_interaction_range` attributes, which clients aim with, so the extendo
grip is a modifier while it's held. `player.start_using(ticks)` uses an item over time, with `on_use_tick`,
`on_release_using` and `on_finish_using`, for the sand paper, builder's tea and packages. The potato cannon and wands
are plain uses, but their reload needs item cooldowns (Minecraft's `getCooldowns`, shown on the hotbar), which aren't
built.
+1 -1
View File
@@ -69,7 +69,7 @@ async function build_sprites() {
}
}
// the engine's textures (engine:<file>), with a list of them. clients put them in the texture atlas with the mods'
// the engine's textures (cubi:<file>), with a list of them. clients put them in the texture atlas with the mods'
function build_engine_textures() {
const folder = `${BUILD_FOLDER}/assets/textures`;
Deno.mkdirSync(folder, { recursive: true });
+7 -7
View File
@@ -25,10 +25,10 @@ export interface TextureSize {
export const ATLAS_BORDER = 1;
// shelves, tallest first so each row wastes little, and by id when they're the same size so the same textures always
// give the same atlas. engine:missing is 16×16 and always there
// give the same atlas. cubi:missing is 16×16 and always there
export function atlas_layout(sizes: Map<string, TextureSize>): AtlasLayout {
const entries = [...sizes].filter(([id]) => id !== "engine:missing");
entries.push(["engine:missing", { width: TEXTURE_SIZE, height: TEXTURE_SIZE }]);
const entries = [...sizes].filter(([id]) => id !== "cubi:missing");
entries.push(["cubi:missing", { width: TEXTURE_SIZE, height: TEXTURE_SIZE }]);
entries.sort(([a, sa], [b, sb]) => sb.height - sa.height || sb.width - sa.width || a.localeCompare(b));
const area = entries.reduce(
@@ -76,8 +76,8 @@ export async function build_atlas(textures: Map<string, Uint8Array>, texture_jso
console.warn(`Texture ${id} isn't a png that can be shown, it will show as missing`);
}
}));
images.get("engine:missing")?.close();
images.delete("engine:missing");
images.get("cubi:missing")?.close();
images.delete("cubi:missing");
const animations = new Map<string, Animation>();
for (const [id, image] of images) {
@@ -95,7 +95,7 @@ export async function build_atlas(textures: Map<string, Uint8Array>, texture_jso
const ctx = canvas.getContext("2d")!;
// magenta and black checker
const missing = regions["engine:missing"];
const missing = regions["cubi:missing"];
const half = TEXTURE_SIZE / 2;
ctx.fillStyle = "magenta";
ctx.fillRect(missing.x, missing.y, half, half);
@@ -208,7 +208,7 @@ export async function engine_textures(): Promise<Map<string, Uint8Array>> {
const textures = new Map<string, Uint8Array>();
await Promise.all(names.map(async (name) => {
const response = await fetch(`/assets/textures/${name}.png`);
textures.set(`engine:${name}`, new Uint8Array(await response.arrayBuffer()));
textures.set(`cubi:${name}`, new Uint8Array(await response.arrayBuffer()));
}));
return textures;
}
+1 -1
View File
@@ -19,7 +19,7 @@ const SWING_TICKS = 6;
// an entity the server simulates, like a mob. this only follows where it's told it is and keeps what it was told
// it looks like, for drawing it
export class RemoteEntity extends Entity {
// the entity type, like "bworld:item"
// the entity type, like "cubi:item"
readonly type: string;
// synced data, see EntityData
data: EntityData;
+1 -1
View File
@@ -409,7 +409,7 @@ export function fluid_rgb(fluid: FluidVariant): Vec3 {
export function fluid_look(fluid: FluidVariant): { texture: string; tint: Vec3 } {
const json = EverythingRegistry.get<FluidJson>("fluids", fluid?.id);
if (!json) throw new Error(`there's no fluid ${fluid?.id}`);
return { texture: json.texture ?? "engine:missing", tint: fluid_rgb(structuredClone(fluid)) };
return { texture: json.texture ?? "cubi:missing", tint: fluid_rgb(structuredClone(fluid)) };
}
// where a model's uv in pixels (0-16) is in the atlas. the atlas's border around each sprite (see ATLAS_BORDER) keeps
+1 -1
View File
@@ -204,7 +204,7 @@ export class LevelRenderer {
return;
}
const tex = AssetManager.instance.get<Texture>("bworld:textures");
const region = get_sprite_region(`engine:break_${stage}`);
const region = get_sprite_region(`cubi:break_${stage}`);
for (const quad of this.#destroy_quads(info, value)) {
push_decal_quad(tex, quad, x, y, z, region);
}
+1 -1
View File
@@ -487,7 +487,7 @@ export function fluid_box(texture: string, tint: number[], from: number[], to: n
for (let at = (Math.floor(from[axis] / 16) + 1) * 16; at < to[axis]; at += 16) points.push(at);
return [...points, to[axis]];
});
const model: ModelJson = { id: "engine:fluid_box", textures: { fluid: texture }, elements: [] };
const model: ModelJson = { id: "cubi:fluid_box", textures: { fluid: texture }, elements: [] };
const quads: InstanceQuad[] = [];
for (let i = 0; i < cuts[0].length - 1; i++) {
for (let j = 0; j < cuts[1].length - 1; j++) {
+1 -1
View File
@@ -8,6 +8,6 @@ type TexturesInfo = Record<string, SpriteRegion>;
export function get_sprite_region(id: string): SpriteRegion {
const textures_info = AssetManager.instance.get<TexturesInfo>("bworld:textures_info");
return textures_info?.[id] ?? textures_info?.["engine:missing"] ??
return textures_info?.[id] ?? textures_info?.["cubi:missing"] ??
{ x: 0, y: 0, width: TEXTURE_SIZE, height: TEXTURE_SIZE };
}
+4 -4
View File
@@ -473,7 +473,7 @@ function block_quads(value: number): MeshQuad[] {
flush: quad.flush,
group: quad.aligned ? quad.face : UNALIGNED_GROUP,
shade: quad.shade ? FACE_SHADE[quad.face] : 1,
sprite: textures_info[quad.texture] ?? textures_info["engine:missing"],
sprite: textures_info[quad.texture] ?? textures_info["cubi:missing"],
light_weights: light_weights(quad.face, quad.positions),
tint: quad_tint(block, quad.variables),
}));
@@ -595,8 +595,8 @@ function fill_fluid_cells(chunks: (Uint32Array | null)[], nid: number, index: nu
function flowing_scale(block: BlockRegistry): number | undefined {
const textures = fluid_textures(block.textures);
if (textures.flowing === textures.still) return undefined;
const still = textures_info[textures.still] ?? textures_info["engine:missing"];
const flowing = textures_info[textures.flowing] ?? textures_info["engine:missing"];
const still = textures_info[textures.still] ?? textures_info["cubi:missing"];
const flowing = textures_info[textures.flowing] ?? textures_info["cubi:missing"];
return Math.min(1, still.width / flowing.width);
}
@@ -619,7 +619,7 @@ function fluid_mesh_quad(
flush: true,
group: flat ? face : UNALIGNED_GROUP,
shade: FACE_SHADE[face],
sprite: textures_info[still ? textures.still : textures.flowing] ?? textures_info["engine:missing"],
sprite: textures_info[still ? textures.still : textures.flowing] ?? textures_info["cubi:missing"],
light_weights: light_weights(face, positions),
tint: quad_tint(block, [still ? "still" : "flowing"]),
};
+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;
+1 -1
View File
@@ -203,7 +203,7 @@ export class BlockRules {
let neighbor: SharedBlock | undefined;
for (const { mod, id: rules_id, rules, params } of this.#of(block)) {
if (!rules.on_neighbor_change) continue;
const changed = neighbor ??= { ...from, id: this.get_block(from.x, from.y, from.z) ?? "bworld:air" };
const changed = neighbor ??= { ...from, id: this.get_block(from.x, from.y, from.z) ?? "cubi:air" };
const at = { x, y, z, id };
this.run(mod, `${rules_id} on_neighbor_change`, () => rules.on_neighbor_change!(at, params, changed));
}
-148
View File
@@ -1,148 +0,0 @@
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
// SPDX-License-Identifier: AGPL-3.0-or-later
import { EverythingRegistry } from "$/common/everything_registry.ts";
interface CropsRegistry {
total_stages: number;
time_to_grow: number[];
item_drop: string;
sprite_ids: string[];
regrowable: boolean;
}
EverythingRegistry.register<CropsRegistry>("crops", "bworld:carrot", {
total_stages: 5,
time_to_grow: [60, 60 * 3, 60 * 3, 60 * 3],
sprite_ids: [
"bworld:carrot_seeds",
"bworld:carrot_stage_1",
"bworld:carrot_stage_2",
"bworld:carrot_stage_3",
"bworld:carrot_stage_4",
],
item_drop: "bworld:carrot",
regrowable: false,
});
EverythingRegistry.register<CropsRegistry>("crops", "bworld:potato", {
total_stages: 5,
time_to_grow: [45, 60 * 2, 60 * 2, 60 * 2],
sprite_ids: [
"bworld:potato_seeds",
"bworld:potato_stage_1",
"bworld:potato_stage_2",
"bworld:potato_stage_3",
"bworld:potato_stage_4",
],
item_drop: "bworld:potato",
regrowable: false,
});
EverythingRegistry.register<CropsRegistry>("crops", "bworld:tomato", {
total_stages: 5,
time_to_grow: [90, 60 * 2, 60 * 2, 60 * 3],
sprite_ids: [
"bworld:tomato_seeds",
"bworld:tomato_stage_1",
"bworld:tomato_stage_2",
"bworld:tomato_stage_3",
"bworld:tomato_stage_4",
],
item_drop: "bworld:tomato",
regrowable: true,
});
EverythingRegistry.register<CropsRegistry>("crops", "bworld:pumpkin", {
total_stages: 5,
time_to_grow: [60 * 2, 60 * 4, 60 * 4, 60 * 4],
sprite_ids: [
"bworld:pumpkin_seeds",
"bworld:pumpkin_stage_1",
"bworld:pumpkin_stage_2",
"bworld:pumpkin_stage_3",
"bworld:pumpkin_stage_4",
],
item_drop: "bworld:pumpkin",
regrowable: false,
});
interface TileCropData {
current_stage: number;
growth_time: number;
}
/*
function create_crop_tile(crop_id: string) {
const crop_info = EverythingRegistry.get<CropsRegistry>("crops", crop_id);
return {
has_collision: false,
on_create(_, tile) {
tile.data = {
current_stage: 0,
growth_time: 0,
};
},
texture_id(tile) {
return crop_info.sprite_ids[tile.data!.current_stage];
},
on_click(world, tile) {
const [player] = world.get_tag("player")!;
const player_inventory = player.get(PlayerComponent)!.player_inventory;
const item = player_inventory.container.get_item(player_inventory.hotbar_selected);
if (!item) {
return;
}
if (item.type_id === "bworld:pickaxe") {
world.dimension.delete_tile(world, tile);
}
},
on_interact(world, tile) {
if (tile.data!.current_stage + 1 !== crop_info.total_stages) {
return;
}
const [player] = world.get_tag("player")!;
const player_inventory = player.get(PlayerComponent)!.player_inventory;
player_inventory.container.add_item(new ItemStack(crop_info.item_drop));
if (crop_info.regrowable) {
tile.data!.current_stage -= 1;
} else {
world.dimension.delete_tile(world, tile);
}
},
on_second(_, tile, delta) {
const crop = tile.data!;
// finished growing
if (crop.current_stage + 1 === crop_info.total_stages) {
return;
}
// grow !
crop.growth_time += delta;
if (crop.growth_time >= crop_info.time_to_grow[crop.current_stage]) {
crop.current_stage += 1;
crop.growth_time = 0;
}
},
} as BlockRegistry<TileCropData>;
}
EverythingRegistry.register<BlockRegistry<TileCropData>>(
"blocks",
"bworld:tomato_crop",
create_crop_tile("bworld:tomato"),
);
EverythingRegistry.register<BlockRegistry<TileCropData>>(
"blocks",
"bworld:carrot_crop",
create_crop_tile("bworld:carrot"),
);
EverythingRegistry.register<BlockRegistry<TileCropData>>(
"blocks",
"bworld:potato_crop",
create_crop_tile("bworld:potato"),
);
EverythingRegistry.register<BlockRegistry<TileCropData>>(
"blocks",
"bworld:pumpkin_crop",
create_crop_tile("bworld:pumpkin"),
);
*/
+1 -1
View File
@@ -377,7 +377,7 @@ function registry_id(registry: string, what: string): ArgumentType<string> {
suggest(partial) {
return EverythingRegistry.entries(registry)
.map(([id]) => id)
.filter((id) => id !== "bworld:air" && (id.startsWith(partial) || id.split(":")[1].startsWith(partial)))
.filter((id) => id !== "cubi:air" && (id.startsWith(partial) || id.split(":")[1].startsWith(partial)))
.map((id) => ({ text: id }));
},
};
+1 -1
View File
@@ -49,7 +49,7 @@ export const PLAYER_EYE_HEIGHT = 1.69;
export const PLAYER_SWIM_HEIGHT = 0.8;
export const PLAYER_SWIM_EYE_HEIGHT = 0.6;
// the stages of cracks on a block being broken, 0 to this, each drawn with engine:break_<stage>
// the stages of cracks on a block being broken, 0 to this, each drawn with cubi:break_<stage>
export const BREAK_STAGES = 8;
// where a block placed against each face of another block goes
+3 -3
View File
@@ -71,7 +71,7 @@ export class EverythingRegistry {
}
// one texture for everything, or the model's texture variables: { top, bottom, side } or { front, side } for
// cubes, { crop } for engine:crop and so on
// cubes, { crop } for cubi:crop and so on
export type BlockTextures = string | Record<string, string>;
export interface BlockStateDefinition {
@@ -106,7 +106,7 @@ export interface BlockRegistry {
// what players see, like "Iron Ore". made from the id when not set, see display_name in common/utils.ts
name?: string;
textures: BlockTextures;
// the block model, engine:cube when not set. see common/block_models.ts
// the block model, cubi:cube when not set. see common/block_models.ts
model?: string;
// solid when not set. anything else doesn't hide its neighbors' faces
render_layer?: RenderLayer;
@@ -199,7 +199,7 @@ export function is_fluid_block(block: BlockRegistry | undefined): boolean {
// a fluid's textures as the top, bottom and sides of a cube, for its item and its particles
export function fluid_textures(textures: BlockTextures): { still: string; flowing: string } {
if (typeof textures === "string") return { still: textures, flowing: textures };
const still = textures.still ?? "engine:missing";
const still = textures.still ?? "cubi:missing";
return { still, flowing: textures.flowing ?? still };
}
+2 -2
View File
@@ -177,10 +177,10 @@ function generate_features(
return undefined;
}
const nid = blocks[y * CHUNK_AREA + local(x, z, "get_block")] & ID_MASK;
return nid === AIR ? "bworld:air" : ids_by_nid[nid];
return nid === AIR ? "cubi:air" : ids_by_nid[nid];
},
set_block(x, y, z, id) {
const nid = id === "bworld:air" ? AIR : block_ids[id];
const nid = id === "cubi:air" ? AIR : block_ids[id];
if (nid === undefined) {
throw new Error(`unknown block ${id}`);
}
+3 -3
View File
@@ -326,7 +326,7 @@ export interface ServerWorld {
// an item lying still at x y z, which players can pick up after half a second, like a new minecraft ItemEntity
spawn_item(x: number, y: number, z: number, item: ItemStack): EntityRef;
// the entities whose boxes touch the box between two corners, like minecraft's getEntitiesOfClass. only ones of type
// when given, like "bworld:item" for items lying around. players aren't among them, they're in ctx.players
// when given, like "cubi:item" for items lying around. players aren't among them, they're in ctx.players
entities_in(from: Position, to: Position, type?: Id): EntityRef[];
// uses item on face of the block at x y z the way a player holding it would, like a deployer: the block's
// on_interact, or the item's on_use, or placing it. a player that isn't anyone does it, standing in the block in
@@ -456,7 +456,7 @@ export interface Player {
set_worn(key: string, items: ItemStack[]): void;
teleport(x: number, y: number, z: number): void;
// health and hunger, like minecraft: 20 each, saturation is never above hunger. max_health is the
// bworld:max_health attribute
// cubi:max_health attribute
readonly health: number;
readonly max_health: number;
readonly food: number;
@@ -468,7 +468,7 @@ export interface Player {
feed(nutrition: number, saturation_modifier: number): void;
// tires them out: 4 costs a point of saturation, or of hunger once it's gone
add_exhaustion(amount: number): void;
// their stats, like minecraft's attributes: "bworld:attack_damage", "bworld:attack_speed", "bworld:max_health"...
// their stats, like minecraft's attributes: "cubi:attack_damage", "cubi:attack_speed", "cubi:max_health"...
// see docs/modding/entities/players.md. modifiers aren't saved, they're gone when the player leaves
attribute(id: Id): number;
// replaces one with the same id on that attribute
+1 -1
View File
@@ -189,7 +189,7 @@ export interface SharedContext {
}
export interface SharedWorld {
// undefined when the chunk isn't loaded, "bworld:air" for air
// undefined when the chunk isn't loaded, "cubi:air" for air
get_block(x: number, y: number, z: number): Id | undefined;
get_state(x: number, y: number, z: number, name: string): number | undefined;
// changing what a block is tells the blocks beside it, see BlockRules.on_neighbor_change
+4 -4
View File
@@ -134,7 +134,7 @@ export function load_order(mods: LoadedMod[]): LoadedMod[] {
// it has none, and an item file without a texture only adds to its block's item
export function registered_ids(mods: LoadedMod[]): Record<TagRegistry, Set<string>> {
const ids: Record<TagRegistry, Set<string>> = {
blocks: new Set(["bworld:air"]),
blocks: new Set(["cubi:air"]),
items: new Set(),
entities: new Set(),
biomes: new Set(),
@@ -151,7 +151,7 @@ export function registered_ids(mods: LoadedMod[]): Record<TagRegistry, Set<strin
return ids;
}
// engine_textures are the engine: texture ids, for telling whether a texture a mod uses exists
// engine_textures are the cubi: texture ids, for telling whether a texture a mod uses exists
export function check_references(mods: LoadedMod[], engine_textures: Iterable<string>) {
const block_owners = new Map<string, string[]>();
const item_owners = new Map<string, string[]>();
@@ -240,7 +240,7 @@ export function check_references(mods: LoadedMod[], engine_textures: Iterable<st
const tag = id.startsWith("#");
const namespace = id.replace("#", "").split(":")[0];
if (tag && namespace === SHARED_TAG_NAMESPACE) return;
if (namespace !== mod.id && namespace !== "engine" && !dependencies.has(namespace)) {
if (namespace !== mod.id && namespace !== "cubi" && !dependencies.has(namespace)) {
warnings.push(`${file}: uses ${id} but doesn't list "${namespace}" in dependencies`);
}
};
@@ -290,7 +290,7 @@ export function check_references(mods: LoadedMod[], engine_textures: Iterable<st
}
}
for (const id of [...(json.place_on ?? []), ...(json.place_in ?? [])]) {
if (id !== "bworld:air") uses(file, id, "block");
if (id !== "cubi:air") uses(file, id, "block");
}
}
for (const { file, json } of mod.models) {
+3 -3
View File
@@ -43,7 +43,7 @@ import {
export const FORMAT_VERSION = 1;
export const NAMESPACE_PATTERN = /^[a-z0-9_]{1,32}$/;
export const RESERVED_NAMESPACES = ["bworld", "engine"];
export const RESERVED_NAMESPACES = ["bworld", "cubi"];
// the namespace for tags every mod shares, like neoforge's. no mod owns it
export const SHARED_TAG_NAMESPACE = "c";
export const TAG_REGISTRIES = ["blocks", "items", "entities", "biomes"] as const;
@@ -256,7 +256,7 @@ function check_block(block: z.infer<typeof block_fields>, ctx: z.RefinementCtx)
problem(["states"], `can't have "${FLUID_LEVEL.name}", a fluid gets that state of its own`);
}
if (block.waterloggable !== undefined) problem(["waterloggable"], "isn't for fluids");
} else if (block.parts === undefined && (block.model ?? "engine:cube") === "engine:cube") {
} else if (block.parts === undefined && (block.model ?? "cubi:cube") === "cubi:cube") {
if (!cube_textures.safeParse(block.textures).success) {
problem(["textures"], "must be a texture id, { top, bottom, side } or { front, side }");
}
@@ -484,7 +484,7 @@ const fluid_schema = z.object({
name: text.optional(),
// for whatever shows it, like a layer tinted "fluid" on a full container
color,
// what a box of it is drawn with, tinted by its color, like neoforge's still texture. engine:missing when not set
// what a box of it is drawn with, tinted by its color, like neoforge's still texture. cubi:missing when not set
texture: z.string().optional(),
// what 1000 mB of it is worth when sold in a fluid container, like an item's base_sell_value
base_sell_value: z.int().min(0).optional(),
+1 -1
View File
@@ -111,7 +111,7 @@ export class ModLoadError extends Error {
// whether a block, item, entity or biome is registered, for tags. air isn't a registered block, but tags can hold it
export function is_registered(registry: TagRegistry, id: string): boolean {
return (registry === "blocks" && id === "bworld:air") || EverythingRegistry.get(registry, id) !== undefined;
return (registry === "blocks" && id === "cubi:air") || EverythingRegistry.get(registry, id) !== undefined;
}
// registers every mod's blocks, items, entities, effects, fluids, tags and recipes, in the order given (dependencies
+2 -2
View File
@@ -7,11 +7,11 @@ import type { ItemData } from "./inventory.ts";
import type { FluidVariant } from "./mod_api/shared.ts";
import type { ModListing } from "./mod_loader.ts";
export const AIR_ID = "bworld:air";
export const AIR_ID = "cubi:air";
// bump when a client and server of different versions can't play together.
// the server rejects a different version before the client downloads anything
export const PROTOCOL_VERSION = 25;
export const PROTOCOL_VERSION = 26;
export interface PlayerInfo {
id: string;
+2 -2
View File
@@ -74,7 +74,7 @@ export function item_texture(
item: ItemStack,
info = EverythingRegistry.get<ItemRegistry>("items", item.type_id),
): string {
if (!info) return "engine:missing";
if (!info) return "cubi:missing";
const data = item.data as Record<string, unknown> | undefined;
for (const [key, texture] of Object.entries(info.data_textures ?? {})) {
if (data?.[key]) return texture;
@@ -234,7 +234,7 @@ export function can_place(
below: string,
): boolean {
if (!block) return false;
const into = current?.id ?? "bworld:air";
const into = current?.id ?? "cubi: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 fluid and nothing else
+1 -1
View File
@@ -18,7 +18,7 @@ a snowy biome.
"format_version": 1,
"block": {
"id": "bworld:cabbages",
"model": "engine:cross",
"model": "cubi:cross",
"textures": { "cross": "bworld:cabbages_stage0" },
"variants": {
"age=1": { "textures": { "cross": "bworld:cabbages_stage1" } },
+15 -15
View File
@@ -30,21 +30,21 @@ of tier 1 (stone or copper) or better.
### Looks
| Field | Default | Meaning |
| ---------------- | ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id` | required | The block's id. |
| `name` | from the id | What players see. `copper_tools:copper_block` is "Copper Block" when not set. Its item uses it too. |
| `textures` | required | One texture id for every side, `{ "top", "bottom", "side" }`, or `{ "front", "side" }` (optionally with `top` and `bottom`) for a block that faces a way. With another `model`, the model's texture variables. |
| `model` | `engine:cube` | The [block model](../resources/models.md). |
| `variants` | none | Other models, textures or rotations for some [states](states.md). |
| `parts` | none | Models drawn together depending on [states](states.md), like a fence's post and bars. See [Parts](../resources/models.md#parts). |
| `item_model` | none | The model its item is drawn with. See [Item Models](../resources/models.md#item-models). |
| `render_layer` | `solid` | `solid`; `cutout` for texels that are fully opaque or fully clear, like leaves; `translucent` for blended ones, like water and glass. |
| `cull_same` | see meaning | Hide the faces between two of this block. `true` for translucent blocks, `false` otherwise. |
| `alpha` | `1` | Opacity, for translucent blocks. |
| `tint` | none | Draws its textures in a color, see [below](#tinting). |
| `light_emission` | `0` | Light it gives off, 0-15. A torch is 14. |
| `light_opacity` | see meaning | How much light passing through it loses, 0-15. `15` for solid blocks, `0` otherwise. Leaves and water use `1`. |
| Field | Default | Meaning |
| ---------------- | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id` | required | The block's id. |
| `name` | from the id | What players see. `copper_tools:copper_block` is "Copper Block" when not set. Its item uses it too. |
| `textures` | required | One texture id for every side, `{ "top", "bottom", "side" }`, or `{ "front", "side" }` (optionally with `top` and `bottom`) for a block that faces a way. With another `model`, the model's texture variables. |
| `model` | `cubi:cube` | The [block model](../resources/models.md). |
| `variants` | none | Other models, textures or rotations for some [states](states.md). |
| `parts` | none | Models drawn together depending on [states](states.md), like a fence's post and bars. See [Parts](../resources/models.md#parts). |
| `item_model` | none | The model its item is drawn with. See [Item Models](../resources/models.md#item-models). |
| `render_layer` | `solid` | `solid`; `cutout` for texels that are fully opaque or fully clear, like leaves; `translucent` for blended ones, like water and glass. |
| `cull_same` | see meaning | Hide the faces between two of this block. `true` for translucent blocks, `false` otherwise. |
| `alpha` | `1` | Opacity, for translucent blocks. |
| `tint` | none | Draws its textures in a color, see [below](#tinting). |
| `light_emission` | `0` | Light it gives off, 0-15. A torch is 14. |
| `light_opacity` | see meaning | How much light passing through it loses, 0-15. `15` for solid blocks, `0` otherwise. Leaves and water use `1`. |
Only `solid` blocks hide their neighbors' faces. Blocks that aren't full cubes, like plants, should use `cutout`, or
there will be holes in the world behind them.
+1 -1
View File
@@ -53,7 +53,7 @@ a texture per growth stage:
"format_version": 1,
"block": {
"id": "bworld:wheat",
"model": "engine:crop",
"model": "cubi:crop",
"textures": { "crop": "bworld:wheat_stage_0" },
"variants": {
"age=1": { "textures": { "crop": "bworld:wheat_stage_1" } },
+3 -4
View File
@@ -15,10 +15,9 @@ An id looks like `namespace:name`, like `bworld:cabbage`:
Two namespaces are reserved:
- `bworld` belongs to the base game, `mods/bworld`.
- `engine` belongs to the engine: the missing texture `engine:missing`, the breaking cracks `engine:break_0` to
`engine:break_8`, and the built-in block models `engine:cube`, `engine:cross` and `engine:crop`.
`bworld:air` is the one exception: it's the engine's empty block, but keeps that id because every save has it.
- `cubi` belongs to the engine: the empty block `cubi:air`, the entity types `cubi:player` and `cubi:item`, the
[attributes](../entities/players.md) like `cubi:max_health`, the missing texture `cubi:missing`, the breaking cracks
`cubi:break_0` to `cubi:break_8`, and the built-in block models `cubi:cube`, `cubi:cross` and `cubi:crop`.
[Tags](../resources/tags.md) aren't registered like this: they're lists that every mod can add to, their ids can have
folders (`c:ingots/iron`), and the `c` namespace is shared by every mod.
+1 -1
View File
@@ -18,7 +18,7 @@ game's effects are defined this way, in `mods/bworld/effects`.
"id": "copper_tools:swiftness",
"category": "beneficial",
"icon": "copper_tools:swiftness",
"modifiers": [{ "attribute": "bworld:movement_speed", "amount": 0.1, "operation": "add_multiplied_total" }]
"modifiers": [{ "attribute": "cubi:movement_speed", "amount": 0.1, "operation": "add_multiplied_total" }]
}
}
```
+2 -2
View File
@@ -172,12 +172,12 @@ have a `push` too, see [Players](players.md#pushing).
Minecraft's `getEntitiesOfClass`, only the ones of `type` when it's given. Players aren't among them, they're in
`ctx.players`.
Items lying around are entities of type `bworld:item`. A machine that works on them, like a press, finds them, changes
Items lying around are entities of type `cubi:item`. A machine that works on them, like a press, finds them, changes
them with `set_item`, and adds what it made with `ctx.world.spawn_item`, which lays an item down still where it's put,
unlike `drop_item`, which pops it out of a block:
```ts
const [item] = ctx.world.entities_in({ x, y: y - 1, z }, { x: x + 1, y, z: z + 1 }, "bworld:item");
const [item] = ctx.world.entities_in({ x, y: y - 1, z }, { x: x + 1, y, z: z + 1 }, "cubi:item");
const stack = item?.get_item();
if (stack?.id === "bworld:iron_ingot") {
item.set_item(stack.count > 1 ? { ...stack, count: stack.count - 1 } : undefined);
+13 -13
View File
@@ -35,7 +35,7 @@ interface Player {
teleport(x: number, y: number, z: number): void;
readonly health: number; // out of max_health
readonly max_health: number; // 20, or what the bworld:max_health attribute makes it
readonly max_health: number; // 20, or what the cubi:max_health attribute makes it
readonly food: number; // hunger, out of 20
readonly saturation: number; // never above food
@@ -74,7 +74,7 @@ what a player is looking at, like Minecraft's `getPlayerPOVHitResult`:
```ts
const eye = player.eye_position;
const look = player.look_direction;
const reach = player.attribute("bworld:block_interaction_range");
const reach = player.attribute("cubi:block_interaction_range");
const to = { x: eye.x + look.x * reach, y: eye.y + look.y * reach, z: eye.z + look.z * reach };
const hit = ctx.world.raycast(eye, to, { fluids: "source_only" });
```
@@ -106,17 +106,17 @@ even when their game isn't running, like in a background tab.
A player's stats are attributes, like Minecraft's: a base value that modifiers change without touching it.
| Attribute | Base | Meaning |
| --------------------------------- | ---- | -------------------------------------------------------------------------- |
| `bworld:attack_damage` | 1 | How much their hits do. |
| `bworld:attack_speed` | 4 | Full strength attacks a second. Hitting sooner than that does less damage. |
| `bworld:block_interaction_range` | 6 | How far from their eyes they break and use blocks, in blocks. |
| `bworld:entity_interaction_range` | 3 | How far from their eyes they hit entities, in blocks. |
| Attribute | Base | Meaning |
| ------------------------------- | ---- | -------------------------------------------------------------------------- |
| `cubi:attack_damage` | 1 | How much their hits do. |
| `cubi:attack_speed` | 4 | Full strength attacks a second. Hitting sooner than that does less damage. |
| `cubi:block_interaction_range` | 6 | How far from their eyes they break and use blocks, in blocks. |
| `cubi:entity_interaction_range` | 3 | How far from their eyes they hit entities, in blocks. |
```ts
player.add_modifier("bworld:attack_damage", { id: "my_mod:rage", amount: 2, operation: "add_value" });
player.attribute("bworld:attack_damage"); // 3
player.remove_modifier("bworld:attack_damage", "my_mod:rage");
player.add_modifier("cubi:attack_damage", { id: "my_mod:rage", amount: 2, operation: "add_value" });
player.attribute("cubi:attack_damage"); // 3
player.remove_modifier("cubi:attack_damage", "my_mod:rage");
```
The value is the base, plus every `add_value`, plus that times the amount of each `add_multiplied_base`, then times 1
@@ -136,13 +136,13 @@ reaches further gives a modifier while it's held, like Create's extendo grip:
ctx.events.after.tick.subscribe(() => {
for (const player of ctx.players.all()) {
if (player.held_item?.id === "copper_tools:grabber") {
player.add_modifier("bworld:block_interaction_range", {
player.add_modifier("cubi:block_interaction_range", {
id: "copper_tools:grabber",
amount: 3,
operation: "add_value",
});
} else {
player.remove_modifier("bworld:block_interaction_range", "copper_tools:grabber");
player.remove_modifier("cubi:block_interaction_range", "copper_tools:grabber");
}
}
});
+12 -12
View File
@@ -1,15 +1,15 @@
# Block Models
A block's model is its shape: the boxes it's made of and which texture goes on each face. Blocks use `engine:cube`
unless they set `model`. For entity models, see [Entities](../entities/index.md#entity-models).
A block's model is its shape: the boxes it's made of and which texture goes on each face. Blocks use `cubi:cube` unless
they set `model`. For entity models, see [Entities](../entities/index.md#entity-models).
## Built-In Models
| Model | Texture variables | Shape |
| -------------- | --------------------------------------------------------- | ---------------------------------------------- |
| `engine:cube` | one texture, `{ top, bottom, side }` or `{ front, side }` | A full block. |
| `engine:cross` | `cross` | Two crossed planes, like flowers and saplings. |
| `engine:crop` | `crop` | Four planes in a # shape, like wheat. |
| Model | Texture variables | Shape |
| ------------ | --------------------------------------------------------- | ---------------------------------------------- |
| `cubi:cube` | one texture, `{ top, bottom, side }` or `{ front, side }` | A full block. |
| `cubi:cross` | `cross` | Two crossed planes, like flowers and saplings. |
| `cubi:crop` | `crop` | Four planes in a # shape, like wheat. |
Blocks that aren't full cubes should use the `cutout` or `translucent` [render layer](../blocks/index.md#looks), since
`solid` blocks hide their neighbors' faces. They usually want `"collision": false` too.
@@ -24,13 +24,13 @@ Models name their textures with variables, like `#side`, and blocks fill them in
```json
{
"id": "bworld:sapling",
"model": "engine:cross",
"model": "cubi:cross",
"textures": { "cross": "bworld:sapling" }
}
```
For `engine:cube`, one texture id fills every face. `{ "front", "side" }` puts `front` on the north face and `side` on
the rest. It's for blocks that [face a way](../blocks/states.md#facing), and can also set `top` and `bottom`.
For `cubi:cube`, one texture id fills every face. `{ "front", "side" }` puts `front` on the north face and `side` on the
rest. It's for blocks that [face a way](../blocks/states.md#facing), and can also set `top` and `bottom`.
## Custom Models
@@ -126,7 +126,7 @@ player is standing in its other half, either.
By default it comes from the model: one box per element, turned with the block's `y`. An element turned by its own
`rotation` gets the box around it. Elements that are flat planes aren't boxes, so a model made only of planes, like
`engine:cross` and `engine:crop`, gets one box around all of them, which is what players point at to break the plant.
`cubi:cross` and `cubi:crop`, gets one box around all of them, which is what players point at to break the plant.
A block can set its own with `shape`, a list of boxes in pixels like `from` and `to` put together, as Minecraft's
`Block.box` does. That's for a shape simpler than the model, or one that's different from what's drawn, like a flower
@@ -136,7 +136,7 @@ their own, like a crop that's taller the older it is:
```json
{
"id": "copper_tools:rice",
"model": "engine:crop",
"model": "cubi:crop",
"textures": { "crop": "copper_tools:rice_3" },
"collision": false,
"states": [{ "name": "age", "bits": 2, "default": 0 }],
+4 -4
View File
@@ -63,15 +63,15 @@ than short ones.
## Missing Textures
A texture id that doesn't exist shows the magenta and black checker, `engine:missing`, and `check-mods` warns about it.
It isn't an error, so a mod still loads while its art is unfinished.
A texture id that doesn't exist shows the magenta and black checker, `cubi:missing`, and `check-mods` warns about it. It
isn't an error, so a mod still loads while its art is unfinished.
## Engine Textures
The engine's own textures use the `engine` namespace and come from `assets/`, not from a mod:
- `engine:missing`, the missing texture,
- `engine:break_0` to `engine:break_8`, the cracks drawn on a block being broken.
- `cubi:missing`, the missing texture,
- `cubi:break_0` to `cubi:break_8`, the cracks drawn on a block being broken.
## How Players Get Them
+4 -4
View File
@@ -268,7 +268,7 @@ If the base game can't be written as a mod, the API is missing something, and ot
**The engine** keeps what every game built on it needs: rendering, meshing, lighting and the sky; physics, player
movement and input; networking, saving, the game server and its loop; registries, the mod loader and the Game API;
containers, slot click rules, screens and the GUI toolkit; entities; chat; world time; `/tps`; `bworld:air`; and the
containers, slot click rules, screens and the GUI toolkit; entities; chat; world time; `/tps`; `cubi:air`; and the
engine assets in `assets/`.
**`mods/bworld`** has everything else:
@@ -358,9 +358,9 @@ features that are code or data (bworld's trees and cacti are code, in its worldg
workers (see [Chunk Streaming](#chunk-streaming)). The golden fixture checked every step made the same world block for
block, and the server refuses to start without the `bworld:overworld` generator.
**Done when** searching `client/`, `common/` and `server/` for `"bworld:` finds only `bworld:air`, removing
`mods/bworld` gives an engine that starts and says it needs a terrain generator, the base game uses no engine access,
and a world saved before any of this plays exactly the same.
**Done when** searching `client/`, `common/` and `server/` for `"bworld:` finds only `cubi:air`, removing `mods/bworld`
gives an engine that starts and says it needs a terrain generator, the base game uses no engine access, and a world
saved before any of this plays exactly the same.
## Open Questions
+1 -1
View File
@@ -11,7 +11,7 @@
},
"components": {
"bworld:curio_modifiers": [
{ "attribute": "bworld:attack_speed", "amount": 0.3, "operation": "add_multiplied_base" }
{ "attribute": "cubi:attack_speed", "amount": 0.3, "operation": "add_multiplied_base" }
]
}
}
+1 -1
View File
@@ -12,7 +12,7 @@
},
"components": {
"bworld:curio_modifiers": [
{ "attribute": "bworld:attack_damage", "amount": 4, "operation": "add_value" }
{ "attribute": "cubi:attack_damage", "amount": 4, "operation": "add_value" }
]
}
}
+1 -1
View File
@@ -48,7 +48,7 @@ The Power Glove from Artifacts:
```json
"components": {
"bworld:curio_modifiers": [{ "attribute": "bworld:attack_damage", "amount": 4, "operation": "add_value" }]
"bworld:curio_modifiers": [{ "attribute": "cubi:attack_damage", "amount": 4, "operation": "add_value" }]
}
```
+1 -1
View File
@@ -5,7 +5,7 @@
"textures": {
"crop": "bworld:beetroot_stage_0"
},
"model": "engine:crop",
"model": "cubi:crop",
"variants": {
"age=0": {
"textures": {
+1 -1
View File
@@ -5,7 +5,7 @@
"textures": {
"cross": "bworld:cabbages_stage0"
},
"model": "engine:cross",
"model": "cubi:cross",
"variants": {
"age=0": {
"textures": {
+1 -1
View File
@@ -5,7 +5,7 @@
"textures": {
"crop": "bworld:carrot_stage_0"
},
"model": "engine:crop",
"model": "cubi:crop",
"variants": {
"age=0": {
"textures": {
+1 -1
View File
@@ -5,7 +5,7 @@
"textures": {
"cross": "bworld:cotton_stage_0"
},
"model": "engine:cross",
"model": "cubi:cross",
"variants": {
"age=0": {
"textures": {
+1 -1
View File
@@ -6,7 +6,7 @@
"textures": {
"cross": "bworld:dead_bush"
},
"model": "engine:cross",
"model": "cubi:cross",
"render_layer": "cutout",
"collision": false,
"shape": [[2, 0, 2, 14, 13, 14]],
+1 -1
View File
@@ -5,7 +5,7 @@
"textures": {
"crop": "bworld:melon_stage_0"
},
"model": "engine:crop",
"model": "cubi:crop",
"variants": {
"age=0": {
"textures": {
+1 -1
View File
@@ -5,7 +5,7 @@
"textures": {
"crop": "bworld:onions_stage0"
},
"model": "engine:crop",
"model": "cubi:crop",
"variants": {
"age=0": {
"textures": {
+1 -1
View File
@@ -5,7 +5,7 @@
"textures": {
"crop": "bworld:potatoes_stage_0"
},
"model": "engine:crop",
"model": "cubi:crop",
"variants": {
"age=0": {
"textures": {
+1 -1
View File
@@ -5,7 +5,7 @@
"textures": {
"crop": "bworld:pumpkin_stage_0"
},
"model": "engine:crop",
"model": "cubi:crop",
"variants": {
"age=0": {
"textures": {
+1 -1
View File
@@ -5,7 +5,7 @@
"textures": {
"cross": "bworld:rice_stage0"
},
"model": "engine:cross",
"model": "cubi:cross",
"variants": {
"age=0": {
"textures": {
+1 -1
View File
@@ -5,7 +5,7 @@
"textures": {
"cross": "bworld:rice_panicles_stage0"
},
"model": "engine:cross",
"model": "cubi:cross",
"variants": {
"age=0": {
"textures": {
+1 -1
View File
@@ -5,7 +5,7 @@
"textures": {
"cross": "bworld:strawberry_stage_0"
},
"model": "engine:cross",
"model": "cubi:cross",
"variants": {
"age=0": {
"textures": {
+1 -1
View File
@@ -6,7 +6,7 @@
"textures": {
"cross": "bworld:sugar_cane_block"
},
"model": "engine:cross",
"model": "cubi:cross",
"render_layer": "cutout",
"shape": [[1, 0, 1, 15, 16, 15]],
"mining": {
+1 -1
View File
@@ -5,7 +5,7 @@
"textures": {
"cross": "bworld:budding_tomatoes_stage0"
},
"model": "engine:cross",
"model": "cubi:cross",
"variants": {
"age=0": {
"textures": {
+1 -1
View File
@@ -13,7 +13,7 @@
"loot_table": "bworld:blocks/verdigris_wire",
"item": false,
"place_in": [
"bworld:air",
"cubi:air",
"bworld:verdigris_wire"
],
"states": [
+1 -1
View File
@@ -5,7 +5,7 @@
"textures": {
"crop": "bworld:wheat_stage_0"
},
"model": "engine:crop",
"model": "cubi:crop",
"variants": {
"age=0": {
"textures": {
+1 -1
View File
@@ -6,7 +6,7 @@
"icon": "bworld:slow",
"modifiers": [
{
"attribute": "bworld:movement_speed",
"attribute": "cubi:movement_speed",
"amount": -0.15,
"operation": "add_multiplied_total"
}
+1 -1
View File
@@ -6,7 +6,7 @@
"icon": "bworld:speed",
"modifiers": [
{
"attribute": "bworld:movement_speed",
"attribute": "cubi:movement_speed",
"amount": 0.2,
"operation": "add_multiplied_total"
}
+1 -1
View File
@@ -7,7 +7,7 @@
"worn": { "model": "bworld:giant_chestplate", "texture": "bworld:giant_chestplate_worn" },
"components": {
"bworld:curio_modifiers": [
{ "attribute": "bworld:max_health", "amount": 20, "operation": "add_value" }
{ "attribute": "cubi:max_health", "amount": 20, "operation": "add_value" }
],
"bworld:curio_unhurt_effect": { "effect": "bworld:regeneration", "amplifier": 2, "after": 200 }
}
+8 -8
View File
@@ -678,7 +678,7 @@ function register_farming(ctx: ServerContext) {
const die = (block: BlockRef, params: CropParams) => {
const { x, y, z } = block;
if (params.upper && ctx.world.get_block(x, y + 1, z) === params.upper.block) {
ctx.world.set_block(x, y + 1, z, "bworld:air");
ctx.world.set_block(x, y + 1, z, "cubi:air");
}
ctx.world.set_block(x, y, z, DEAD_BUSH);
};
@@ -711,11 +711,11 @@ function register_farming(ctx: ServerContext) {
const above = ctx.world.get_block(block.x, block.y + 1, block.z);
if (!upper || stage < params.stages) {
ctx.world.set_state(block.x, block.y, block.z, "age", stage);
if (upper && above === upper.block) ctx.world.set_block(block.x, block.y + 1, block.z, "bworld:air");
if (upper && above === upper.block) ctx.world.set_block(block.x, block.y + 1, block.z, "cubi:air");
return;
}
// the top needs room, like farmer's delight's rice
if (above !== upper.block && above !== "bworld:air") {
if (above !== upper.block && above !== "cubi:air") {
ctx.world.set_state(block.x, block.y, block.z, "age", params.stages - 1);
return;
}
@@ -770,7 +770,7 @@ function register_farming(ctx: ServerContext) {
const leaves = params.leaves;
// after it's gone, it's still there while on_break runs
ctx.system.run_timeout(() => {
if (ctx.world.get_block(x, y, z) === "bworld:air") ctx.world.set_block(x, y, z, leaves);
if (ctx.world.get_block(x, y, z) === "cubi:air") ctx.world.set_block(x, y, z, leaves);
}, 0);
}
},
@@ -837,7 +837,7 @@ function register_buckets(ctx: ServerContext) {
if (ctx.world.get_block(x, y, z) === block.id) {
// only a fluid's source fills it, not where it's flowing
if ((ctx.world.get_state(x, y, z, "level") ?? 0) !== 0) return false;
ctx.world.set_block(x, y, z, "bworld:air");
ctx.world.set_block(x, y, z, "cubi:air");
} else {
// the fluid in a waterlogged block, like a fence in water, which stays
ctx.world.set_state(x, y, z, "waterlogged", 0);
@@ -1050,7 +1050,7 @@ interface GrowableBlockParams {
function register_growable_block(ctx: ServerContext) {
ctx.components.register_block<GrowableBlockParams>("bworld:growable_block", {
on_new_day(block, params, day) {
if (ctx.world.get_block(block.x, block.y + 1, block.z) !== "bworld:air") {
if (ctx.world.get_block(block.x, block.y + 1, block.z) !== "cubi:air") {
return;
}
const should_grow_today = day % params.days === 0;
@@ -1083,7 +1083,7 @@ function register_door(ctx: ServerContext) {
const is_door = (id: string) => DOOR in ctx.blocks.components(id);
ctx.events.before.block_place.subscribe((event) => {
const { id, x, y, z } = event.block;
if (is_door(id) && ctx.world.get_block(x, y + 1, z) !== "bworld:air") event.cancel = true;
if (is_door(id) && ctx.world.get_block(x, y + 1, z) !== "cubi:air") event.cancel = true;
});
ctx.events.after.block_place.subscribe(({ block: { id, x, y, z } }) => {
if (!is_door(id)) return;
@@ -1110,7 +1110,7 @@ function register_door(ctx: ServerContext) {
const halves = [`${x},${y},${z}`, `${x},${other},${z}`];
for (const half of halves) breaking.add(half);
try {
ctx.world.set_block(x, other, z, "bworld:air");
ctx.world.set_block(x, other, z, "cubi:air");
} finally {
for (const half of halves) breaking.delete(half);
}
+2 -2
View File
@@ -231,7 +231,7 @@ export function register_trees(gen: WorldgenContext) {
return;
}
const current = chunk.get_block(x, y, z);
if (current === "bworld:air" || (block === "log" && LEAVES.has(current!))) chunk.set_block(x, y, z, id);
if (current === "cubi:air" || (block === "log" && LEAVES.has(current!))) chunk.set_block(x, y, z, id);
};
for (const site of tree_sites(chunk)) {
@@ -242,7 +242,7 @@ export function register_trees(gen: WorldgenContext) {
const ground_y = chunk.height_at(site.x, site.z);
const ground = chunk.get_block(site.x, ground_y, site.z);
const above = chunk.get_block(site.x, ground_y + 1, site.z);
if (!SOIL.has(ground!) || above !== "bworld:air") continue;
if (!SOIL.has(ground!) || above !== "cubi:air") continue;
const kind = here.kinds[Math.floor(site.rng.next() * here.kinds.length)] as TreeKind;
// big oaks grow oak, every other kind its own wood, unless the biome says
+1 -1
View File
@@ -7,7 +7,7 @@ import type { Face, Id } from "bworld/shared";
import { FACES, type FacingParam, front_of, named_sides, OPPOSITE, type SideName, step } from "./sides.ts";
export const WIRE = "bworld:verdigris_wire";
export const AIR = "bworld:air";
export const AIR = "cubi:air";
export const MAX_POWER = 15;
// a bworld:verdigris_source's params, the block json's: something that gives power out of some of its sides
+1 -1
View File
@@ -35,7 +35,7 @@ function cactus(chunk: FeatureChunk) {
continue;
}
for (let y = ground + 1; y <= ground + height; y++) {
if (chunk.get_block(x, y, z) !== "bworld:air") {
if (chunk.get_block(x, y, z) !== "cubi:air") {
break;
}
chunk.set_block(x, y, z, "bworld:cactus");
+1 -1
View File
@@ -294,7 +294,7 @@ function register_press(ctx: ServerContext, compacting: ProcessingRecipe[]) {
ctx.world.entities_in(
{ x: block.x + inset, y: block.y - 1 + inset, z: block.z + inset },
{ x: block.x + 1 - inset, y: block.y - inset, z: block.z + 1 - inset },
"bworld:item",
"cubi:item",
).filter((item) => item.on_ground && pressing_for(item.get_item()!.id));
const press = (item: EntityRef) => {
+1 -1
View File
@@ -99,7 +99,7 @@ export class ItemList {
// in the space from left to the window's right edge. returns the hovered item or fluid
render(g: Graphics, left: number, open: Open): Entry | undefined {
this.#entries ??= [
...this.ctx.items.ids().filter((id) => id !== "bworld:air").map((id) => ({ kind: "item" as const, id })),
...this.ctx.items.ids().filter((id) => id !== "cubi:air").map((id) => ({ kind: "item" as const, id })),
...this.ctx.fluids.ids().map((id) => ({ kind: "fluid" as const, id })),
];
left += GAP;
+1 -1
View File
@@ -22,7 +22,7 @@ export interface AttributeType {
}
function attribute(id: string, value: number, min: number, max: number): AttributeType {
return { id: `bworld:${id}`, default: value, min, max };
return { id: `cubi:${id}`, default: value, min, max };
}
export const ATTRIBUTES = {
+1 -1
View File
@@ -130,7 +130,7 @@ export interface SavedEntity {
}
export abstract class Entity {
// the entity type, like "bworld:item". see entity_types.ts
// the entity type, like "cubi:item". see entity_types.ts
abstract readonly type: string;
readonly level: EntityLevel;
// a UUID, which clients know it by too
+2 -2
View File
@@ -7,7 +7,7 @@ import { TICK_DELTA } from "$/common/constants.ts";
import { physics } from "$/common/physics.ts";
import { type Attacker, type DamageSource, Entity, finite, type SavedEntity } from "./entity.ts";
export const ITEM_ENTITY_TYPE = "bworld:item";
export const ITEM_ENTITY_TYPE = "cubi:item";
// minecraft's item physics, its per tick numbers turned into per second ones where they're speeds
export const ITEM_SIZE = 0.25;
@@ -61,7 +61,7 @@ export class ItemEntity extends Entity {
constructor(
level: Entity["level"],
item = new ItemStack("bworld:air", 0),
item = new ItemStack("cubi:air", 0),
x = 0,
y = 0,
z = 0,
+2 -2
View File
@@ -1623,7 +1623,7 @@ export class GameServer {
// the engine's own commands, registered like mods' so they're in /help and suggested the same way
#register_commands() {
const register = (node: CommandNode<ServerCommandSource>) => this.mods.register_command("engine", node);
const register = (node: CommandNode<ServerCommandSource>) => this.mods.register_command("cubi", node);
// TODO: only let operators do this
// with data, any json, like { "damage": 10 } on a tool, or a fluid container full of a fluid with its data
@@ -2563,7 +2563,7 @@ function death_message(name: string, source: DamageSource) {
// the states a block is placed with: its defaults, and a "facing" state turned towards whoever placed it, like
// minecraft's getStateForPlacement with getHorizontalDirection().getOpposite(). facing is 0 north, 1 east, 2 south,
// 3 west, and variants turn the model with it (its north side is the front, like engine:cube's). they look along
// 3 west, and variants turn the model with it (its north side is the front, like cubi:cube's). they look along
// (-sin yaw, -cos yaw), so the way back to them is (sin yaw, cos yaw)
// where a player is now, for everyone else
function player_move(player: ServerPlayer): ServerMessage {
+3 -3
View File
@@ -176,7 +176,7 @@ export class ModRuntime {
effect_components = new Map<string, { mod: string; component: EffectComponent }>();
// every command, the engine's and mods', see common/commands.ts
commands = new CommandDispatcher<ServerCommandSource>();
// who registered each command name: "engine" or a mod's id
// who registered each command name: "cubi" or a mod's id
command_owners = new Map<string, string>();
before: Before = {
@@ -478,14 +478,14 @@ export class ModRuntime {
const existing = this.command_owners.get(node.name);
if (existing) {
throw new Error(
existing === "engine"
existing === "cubi"
? `/${node.name} belongs to the engine`
: `/${node.name} is also registered by ${existing}`,
);
}
this.commands.register(node);
this.command_owners.set(node.name, owner);
if (owner !== "engine") {
if (owner !== "cubi") {
const alias = new CommandNode<ServerCommandSource>(`${owner}:${node.name}`);
alias.children.push(...node.children);
alias.command = node.command;
+1 -1
View File
@@ -51,7 +51,7 @@ const MAX_KNOCKBACK_TICKS = 20;
// until they land, so it works even when their client isn't running, like in a background tab. they're kept apart
// from the entity manager's entities, clients hear about players through their own messages
export class ServerPlayer extends LivingEntity {
readonly type = "bworld:player";
readonly type = "cubi:player";
readonly conn: number;
readonly name: string;
+2 -2
View File
@@ -333,10 +333,10 @@ async function write_world(dir: string, save: { level: string; chunks: SavedChun
Deno.renameSync(`${level}.tmp`, level);
}
// the engine's textures, listed by the build next to the client's assets. engine:missing is drawn by code
// the engine's textures, listed by the build next to the client's assets. cubi:missing is drawn by code
export function engine_texture_ids(build_dir: string): string[] {
const names: string[] = JSON.parse(Deno.readTextFileSync(join(build_dir, ENGINE_TEXTURES_INDEX)));
return ["engine:missing", ...names.map((name) => `engine:${name}`)];
return ["cubi:missing", ...names.map((name) => `cubi:${name}`)];
}
// the client and the engine's assets. pages on other origins load the engine's textures from here too
+1 -1
View File
@@ -25,7 +25,7 @@ export class ModsError extends Error {
}
}
// engine_textures are the engine: texture ids, for checking the textures mods use. config_dir has the server's
// engine_textures are the cubi: texture ids, for checking the textures mods use. config_dir has the server's
// <mod id>.json files that change mods' config. a mod with problems stops the whole server from starting, the game
// never runs with some mods missing
export async function load_bmods(
+6 -6
View File
@@ -75,7 +75,7 @@ Deno.test("a chest keeps items, shows them to everyone, and drops them when brok
assertEquals(opened.open_data, { rows: 3 });
assertEquals(opened.slots.length, 27 + 36);
// nothing got placed on top
assertEquals(t.game.world.get_block_id(1, 101, 0), "bworld:air");
assertEquals(t.game.world.get_block_id(1, 101, 0), "cubi:air");
move_to_menu(t, opened, coal, 4);
assertEquals(menu_items(t.take(1))[4], { id: "bworld:coal", count: 10 });
@@ -213,7 +213,7 @@ Deno.test("bone meal grows wheat until it's fully grown", async () => {
for (let i = 0; i < 7; i++) t.send(1, { type: "use_block", x: 1, y: 100, z: 0, face: "top" });
assertEquals(age(), 7);
assertEquals(container_items(t.take(1), "inventory")[slot]?.count, 1);
assertEquals(t.game.world.get_block_id(1, 101, 0), "bworld:air");
assertEquals(t.game.world.get_block_id(1, 101, 0), "cubi:air");
});
Deno.test("the last bone meal is used up", async () => {
@@ -247,7 +247,7 @@ Deno.test("items are called by their name, or by one made from their id", async
assertEquals(display_name("bworld:iron_ingot"), "Iron Ingot");
assertEquals(display_name("bworld:stone_pickaxe"), "Stone Pickaxe");
assertEquals(display_name("bworld:hoed_dirt"), "Hoed Dirt");
EverythingRegistry.register<ItemRegistry>("items", "test:thing", { texture_id: "engine:missing", name: "A Thing" });
EverythingRegistry.register<ItemRegistry>("items", "test:thing", { texture_id: "cubi:missing", name: "A Thing" });
assertEquals(display_name("test:thing"), "A Thing");
});
@@ -410,7 +410,7 @@ Deno.test("a bucket picks up a water source but not flowing water, and a water b
t.send(1, { type: "use_block", x: 1, y: 100, z: 0, face: "top" });
assertEquals(held(), "bworld:water_bucket");
assertEquals(t.game.world.get_block_id(1, 100, 0), "bworld:air");
assertEquals(t.game.world.get_block_id(1, 100, 0), "cubi:air");
t.send(1, { type: "use_block", x: -2, y: 99, z: 0, face: "top" });
assertEquals(held(), "bworld:bucket");
@@ -432,7 +432,7 @@ Deno.test("only an empty bucket picks up water, and from a stack the water bucke
player.inventory.set_item(0, undefined);
t.game.give(player, "bworld:bucket", 3);
t.send(1, { type: "use_block", x: 1, y: 100, z: 0, face: "top" });
assertEquals(t.game.world.get_block_id(1, 100, 0), "bworld:air");
assertEquals(t.game.world.get_block_id(1, 100, 0), "cubi:air");
assertEquals(slots(), [["bworld:bucket", 2], ["bworld:water_bucket", 1]]);
});
@@ -443,7 +443,7 @@ Deno.test("a bucket picks up a lava source too, and a lava bucket puts one back"
t.send(1, { type: "use_block", x: 1, y: 100, z: 0, face: "top" });
assertEquals(held(), "bworld:lava_bucket");
assertEquals(t.game.world.get_block_id(1, 100, 0), "bworld:air");
assertEquals(t.game.world.get_block_id(1, 100, 0), "cubi:air");
t.send(1, { type: "use_block", x: -2, y: 99, z: 0, face: "top" });
assertEquals(held(), "bworld:bucket");
+5 -5
View File
@@ -14,7 +14,7 @@ import {
import { block_from_json, validate_block } from "$/common/mod_data.ts";
import { set_state_value } from "$/common/utils.ts";
const cube = BUILTIN_MODELS["engine:cube"];
const cube = BUILTIN_MODELS["cubi:cube"];
Deno.test("cubes resolve the old texture shapes", () => {
assertEquals(resolve_texture("#top", "a:all", cube), "a:all");
@@ -31,7 +31,7 @@ Deno.test("cubes resolve the old texture shapes", () => {
"a:side",
"a:front",
]);
assertEquals(resolve_texture("#nothing", { crop: "a:crop" }), "engine:missing");
assertEquals(resolve_texture("#nothing", { crop: "a:crop" }), "cubi:missing");
});
Deno.test("a cube bakes into six full faces that cull against their neighbors", () => {
@@ -44,12 +44,12 @@ Deno.test("a cube bakes into six full faces that cull against their neighbors",
});
Deno.test("crop and cross models are planes inside the block, seen from both sides", () => {
const crop = bake_model(BUILTIN_MODELS["engine:crop"], { crop: "a:wheat" });
const crop = bake_model(BUILTIN_MODELS["cubi:crop"], { crop: "a:wheat" });
assertEquals(crop.length, 8);
assert(crop.every((q) => !q.flush && q.cull === -1 && !q.shade && q.texture === "a:wheat"));
assertEquals(crop[0].positions.filter((_, i) => i % 3 === 0), [0.25, 0.25, 0.25, 0.25]);
const cross = bake_model(BUILTIN_MODELS["engine:cross"], { cross: "a:flower" });
const cross = bake_model(BUILTIN_MODELS["cubi:cross"], { cross: "a:flower" });
assertEquals(cross.length, 4);
// rescaled so the diagonal planes stay as wide as the block, like minecraft's (0.8 to 15.2 pixels)
for (const quad of cross) {
@@ -99,7 +99,7 @@ Deno.test("an x turn tips a model's top to the north, before its y turn", () =>
Deno.test("variants pick textures by state", () => {
const { block } = block_from_json(JSON.parse(Deno.readTextFileSync("mods/bworld/blocks/wheat.json")).block);
assertEquals(block_variant(block, { age: 5 }).textures, { crop: "bworld:wheat_stage_5" });
assertEquals(block_variant(block, { age: 5 }).model, "engine:crop");
assertEquals(block_variant(block, { age: 5 }).model, "cubi:crop");
assertEquals(block_variant(block).textures, { crop: "bworld:wheat_stage_0" });
// states live above the numeric id
assertEquals(set_state_value(7, block, "age", 3), (3 << 16) | 7);
+5 -5
View File
@@ -25,7 +25,7 @@ const slab: ModelJson = {
const SLAB: Shape = [[0, 0, 0, 1, 0.5, 1]];
Deno.test("a model's shape is the boxes of its elements", () => {
assertEquals(model_shape(BUILTIN_MODELS["engine:cube"]), FULL_SHAPE);
assertEquals(model_shape(BUILTIN_MODELS["cubi:cube"]), FULL_SHAPE);
assertEquals(model_shape(slab), SLAB);
const stairs: ModelJson = {
id: "test:stairs",
@@ -40,8 +40,8 @@ Deno.test("a model's shape is the boxes of its elements", () => {
});
Deno.test("models made of planes get one box around them, so plants can still be pointed at", () => {
assertEquals(model_shape(BUILTIN_MODELS["engine:crop"]), [[0, 0, 0, 1, 1, 1]]);
const [cross] = model_shape(BUILTIN_MODELS["engine:cross"]);
assertEquals(model_shape(BUILTIN_MODELS["cubi:crop"]), [[0, 0, 0, 1, 1, 1]]);
const [cross] = model_shape(BUILTIN_MODELS["cubi:cross"]);
assertEquals(cross[1], 0);
assertEquals(cross[4], 1);
assert(cross[0] < 0.1 && cross[3] > 0.9);
@@ -60,7 +60,7 @@ Deno.test("a block's shape follows its model, or its own shape in pixels, turned
const { block: plant } = block_from_json({
id: "test:plant",
textures: { cross: "test:flower" },
model: "engine:cross",
model: "cubi:cross",
collision: false,
});
assertEquals(collision_shape_at(plant, 0), EMPTY_SHAPE);
@@ -188,7 +188,7 @@ Deno.test("a solid block is drawn in the solid layer and is a whole block to bum
assert(!is_solid(block({ render_layer: "translucent" })), "like glass");
assert(!is_solid(block({ collision: false })));
assert(!is_solid(block({ shape: [[0, 0, 0, 16, 8, 16]] })), "like a slab");
assert(!is_solid(block({ states, variants: { "age=1": { model: "engine:cross" } } })), "not in one of its states");
assert(!is_solid(block({ states, variants: { "age=1": { model: "cubi:cross" } } })), "not in one of its states");
assert(!is_solid(block({ states, variants: { "age=1": { collision_shape: [[0, 0, 0, 16, 8, 16]] } } })));
assert(
is_solid(block({ shape: [[0, 0, 0, 16, 8, 16]], collision_shape: [[0, 0, 0, 16, 16, 16]] })),
+4 -4
View File
@@ -18,7 +18,7 @@ import { decode_level_chunk, type LevelChunk } from "$/common/chunk_streaming.ts
import { decode_chunk, encode_chunk } from "$/server/game/saves.ts";
import { list_chunks, read_chunk, write_chunks } from "$/server/regions.ts";
const ENGINE_TEXTURES = ["engine:missing", ...Array.from({ length: 9 }, (_, i) => `engine:break_${i}`)];
const ENGINE_TEXTURES = ["cubi:missing", ...Array.from({ length: 9 }, (_, i) => `cubi:break_${i}`)];
// mods/bworld and one made from the template, packed into a folder of .bmod files
async function packed_mods() {
@@ -214,14 +214,14 @@ const sizes = (entries: [string, number, number][]) =>
new Map(entries.map(([id, width, height]) => [id, { width, height }]));
Deno.test("the atlas lays out same sized textures by id, with the missing texture among them", () => {
const layout = atlas_layout(sizes([["b:two", 16, 16], ["a:one", 16, 16], ["engine:break_0", 16, 16]]));
const layout = atlas_layout(sizes([["b:two", 16, 16], ["a:one", 16, 16], ["cubi:break_0", 16, 16]]));
assertEquals(layout.size, 64);
// each inside a pixel of border
assertEquals(layout.regions, {
"a:one": { x: 1, y: 1, width: 16, height: 16 },
"b:two": { x: 19, y: 1, width: 16, height: 16 },
"engine:break_0": { x: 37, y: 1, width: 16, height: 16 },
"engine:missing": { x: 1, y: 19, width: 16, height: 16 },
"cubi:break_0": { x: 37, y: 1, width: 16, height: 16 },
"cubi:missing": { x: 1, y: 19, width: 16, height: 16 },
});
const many = atlas_layout(sizes(Array.from({ length: 100 }, (_, i) => [`m:t${i}`, 16, 16])));
assertEquals(many.size, 256);
+1 -1
View File
@@ -137,7 +137,7 @@ Deno.test("/give suggests item ids as they're typed", async () => {
assertEquals(ids("/give ").length, 100);
assert(ids("/give bworld:sto").includes("bworld:stone"));
assert(ids("/give bworld:cab").includes("bworld:cabbage"));
assert(!ids("/give bworld:a").includes("bworld:air"));
assert(!ids("/give bworld:a").includes("cubi:air"));
assertEquals(suggest("/give bworld:tom").suggestions.map((s: { text: string }) => s.text), [
"bworld:tomato",
"bworld:tomato_sauce",
+1 -1
View File
@@ -35,7 +35,7 @@ Deno.test("a crab pot placed in water holds it, and leaves it behind when broken
for (let x = -2; x <= 2; x++) {
for (let z = -2; z <= 2; z++) {
t.game.set_block(x, 99, z, "bworld:stone");
t.game.set_block(x, 100, z, "bworld:air");
t.game.set_block(x, 100, z, "cubi:air");
}
}
t.game.set_block(0, 100, 0, "bworld:water");
+6 -6
View File
@@ -19,7 +19,7 @@ async function setup() {
for (let x = -3; x <= 3; x++) {
for (let z = -3; z <= 3; z++) {
t.game.set_block(x, 99, z, "bworld:stone");
for (let y = 100; y < 103; y++) t.game.set_block(x, y, z, "bworld:air");
for (let y = 100; y < 103; y++) t.game.set_block(x, y, z, "cubi:air");
}
}
t.send(1, { type: "move", x: 0.5, y: 100, z: 3.5, yaw: 0, pitch: 0 });
@@ -57,7 +57,7 @@ Deno.test("a door isn't placed without room for its upper half", async () => {
const { t, held } = await setup();
t.game.set_block(0, 101, 0, "bworld:stone");
t.send(1, { type: "use_block", x: 0, y: 99, z: 0, face: "top", hit: [0.5, 1, 0.5] });
assertEquals(t.game.world.get_block_id(0, 100, 0), "bworld:air");
assertEquals(t.game.world.get_block_id(0, 100, 0), "cubi:air");
assertEquals(held(), 64);
});
@@ -74,7 +74,7 @@ Deno.test("right clicking either half opens and closes both, and the door turns
// swung against the west side, its hinge on alice's left
assertEquals(shape(), [[0, 0, 0, 3 / 16, 1, 1]]);
// nothing placed in the doorway
assertEquals(t.game.world.get_block_id(0, 102, 0), "bworld:air");
assertEquals(t.game.world.get_block_id(0, 102, 0), "cubi:air");
t.send(1, { type: "use_block", x: 0, y: 100, z: 0, face: "west", hit: [0, 0.5, 0.5] });
assertEquals([states(0, 100, 0).open, states(0, 101, 0).open], [0, 0]);
@@ -84,13 +84,13 @@ Deno.test("breaking either half breaks the whole door, which drops one door", as
const { t, dropped } = await setup();
t.send(1, { type: "use_block", x: 0, y: 99, z: 0, face: "top", hit: [0.5, 1, 0.5] });
t.send(1, { type: "break_block", x: 0, y: 101, z: 0 });
assertEquals(t.game.world.get_block_id(0, 100, 0), "bworld:air");
assertEquals(t.game.world.get_block_id(0, 101, 0), "bworld:air");
assertEquals(t.game.world.get_block_id(0, 100, 0), "cubi:air");
assertEquals(t.game.world.get_block_id(0, 101, 0), "cubi:air");
assertEquals(dropped(), ["bworld:oak_door 1"]);
t.send(1, { type: "use_block", x: 1, y: 99, z: 0, face: "top", hit: [0.5, 1, 0.5] });
t.send(1, { type: "break_block", x: 1, y: 100, z: 0 });
assertEquals(t.game.world.get_block_id(1, 101, 0), "bworld:air");
assertEquals(t.game.world.get_block_id(1, 101, 0), "cubi:air");
assertEquals(dropped(), ["bworld:oak_door 1", "bworld:oak_door 1"]);
});
+1 -1
View File
@@ -17,7 +17,7 @@ async function mesh_light() {
type: "init",
blocks_registry: JSON.parse(JSON.stringify(blocks)),
models: {},
textures_info: { "engine:missing": { x: 0, y: 0, width: 16, height: 16 } },
textures_info: { "cubi:missing": { x: 0, y: 0, width: 16, height: 16 } },
image: { width: 1024, height: 1024 },
visuals: [],
});
+10 -10
View File
@@ -53,7 +53,7 @@ Deno.test("hoe, fill the can, plant, water, and the crop grows the next morning"
// seeds only go on farmland
t.hold("bworld:wheat_seeds");
t.use(0, 100, 1);
assertEquals(t.game.world.get_block_id(0, 101, 1), "bworld:air");
assertEquals(t.game.world.get_block_id(0, 101, 1), "cubi:air");
t.use(1, 100, 0);
assertEquals(t.game.world.get_block_id(1, 101, 0), "bworld:wheat");
@@ -107,7 +107,7 @@ Deno.test("digging up the farmland pops the crop off with its drops", async () =
t.game.set_block(1, 100, 0, "bworld:hoed_dirt");
t.game.set_block(1, 101, 0, "bworld:wheat");
t.send(1, { type: "break_block", x: 1, y: 100, z: 0 });
assertEquals(t.game.world.get_block_id(1, 101, 0), "bworld:air");
assertEquals(t.game.world.get_block_id(1, 101, 0), "cubi:air");
const ids = t.game.item_entities().map((e) => e.item.type_id).sort();
assertEquals(ids, ["bworld:dirt", "bworld:wheat_seeds"]);
});
@@ -182,7 +182,7 @@ Deno.test("potatoes and carrots are planted on farmland, and eaten anywhere else
assertEquals(t.game.players()[0].vitals.food, 10, "planted, not eaten");
// on stone it can't be planted, so it's eaten
t.use(0, 99, 1);
assertEquals(t.game.world.get_block_id(0, 100, 1), "bworld:air");
assertEquals(t.game.world.get_block_id(0, 100, 1), "cubi:air");
assertEquals(t.game.players()[0].vitals.food, 11);
});
@@ -220,14 +220,14 @@ Deno.test("rice is planted in water, grows panicles on top without watering, and
// not on land
t.hold("bworld:rice");
t.use(2, 100, 0);
assertEquals(t.game.world.get_block_id(2, 101, 0), "bworld:air");
assertEquals(t.game.world.get_block_id(2, 101, 0), "cubi:air");
// into the water, standing on the dirt under it
t.use(1, 100, 0);
assertEquals(t.game.world.get_block_id(1, 100, 0), "bworld:rice");
for (let day = 0; day < 3; day++) t.next_morning();
assertEquals(t.state(1, 100, 0, "age"), 3);
assertEquals(t.game.world.get_block_id(1, 101, 0), "bworld:air");
assertEquals(t.game.world.get_block_id(1, 101, 0), "cubi:air");
for (let day = 0; day < 3; day++) t.next_morning();
assertEquals(t.game.world.get_block_id(1, 101, 0), "bworld:rice_panicles");
assertEquals(t.state(1, 101, 0, "age"), 3, "fully grown after 6 days");
@@ -241,7 +241,7 @@ Deno.test("rice is planted in water, grows panicles on top without watering, and
const dropped = t.game.item_entities().map((e) => e.item.type_id).sort();
assertEquals(dropped, ["bworld:rice", "bworld:rice_panicle"]);
assertEquals(t.game.world.get_block_id(1, 100, 0), "bworld:water");
assertEquals(t.game.world.get_block_id(1, 101, 0), "bworld:air");
assertEquals(t.game.world.get_block_id(1, 101, 0), "cubi:air");
});
Deno.test("a crop dies into a dead bush the first morning out of its seasons", async () => {
@@ -272,7 +272,7 @@ Deno.test("a two block crop dies whole, its top going without dropping anything"
t.game.tick();
t.game.tick();
assertEquals(t.game.world.get_block_id(1, 100, 0), "bworld:dead_bush");
assertEquals(t.game.world.get_block_id(1, 101, 0), "bworld:air");
assertEquals(t.game.world.get_block_id(1, 101, 0), "cubi:air");
assertEquals(t.game.item_entities(), []);
});
@@ -329,7 +329,7 @@ Deno.test("blocks without data run on_new_day near players, once a morning", asy
t.game.world.remove_tile(0, 101, 0);
t.next_morning();
assertEquals(t.game.world.get_block_id(0, 102, 0), "bworld:cactus", "grew a block");
assertEquals(t.game.world.get_block_id(0, 103, 0), "bworld:air", "the new block waits for tomorrow");
assertEquals(t.game.world.get_block_id(0, 103, 0), "cubi:air", "the new block waits for tomorrow");
// far from every player, in a chunk that isn't kept, nothing runs
const far = 16 * 40;
@@ -337,7 +337,7 @@ Deno.test("blocks without data run on_new_day near players, once a morning", asy
t.game.set_block(far, 101, 0, "bworld:cactus");
t.game.world.remove_tile(far, 101, 0);
t.next_morning();
assertEquals(t.game.world.get_block_id(far, 102, 0), "bworld:air");
assertEquals(t.game.world.get_block_id(far, 102, 0), "cubi:air");
});
Deno.test("a cactus grows a block a day until it's 4 tall", async () => {
@@ -346,5 +346,5 @@ Deno.test("a cactus grows a block a day until it's 4 tall", async () => {
t.game.set_block(0, 101, 0, "bworld:cactus");
for (let day = 0; day < 6; day++) t.next_morning();
const column = [101, 102, 103, 104, 105].map((y) => t.game.world.get_block_id(0, y, 0));
assertEquals(column, ["bworld:cactus", "bworld:cactus", "bworld:cactus", "bworld:cactus", "bworld:air"]);
assertEquals(column, ["bworld:cactus", "bworld:cactus", "bworld:cactus", "bworld:cactus", "cubi:air"]);
});
+2 -2
View File
@@ -18,7 +18,7 @@ const Y = 100;
async function setup() {
const { game } = await test_game("mods");
for (let x = -1; x <= 5; x++) {
for (let z = -1; z <= 1; z++) game.set_block(x, Y, z, "bworld:air");
for (let z = -1; z <= 1; z++) game.set_block(x, Y, z, "cubi:air");
}
const sides = (x: number, z: number) => {
const info = game.world.get_block_info(x, Y, z)!;
@@ -38,7 +38,7 @@ Deno.test("fences join the fences beside them, and let go when one is broken", a
assertEquals(sides(1, 0), ["east", "west"]);
assertEquals(sides(2, 0), ["west"]);
game.set_block(1, Y, 0, "bworld:air");
game.set_block(1, Y, 0, "cubi:air");
assertEquals(sides(0, 0), []);
assertEquals(sides(2, 0), []);
});
+384 -384
View File
File diff suppressed because it is too large Load Diff
+5 -5
View File
@@ -31,15 +31,15 @@ async function setup() {
format_version: 1,
item: {
id: JAR,
texture: "engine:missing",
texture: "cubi:missing",
max_stack: 16,
fluid_container: { capacity: 250, full_max_stack: 4 },
layers: [{ texture: "engine:break_0", tint: "fluid" }, { texture: "engine:break_1", tint: "#ff0000" }],
layers: [{ texture: "cubi:break_0", tint: "fluid" }, { texture: "cubi:break_1", tint: "#ff0000" }],
},
});
write("items/flask.json", {
format_version: 1,
item: { id: FLASK, texture: "engine:missing", base_sell_value: 2, fluid_container: { capacity: 1000 } },
item: { id: FLASK, texture: "cubi:missing", base_sell_value: 2, fluid_container: { capacity: 1000 } },
});
const t = await test_game(dir);
Deno.removeSync(dir, { recursive: true });
@@ -69,9 +69,9 @@ Deno.test("a layer tinted fluid is drawn in the fluid's color while there's one,
stack.data = data;
return item_layers(stack);
};
const red = { texture: "engine:break_1", color: [1, 0, 0] };
const red = { texture: "cubi:break_1", color: [1, 0, 0] };
assertEquals(jar(), [red]);
assertEquals(jar(FULL), [{ texture: "engine:break_0", color: [0xa0 / 255, 0x52 / 255, 0x2d / 255] }, red]);
assertEquals(jar(FULL), [{ texture: "cubi:break_0", color: [0xa0 / 255, 0x52 / 255, 0x2d / 255] }, red]);
});
Deno.test("a full fluid container sells for its own value and its fluid's, rounded up", async () => {
+3 -3
View File
@@ -107,7 +107,7 @@ Deno.test("taking the source away drains what flowed from it", async () => {
ticks(game, 60);
assertEquals(level(game, 5, Y, 0), 5);
game.set_block(0, Y, 0, "bworld:air");
game.set_block(0, Y, 0, "cubi:air");
ticks(game, 200);
for (let x = -8; x <= 8; x++) {
for (let z = -8; z <= 8; z++) assertEquals(level(game, x, Y, z), undefined, `at ${x}, ${z}`);
@@ -130,8 +130,8 @@ Deno.test("two sources beside a spot on solid ground make it a source, like infi
assertEquals(level(game, 0, Y, 0), 0);
// and stays one with the others gone
game.set_block(-1, Y, 0, "bworld:air");
game.set_block(1, Y, 0, "bworld:air");
game.set_block(-1, Y, 0, "cubi:air");
game.set_block(1, Y, 0, "cubi:air");
ticks(game, 20);
assertEquals(level(game, 0, Y, 0), 0);
});
+1 -1
View File
@@ -54,7 +54,7 @@ async function setup() {
write("fluids/honey.json", { format_version: 1, fluid: { id: HONEY.id, color: "#e0a030" } });
write("items/jar.json", {
format_version: 1,
item: { id: JAR, texture: "engine:missing", fluid_container: { capacity: 250 } },
item: { id: JAR, texture: "cubi:missing", fluid_container: { capacity: 250 } },
});
write("blocks/tank.json", {
format_version: 1,
+1 -1
View File
@@ -33,7 +33,7 @@ function fluid_mod(dir: string, fluids: Record<string, unknown>, shared_script?:
write("scripts/shared.ts", shared_script);
write("items/maple.json", {
format_version: 1,
item: { id: "testfluids:maple", texture: "engine:missing", name: "Sugar Maple" },
item: { id: "testfluids:maple", texture: "cubi:missing", name: "Sugar Maple" },
});
}
}
+2 -2
View File
@@ -68,7 +68,7 @@ Deno.test("check-mods catches fluids that can't work", () => {
assertEquals(problems({ textures: { top: "a:b" } }), [
"textures must be a texture id or { still, flowing } for a fluid",
]);
assertEquals(problems({ model: "engine:cross" }), ["model isn't for fluids, the engine draws them"]);
assertEquals(problems({ model: "cubi:cross" }), ["model isn't for fluids, the engine draws them"]);
assertEquals(problems({ states: [{ name: "level", bits: 2, default: 0 }] }), [
`states can't have "level", a fluid gets that state of its own`,
]);
@@ -175,7 +175,7 @@ async function mesh(blocks: [number, number, number, string, number?][]) {
// with the registry's gaps, like the client sends it
blocks_registry: registry.map((block) => JSON.parse(JSON.stringify(block))),
models: {},
textures_info: { "engine:missing": { x: 0, y: 0, width: 16, height: 16 } },
textures_info: { "cubi:missing": { x: 0, y: 0, width: 16, height: 16 } },
image: { width: 1024, height: 1024 },
visuals: [],
});
+1 -1
View File
@@ -482,7 +482,7 @@ function gears_mod(): string {
Deno.writeTextFileSync(`${mod}/${path}`, JSON.stringify(json));
};
write("manifest.json", { format_version: 1, id: "gears", name: "Gears", version: "1.0.0" });
write("blocks/gear.json", { format_version: 1, block: { id: "gears:gear", textures: "engine:missing" } });
write("blocks/gear.json", { format_version: 1, block: { id: "gears:gear", textures: "cubi:missing" } });
write("tags/items/gears/teeth.json", { format_version: 1, tag: { values: ["gears:gear"] } });
return mod;
}
+1 -1
View File
@@ -125,7 +125,7 @@ Deno.test("items fall into water, float back up and bob at its surface", async (
for (let z = -3; z <= 3; z++) {
for (let y = 99; y <= 103; y++) {
const inside = x >= 4 && x <= 8 && z >= -2 && z <= 2 && y >= 100;
game.set_block(x, y, z, inside ? (y <= 102 ? "bworld:water" : "bworld:air") : "bworld:stone");
game.set_block(x, y, z, inside ? (y <= 102 ? "bworld:water" : "cubi:air") : "bworld:stone");
}
}
}
+2 -2
View File
@@ -40,11 +40,11 @@ async function setup(recipes: Record<string, unknown> = {}) {
format_version: 1,
item: {
id: CLOUDBERRY,
texture: "engine:missing",
texture: "cubi:missing",
components: { "bworld:juiceable": { juice: 100, color: "#e0a030" } },
},
});
write("items/pebble.json", { format_version: 1, item: { id: PEBBLE, texture: "engine:missing" } });
write("items/pebble.json", { format_version: 1, item: { id: PEBBLE, texture: "cubi:missing" } });
for (const [name, recipe] of Object.entries(recipes)) write(`recipes/${name}`, { format_version: 1, recipe });
try {
const t = await test_game(dir);
+1 -1
View File
@@ -292,7 +292,7 @@ Deno.test("a broken block drops from its loot table, with the tool it was broken
t.game.set_block(1, 100, 0, "testloot:ore");
t.send(1, { type: "break_block", x: 1, y: 100, z: 0 });
// broken by hand, it gives nothing
assertEquals(t.game.world.get_block_id(1, 100, 0), "bworld:air");
assertEquals(t.game.world.get_block_id(1, 100, 0), "cubi:air");
assertEquals(dropped(), []);
t.send(1, { type: "chat", text: "/give bworld:iron_pickaxe" });
+1 -1
View File
@@ -89,7 +89,7 @@ Deno.test("items lying in a box are found, changed and taken away", async () =>
game.tick();
assertEquals(iron.position, { x: 0.5, y: 100, z: 0.5 });
const found = ctx.world.entities_in({ x: 0, y: 99.5, z: 0 }, { x: 1, y: 101, z: 1 }, "bworld:item");
const found = ctx.world.entities_in({ x: 0, y: 99.5, z: 0 }, { x: 1, y: 101, z: 1 }, "cubi:item");
assertEquals(found.map((entity) => entity.get_item()), [{ id: "bworld:iron_ingot", count: 3 }]);
assertEquals(ctx.world.entities_in({ x: 0, y: 99.5, z: 0 }, { x: 1, y: 101, z: 1 }, "bworld:chicken"), []);
+4 -4
View File
@@ -86,8 +86,8 @@ Deno.test("/summon spawns a mod's entity where the player is", async () => {
// animals don't despawn
assertEquals(chicken.remove_when_far_away(1000), false);
send(1, { type: "chat", text: "/summon bworld:item" });
assertStringIncludes(take(1).find((m) => m.type === "chat").text, "There's no entity bworld:item");
send(1, { type: "chat", text: "/summon cubi:item" });
assertStringIncludes(take(1).find((m) => m.type === "chat").text, "There's no entity cubi:item");
});
Deno.test("solid blocks can't be placed where a mob or player is", async () => {
@@ -104,7 +104,7 @@ Deno.test("solid blocks can't be placed where a mob or player is", async () => {
chicken.set_position(2.1, 101, 1.5);
game.entities.add_entity(chicken);
send(1, { type: "use_block", x: 1, y: 100, z: 1, face: "top" });
assertEquals(game.world.get_block_id(1, 101, 1), "bworld:air");
assertEquals(game.world.get_block_id(1, 101, 1), "cubi:air");
chicken.set_position(2.5, 101, 1.5);
send(1, { type: "use_block", x: 1, y: 100, z: 1, face: "top" });
@@ -113,5 +113,5 @@ Deno.test("solid blocks can't be placed where a mob or player is", async () => {
// nor where a player is, the one placing it included
game.set_block(3, 100, 3, "bworld:stone");
send(1, { type: "use_block", x: 3, y: 100, z: 3, face: "top" });
assertEquals(game.world.get_block_id(3, 101, 3), "bworld:air");
assertEquals(game.world.get_block_id(3, 101, 3), "cubi:air");
});
+1 -1
View File
@@ -112,7 +112,7 @@ Deno.test("a mod made from the template loads and runs", async () => {
for (let i = 0; i < 3 * 20; i++) game.tick();
send(1, { type: "use_block", x: 1, y: y + 1, z: 1, face: "top" });
assert(take(1).some((m) => m.text === "You found the example block! It's been here for 3 seconds."));
assertEquals(game.world.get_block_id(1, y + 2, 1), "bworld:air");
assertEquals(game.world.get_block_id(1, y + 2, 1), "cubi:air");
// the shaped recipe: 4 example items in a square
send(1, { type: "chat", text: "/give copper_tools:example_item 4" });
+1 -1
View File
@@ -63,7 +63,7 @@ Deno.test("new-mod rejects bad and reserved ids", () => {
const dir = temp_mods_dir();
assertThrows(() => create_mod("Has Spaces", "x", dir));
assertThrows(() => create_mod("bworld", "x", dir));
assertThrows(() => create_mod("engine", "x", dir));
assertThrows(() => create_mod("cubi", "x", dir));
create_mod("once", "x", dir);
assertThrows(() => create_mod("once", "x", dir));
Deno.removeSync(dir, { recursive: true });
+2 -2
View File
@@ -43,11 +43,11 @@ Deno.test("a parent can be another mod's model or a built-in one", () => {
const earlier: Record<string, ModelJson> = { "base:slab": { id: "base:slab", elements: [BOX] } };
const { models, problems } = resolve_models([
{ id: "a:slab", parent: "base:slab", textures: { top: "a:top" } },
{ id: "a:cross", parent: "engine:cross" },
{ id: "a:cross", parent: "cubi:cross" },
], (id) => BUILTIN_MODELS[id] ?? earlier[id]);
assertEquals(problems, []);
assertEquals(models[0].elements, [BOX]);
assertEquals(models[1].elements, BUILTIN_MODELS["engine:cross"].elements);
assertEquals(models[1].elements, BUILTIN_MODELS["cubi:cross"].elements);
});
Deno.test("a missing parent and parents that loop are problems, and the models still resolve", () => {
+3 -3
View File
@@ -32,7 +32,7 @@ async function setup(roof = "bworld:stone") {
for (let x = x0; x < x0 + CHUNK_SIZE; x++) {
for (let z = x0; z < x0 + CHUNK_SIZE; z++) {
for (let y = 0; y < FLOOR; y++) world.set_block(x, y, z, "bworld:stone");
for (let y = ROOF + 1; y < CHUNK_HEIGHT; y++) world.set_block(x, y, z, "bworld:air");
for (let y = ROOF + 1; y < CHUNK_HEIGHT; y++) world.set_block(x, y, z, "cubi:air");
}
}
for (let x = x0 - 1; x <= x0 + CHUNK_SIZE; x++) {
@@ -40,7 +40,7 @@ async function setup(roof = "bworld:stone") {
const wall = x < x0 || z < x0 || x >= x0 + CHUNK_SIZE || z >= x0 + CHUNK_SIZE;
world.set_block(x, FLOOR, z, "bworld:stone");
world.set_block(x, ROOF, z, wall ? "bworld:stone" : roof);
for (let y = FLOOR + 1; y < ROOF; y++) world.set_block(x, y, z, wall ? "bworld:stone" : "bworld:air");
for (let y = FLOOR + 1; y < ROOF; y++) world.set_block(x, y, z, wall ? "bworld:stone" : "cubi:air");
}
}
// only the rotwalker, so what else the undergarden spawns doesn't change what can spawn here
@@ -76,7 +76,7 @@ function try_spawning(game: Awaited<ReturnType<typeof setup>>["game"], tries: nu
Deno.test("the server's light is the same as what clients work out", async () => {
const { world, x0 } = await setup();
world.set_block(x0 + 3, FLOOR + 1, x0 + 3, "bworld:light");
world.set_block(x0 + 12, ROOF, x0 + 12, "bworld:air");
world.set_block(x0 + 12, ROOF, x0 + 12, "cubi:air");
const blocks = EverythingRegistry.get_registry<BlockRegistry>("blocks");
const opacity = new Uint8Array(REGION_VOID + 1);
+2 -2
View File
@@ -29,7 +29,7 @@ export function setup(ctx: ServerContext) {
// hangs from the block above and falls when it's gone, which only a server handler can do
ctx.components.register_block("testmod:lantern", {
on_neighbor_change(block) {
if (ctx.world.get_block(block.x, block.y + 1, block.z) === "bworld:air") {
if (ctx.world.get_block(block.x, block.y + 1, block.z) === "cubi:air") {
ctx.world.break_block(block.x, block.y, block.z);
}
},
@@ -196,7 +196,7 @@ Deno.test("a script can tell any block of a change, and one told in on_break hea
// right away, when nothing else is changing
command("/tell 2 100 0 2 100 5");
assertEquals(log(), [["neighbor", "2 100 0", "bworld:air", "2 100 5", 1]]);
assertEquals(log(), [["neighbor", "2 100 0", "cubi:air", "2 100 5", 1]]);
cleanup();
});
+2 -2
View File
@@ -114,7 +114,7 @@ Deno.test("sneaking with an item places it against a block that does something w
hold("testmod:pillar");
send(1, { type: "use_block", x: 1, y: 99, z: 1, face: "top" });
assertEquals(log()["interact"], [false]);
assertEquals(game.world.get_block_id(1, 100, 1), "bworld:air");
assertEquals(game.world.get_block_id(1, 100, 1), "cubi:air");
// the box isn't used, and the pillar's placement knows they were sneaking
move(true);
@@ -195,6 +195,6 @@ Deno.test("how far players reach is an attribute, which their client is sent", a
const sent = take(1).filter((m) => m.type === "attributes").at(-1);
assertEquals([sent.block_interaction_range, sent.entity_interaction_range], [9, 3]);
send(1, { type: "break_block", x: 0, y: 99, z: 9 });
assertEquals(game.world.get_block_id(0, 99, 9), "bworld:air");
assertEquals(game.world.get_block_id(0, 99, 9), "cubi:air");
cleanup();
});
+1 -1
View File
@@ -120,7 +120,7 @@ Deno.test("recipes are found by category in jei's order, and a catalyst's uses a
furnace_uses.find(([type]) => type === "bworld:fuel")?.[1],
all.filter((r) => r.type === "bworld:fuel"),
);
assertEquals(index.find(item("bworld:air"), "recipes"), []);
assertEquals(index.find(item("cubi:air"), "recipes"), []);
});
Deno.test("clicking a fish shows when and where it bites, and the fishing rod's uses are every fish", async () => {
+1 -1
View File
@@ -65,7 +65,7 @@ function recipe_mod(shared_extra = "", recipes: Record<string, unknown> = {}) {
const item = (id: string, components?: unknown) =>
write(`items/${id}.json`, {
format_version: 1,
item: { id: `testrecipes:${id}`, texture: "engine:missing", ...(components ? { components } : {}) },
item: { id: `testrecipes:${id}`, texture: "cubi:missing", ...(components ? { components } : {}) },
});
item("gravel", { "testrecipes:siftable": { into: "testrecipes:flint" } });
item("sand");

Some files were not shown because too many files have changed in this diff Show More