Register lots of rocks

This commit is contained in:
2026-11-12 22:53:42 -03:00
parent 76802ed430
commit e013fbe550
17 changed files with 81 additions and 79 deletions
+2 -1
View File
@@ -13,6 +13,7 @@
"server": "scripts/server.ts",
"client": "scripts/client.ts",
"shared": "scripts/shared.ts",
"worldgen": "scripts/worldgen.ts"
"worldgen": "scripts/worldgen.ts",
"content": "scripts/content.ts"
}
}
+71
View File
@@ -0,0 +1,71 @@
// 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 setup(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`,
});
}
}
@@ -0,0 +1 @@
{ "animation": { "frametime": 8, "interpolate": true, "frames": [0, 1, 2] } }
@@ -1,11 +0,0 @@
{
"animation": {
"frametime": 8,
"interpolate": true,
"frames": [
0,
1,
2
]
}
}
@@ -0,0 +1 @@
{ "animation": { "frametime": 8, "interpolate": true, "frames": [0, 1, 2] } }
@@ -1,11 +0,0 @@
{
"animation": {
"frametime": 8,
"interpolate": true,
"frames": [
0,
1,
2
]
}
}
@@ -0,0 +1 @@
{ "animation": { "frametime": 8, "interpolate": true, "frames": [0, 1, 2] } }
@@ -1,11 +0,0 @@
{
"animation": {
"frametime": 8,
"interpolate": true,
"frames": [
0,
1,
2
]
}
}
@@ -0,0 +1 @@
{ "animation": { "frametime": 8, "interpolate": true, "frames": [0, 1, 2] } }
@@ -1,11 +0,0 @@
{
"animation": {
"frametime": 8,
"interpolate": true,
"frames": [
0,
1,
2
]
}
}
@@ -0,0 +1 @@
{ "animation": { "frametime": 8, "interpolate": true, "frames": [0, 1, 2] } }
@@ -1,11 +0,0 @@
{
"animation": {
"frametime": 8,
"interpolate": true,
"frames": [
0,
1,
2
]
}
}
@@ -0,0 +1 @@
{ "animation": { "frametime": 8, "interpolate": true, "frames": [0, 1, 2] } }
@@ -1,11 +0,0 @@
{
"animation": {
"frametime": 8,
"interpolate": true,
"frames": [
0,
1,
2
]
}
}
@@ -0,0 +1 @@
{ "animation": { "frametime": 8, "interpolate": true, "frames": [0, 1, 2] } }
@@ -1,11 +0,0 @@
{
"animation": {
"frametime": 8,
"interpolate": true,
"frames": [
0,
1,
2
]
}
}