72 lines
2.3 KiB
TypeScript
72 lines
2.3 KiB
TypeScript
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
// the rocks: every kind of rock in every form there's a texture for, textures/rock/<form>/<rock>.png. mined like stone,
|
|
// raw rock drops its cobblestone and gravel is dug like sand
|
|
import type { ContentContext } from "cubi/content";
|
|
|
|
const IGNEOUS = ["granite", "diorite", "gabbro", "rhyolite", "basalt", "andesite", "dacite"];
|
|
const ROCKS = [
|
|
...IGNEOUS,
|
|
"shale",
|
|
"claystone",
|
|
"limestone",
|
|
"conglomerate",
|
|
"dolomite",
|
|
"chert",
|
|
"chalk",
|
|
"tuff",
|
|
"quartzite",
|
|
"slate",
|
|
"phyllite",
|
|
"schist",
|
|
"gneiss",
|
|
"marble",
|
|
];
|
|
// rocks whose raw form has layers, so its top and bottom look different from its sides
|
|
const LAYERED = ["shale", "claystone"];
|
|
|
|
// each form's id from the rock's, and its texture folder
|
|
const FORMS: { form: string; id: (rock: string) => string }[] = [
|
|
{ form: "raw", id: (rock) => `raw_${rock}` },
|
|
{ form: "smooth", id: (rock) => `smooth_${rock}` },
|
|
{ form: "cobble", id: (rock) => `${rock}_cobblestone` },
|
|
{ form: "mossy_cobble", id: (rock) => `mossy_${rock}_cobblestone` },
|
|
{ form: "bricks", id: (rock) => `${rock}_bricks` },
|
|
{ form: "cracked_bricks", id: (rock) => `cracked_${rock}_bricks` },
|
|
{ form: "mossy_bricks", id: (rock) => `mossy_${rock}_bricks` },
|
|
{ form: "chiseled", id: (rock) => `chiseled_${rock}` },
|
|
{ form: "gravel", id: (rock) => `${rock}_gravel` },
|
|
];
|
|
|
|
const STONE_MINING = { toughness: 3, tool: "pickaxe", requires_tool: true } as const;
|
|
|
|
export function content(ctx: ContentContext) {
|
|
const texture = (form: string, rock: string) => `bworld:rock_${form}_${rock}`;
|
|
for (const rock of ROCKS) {
|
|
for (const { form, id } of FORMS) {
|
|
const block = `bworld:${id(rock)}`;
|
|
const side = texture(form, rock);
|
|
const textures = form === "raw" && LAYERED.includes(rock)
|
|
? { top: `${side}_top`, bottom: `${side}_top`, side }
|
|
: side;
|
|
ctx.blocks.register({
|
|
id: block,
|
|
textures,
|
|
mining: form === "gravel" ? { toughness: 3, tool: "shovel" } : STONE_MINING,
|
|
drops: form === "raw" ? `bworld:${rock}_cobblestone` : block,
|
|
});
|
|
}
|
|
}
|
|
// igneous rock hot enough to glow
|
|
for (const rock of IGNEOUS) {
|
|
ctx.blocks.register({
|
|
id: `bworld:${rock}_magma_block`,
|
|
textures: texture("magma", rock),
|
|
light_emission: 3,
|
|
mining: STONE_MINING,
|
|
drops: `bworld:${rock}_magma_block`,
|
|
});
|
|
}
|
|
}
|