Register lots of rocks
This commit is contained in:
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
]
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -51,7 +51,7 @@ Deno.test("packing a mod keeps its data, scripts, textures and credits, and give
|
||||
|
||||
const bworld = read_mod(Deno.readFileSync(`${folder}/bworld.cubi`), "bworld.cubi");
|
||||
assertEquals(bworld.data.blocks.length, [...Deno.readDirSync("mods/bworld/blocks")].length);
|
||||
assertEquals(Object.keys(bworld.scripts), ["server", "client", "worldgen", "shared"]);
|
||||
assertEquals(Object.keys(bworld.scripts), ["server", "client", "worldgen", "shared", "content"]);
|
||||
|
||||
Deno.removeSync(sources, { recursive: true });
|
||||
Deno.removeSync(folder, { recursive: true });
|
||||
|
||||
Reference in New Issue
Block a user