diff --git a/mods/bworld/manifest.json b/mods/bworld/manifest.json index 58ba9da..b578aad 100644 --- a/mods/bworld/manifest.json +++ b/mods/bworld/manifest.json @@ -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" } } diff --git a/mods/bworld/scripts/content.ts b/mods/bworld/scripts/content.ts new file mode 100644 index 0000000..4a6ffdf --- /dev/null +++ b/mods/bworld/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/
/.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`, + }); + } +} diff --git a/mods/bworld/textures/rock/magma/andesite.json b/mods/bworld/textures/rock/magma/andesite.json new file mode 100644 index 0000000..50c70b8 --- /dev/null +++ b/mods/bworld/textures/rock/magma/andesite.json @@ -0,0 +1 @@ +{ "animation": { "frametime": 8, "interpolate": true, "frames": [0, 1, 2] } } diff --git a/mods/bworld/textures/rock/magma/andesite.png.mcmeta b/mods/bworld/textures/rock/magma/andesite.png.mcmeta deleted file mode 100644 index 922ba74..0000000 --- a/mods/bworld/textures/rock/magma/andesite.png.mcmeta +++ /dev/null @@ -1,11 +0,0 @@ -{ - "animation": { - "frametime": 8, - "interpolate": true, - "frames": [ - 0, - 1, - 2 - ] - } -} \ No newline at end of file diff --git a/mods/bworld/textures/rock/magma/basalt.json b/mods/bworld/textures/rock/magma/basalt.json new file mode 100644 index 0000000..50c70b8 --- /dev/null +++ b/mods/bworld/textures/rock/magma/basalt.json @@ -0,0 +1 @@ +{ "animation": { "frametime": 8, "interpolate": true, "frames": [0, 1, 2] } } diff --git a/mods/bworld/textures/rock/magma/basalt.png.mcmeta b/mods/bworld/textures/rock/magma/basalt.png.mcmeta deleted file mode 100644 index 922ba74..0000000 --- a/mods/bworld/textures/rock/magma/basalt.png.mcmeta +++ /dev/null @@ -1,11 +0,0 @@ -{ - "animation": { - "frametime": 8, - "interpolate": true, - "frames": [ - 0, - 1, - 2 - ] - } -} \ No newline at end of file diff --git a/mods/bworld/textures/rock/magma/dacite.json b/mods/bworld/textures/rock/magma/dacite.json new file mode 100644 index 0000000..50c70b8 --- /dev/null +++ b/mods/bworld/textures/rock/magma/dacite.json @@ -0,0 +1 @@ +{ "animation": { "frametime": 8, "interpolate": true, "frames": [0, 1, 2] } } diff --git a/mods/bworld/textures/rock/magma/dacite.png.mcmeta b/mods/bworld/textures/rock/magma/dacite.png.mcmeta deleted file mode 100644 index 922ba74..0000000 --- a/mods/bworld/textures/rock/magma/dacite.png.mcmeta +++ /dev/null @@ -1,11 +0,0 @@ -{ - "animation": { - "frametime": 8, - "interpolate": true, - "frames": [ - 0, - 1, - 2 - ] - } -} \ No newline at end of file diff --git a/mods/bworld/textures/rock/magma/diorite.json b/mods/bworld/textures/rock/magma/diorite.json new file mode 100644 index 0000000..50c70b8 --- /dev/null +++ b/mods/bworld/textures/rock/magma/diorite.json @@ -0,0 +1 @@ +{ "animation": { "frametime": 8, "interpolate": true, "frames": [0, 1, 2] } } diff --git a/mods/bworld/textures/rock/magma/diorite.png.mcmeta b/mods/bworld/textures/rock/magma/diorite.png.mcmeta deleted file mode 100644 index 922ba74..0000000 --- a/mods/bworld/textures/rock/magma/diorite.png.mcmeta +++ /dev/null @@ -1,11 +0,0 @@ -{ - "animation": { - "frametime": 8, - "interpolate": true, - "frames": [ - 0, - 1, - 2 - ] - } -} \ No newline at end of file diff --git a/mods/bworld/textures/rock/magma/gabbro.json b/mods/bworld/textures/rock/magma/gabbro.json new file mode 100644 index 0000000..50c70b8 --- /dev/null +++ b/mods/bworld/textures/rock/magma/gabbro.json @@ -0,0 +1 @@ +{ "animation": { "frametime": 8, "interpolate": true, "frames": [0, 1, 2] } } diff --git a/mods/bworld/textures/rock/magma/gabbro.png.mcmeta b/mods/bworld/textures/rock/magma/gabbro.png.mcmeta deleted file mode 100644 index 922ba74..0000000 --- a/mods/bworld/textures/rock/magma/gabbro.png.mcmeta +++ /dev/null @@ -1,11 +0,0 @@ -{ - "animation": { - "frametime": 8, - "interpolate": true, - "frames": [ - 0, - 1, - 2 - ] - } -} \ No newline at end of file diff --git a/mods/bworld/textures/rock/magma/granite.json b/mods/bworld/textures/rock/magma/granite.json new file mode 100644 index 0000000..50c70b8 --- /dev/null +++ b/mods/bworld/textures/rock/magma/granite.json @@ -0,0 +1 @@ +{ "animation": { "frametime": 8, "interpolate": true, "frames": [0, 1, 2] } } diff --git a/mods/bworld/textures/rock/magma/granite.png.mcmeta b/mods/bworld/textures/rock/magma/granite.png.mcmeta deleted file mode 100644 index 922ba74..0000000 --- a/mods/bworld/textures/rock/magma/granite.png.mcmeta +++ /dev/null @@ -1,11 +0,0 @@ -{ - "animation": { - "frametime": 8, - "interpolate": true, - "frames": [ - 0, - 1, - 2 - ] - } -} \ No newline at end of file diff --git a/mods/bworld/textures/rock/magma/rhyolite.json b/mods/bworld/textures/rock/magma/rhyolite.json new file mode 100644 index 0000000..50c70b8 --- /dev/null +++ b/mods/bworld/textures/rock/magma/rhyolite.json @@ -0,0 +1 @@ +{ "animation": { "frametime": 8, "interpolate": true, "frames": [0, 1, 2] } } diff --git a/mods/bworld/textures/rock/magma/rhyolite.png.mcmeta b/mods/bworld/textures/rock/magma/rhyolite.png.mcmeta deleted file mode 100644 index 922ba74..0000000 --- a/mods/bworld/textures/rock/magma/rhyolite.png.mcmeta +++ /dev/null @@ -1,11 +0,0 @@ -{ - "animation": { - "frametime": 8, - "interpolate": true, - "frames": [ - 0, - 1, - 2 - ] - } -} \ No newline at end of file diff --git a/tests/mod_test.ts b/tests/mod_test.ts index 9982c55..3a1fc57 100644 --- a/tests/mod_test.ts +++ b/tests/mod_test.ts @@ -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 });