diff --git a/MODS.md b/MODS.md index a358282..ffbdcc6 100644 --- a/MODS.md +++ b/MODS.md @@ -239,6 +239,7 @@ program**, so the server and each client can number blocks differently. Saves an | `variants` | none | `variants` | A different `model`, `textures` or `y` rotation for some states, see [block models](#block-models). | | `render_layer` | `solid` | `render_layer` | `solid`, `cutout` (texels fully opaque or fully clear, like leaves) or `translucent` (blended, like water and glass). Non-solid blocks don't hide their neighbors' faces. | | `cull_same` | see meaning | `cull_same` | Hide faces between two of this block. Defaults to `true` for translucent blocks, `false` otherwise. | +| `tint` | none | `tint` | Draws its textures in a color: `{ "color": "grass" }` or `"foliage"` for the biome's (blended across biome edges, like minecraft's grass and leaves), or a fixed one like `"#80a755"`. `"textures": ["top"]` tints only those texture variables, like the grass block's top. Paint the textures grey. Its item uses plains' color. | | `light_emission` | `0` | `light_emission` | Light level 0-15 it gives off, like a torch (14). | | `light_opacity` | see meaning | `light_opacity` | How much light passing through it loses, 0-15. Defaults to `15` (blocks all light) for solid blocks and `0` otherwise. Leaves and water use `1`. | | `alpha` | `1` | `alpha` | Opacity for translucent blocks. | @@ -445,9 +446,9 @@ clients as part of the container it's in, so client screens can show it. | `type` | Fields | Notes | | --------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | -| `shaped` | `pattern` rows (space is empty), `key` letter to item id, `result` `{ id, count }` | Used by the crafting grid, fits anywhere in it | -| `furnace` | `input` item id, `output` `{ id, count }`, `cook_time` in ticks | Used by the furnace | -| `fuel` | `item` id, `burn_time` in ticks | Used by the furnace | +| `shaped` | `pattern` rows (space is empty), `key` letter to item id (or a list of ids), `result` `{ id, count }` | Used by the crafting grid, fits anywhere in it | +| `furnace` | `input` item id (or a list of ids), `output` `{ id, count }`, `cook_time` in ticks | Used by the furnace | +| `fuel` | `item` id (or a list of ids), `burn_time` in ticks | Used by the furnace | | `smithing` | `tool` item id, `material` `{ id, count }`, optional `addition` item id, `result` item id | Used by the smithing table: upgrades the tool, keeping its data. Uses up the tool, `count` of the material and the addition | A smithing recipe, `recipes/smithing_stone_pickaxe.json`: @@ -478,6 +479,10 @@ A shaped recipe, for the crafting grid in the player's inventory screen: } ``` +Where a recipe takes an item, a list of ids means any of them fits, like every kind of planks in the stick recipe: +`"key": { "P": ["bworld:planks", "bworld:birch_planks"] }`. In a crafting grid each slot can hold a different one of +them, so a stick can be made from oak and birch planks together. The recipe viewer takes turns showing them. + Two furnace recipes with the same `input`, two smithing recipes with the same tool, material and addition, or two shaped recipes with the same pattern and key, are a load error. diff --git a/client/level/client_level.ts b/client/level/client_level.ts index 91b38d5..9a70af8 100644 --- a/client/level/client_level.ts +++ b/client/level/client_level.ts @@ -45,6 +45,8 @@ export interface Chunk { // blocks its generation put in neighboring chunks (leaves), as x, y, z, numeric id. kept so a neighbor that // generates later, or unloads and comes back, still gets them spills?: Int32Array; + // each column's biome grass then foliage color, once it's generated + biome_colors?: Uint32Array; } export interface ChunkMesh { @@ -446,9 +448,12 @@ export class ClientLevel { chunk.mesh_version += 1; // copies, the worker lights the whole 3x3 area const chunks: (Uint32Array | null)[] = []; + const biome_colors: (Uint32Array | null)[] = []; for (let dz = -1; dz <= 1; dz++) { for (let dx = -1; dx <= 1; dx++) { - chunks.push(this.get_chunk(chunk.x + dx, chunk.z + dz)?.blocks.slice() ?? null); + const neighbor = this.get_chunk(chunk.x + dx, chunk.z + dz); + chunks.push(neighbor?.blocks.slice() ?? null); + biome_colors.push(neighbor?.biome_colors ?? null); } } this.workers.post({ @@ -457,6 +462,7 @@ export class ClientLevel { chunk_z: chunk.z, version: chunk.mesh_version, chunks, + biome_colors, camera: [camera.x, camera.y, camera.z], }, chunks.filter((blocks) => blocks !== null).map((blocks) => blocks.buffer)); } @@ -487,7 +493,7 @@ export class ClientLevel { #on_worker_message(message: FromChunkWorker) { if (message.type === "generated") { - this.#on_generated(message.chunk_x, message.chunk_z, message.blocks, message.spills); + this.#on_generated(message.chunk_x, message.chunk_z, message.blocks, message.spills, message.biome_colors); } else if (message.type === "meshed") { this.#on_meshed(message); } else { @@ -495,7 +501,7 @@ export class ClientLevel { } } - #on_generated(cx: number, cz: number, blocks: Uint32Array, spills: Int32Array) { + #on_generated(cx: number, cz: number, blocks: Uint32Array, spills: Int32Array, biome_colors: Uint32Array) { const key = chunk_key(cx, cz); // unloaded or cancelled while the worker was busy if (!this.pending_generation.delete(key)) { @@ -517,6 +523,7 @@ export class ClientLevel { chunk.generated = true; chunk.dirty = true; chunk.spills = spills; + chunk.biome_colors = biome_colors; // the same rules as the server (server/game/world.ts): a chunk's own blocks, then what its neighbors' // features put in it, only where it has air. both ways, since the neighbors may have generated first diff --git a/client/rendering/item_renderer.ts b/client/rendering/item_renderer.ts index b08703b..26b951a 100644 --- a/client/rendering/item_renderer.ts +++ b/client/rendering/item_renderer.ts @@ -5,7 +5,7 @@ import { get_sprite_region } from "$/client/sprites.ts"; import type { ItemEntity } from "$/client/entity/item_entity.ts"; import type { ItemStack } from "$/common/inventory.ts"; import { push_vertex, Texture } from "$/client/renderer/mod.ts"; -import { block_item_texture, cube_face_texture } from "$/common/block_models.ts"; +import { block_item_texture, cube_face_texture, cube_face_tint } from "$/common/block_models.ts"; import { item_model } from "./item_model.ts"; // how big items on the ground are drawn, minecraft's ground transform @@ -82,7 +82,8 @@ export function push_item(atlas: Texture, item: ItemStack, transform: ItemTransf for (const face of CUBE_FACES) { const region = get_sprite_region(cube_face_texture(block, face.texture)); const corners = face.corners.map(([cx, cy, cz]) => transform(cx - 0.5, cy, cz - 0.5)); - push_textured_quad(atlas, region, corners, face.shade); + const [r, g, b] = cube_face_tint(block, face.texture); + push_textured_quad(atlas, region, corners, [face.shade * r, face.shade * g, face.shade * b]); } return; } @@ -100,7 +101,7 @@ export function push_item(atlas: Texture, item: ItemStack, transform: ItemTransf } } -function push_textured_quad(atlas: Texture, region: { x: number; y: number }, corners: number[][], shade: number) { +function push_textured_quad(atlas: Texture, region: { x: number; y: number }, corners: number[][], color: number[]) { const u0 = (region.x * TEXTURE_SIZE + UV_PAD) / atlas.width; const v0 = (region.y * TEXTURE_SIZE + UV_PAD) / atlas.height; const u1 = ((region.x + 1) * TEXTURE_SIZE - UV_PAD) / atlas.width; @@ -109,7 +110,7 @@ function push_textured_quad(atlas: Texture, region: { x: number; y: number }, co for (const i of [0, 1, 2, 0, 2, 3]) { const [px, py, pz] = corners[i]; const [cu, cv] = CORNER_UVS[i]; - push_vertex(px, py, pz, cu ? u1 : u0, cv ? v1 : v0, shade, shade, shade, 1); + push_vertex(px, py, pz, cu ? u1 : u0, cv ? v1 : v0, color[0], color[1], color[2], 1); } } diff --git a/client/rendering/render_utils.ts b/client/rendering/render_utils.ts index e4a77e1..d8d4def 100644 --- a/client/rendering/render_utils.ts +++ b/client/rendering/render_utils.ts @@ -3,7 +3,7 @@ import { get_sprite_region } from "$/client/sprites.ts"; import { BlockRegistry, EverythingRegistry, ItemRegistry } from "$/common/everything_registry.ts"; import { AssetManager } from "$/client/assets.ts"; import { ItemStack } from "$/common/inventory.ts"; -import { block_item_texture, cube_face_texture } from "$/common/block_models.ts"; +import { block_item_texture, cube_face_texture, cube_face_tint } from "$/common/block_models.ts"; import { draw_text, draw_texture_region, draw_texture_region_skewed, Texture } from "$/client/renderer/mod.ts"; // the corners keep their size (times scale), the edges stretch along and the middle fills the rest, like minecraft's @@ -146,6 +146,7 @@ function draw_item_block(block_info: BlockRegistry, x: number, y: number) { { x: cx, y: cy + half_h }, { x: cx - half_w, y: cy }, ], + ...cube_face_tint(block_info, "top"), ); draw_texture_region_skewed( atlas, @@ -159,6 +160,7 @@ function draw_item_block(block_info: BlockRegistry, x: number, y: number) { { x: cx, y: cy + half_h + height }, { x: cx - half_w, y: cy + height }, ], + ...cube_face_tint(block_info, "side"), ); draw_texture_region_skewed( atlas, @@ -172,5 +174,6 @@ function draw_item_block(block_info: BlockRegistry, x: number, y: number) { { x: cx, y: cy + half_h + height }, { x: cx + half_w, y: cy + height }, ], + ...cube_face_tint(block_info, "front"), ); } diff --git a/client/workers/chunk_messages.ts b/client/workers/chunk_messages.ts index afd50ce..61dee45 100644 --- a/client/workers/chunk_messages.ts +++ b/client/workers/chunk_messages.ts @@ -46,6 +46,8 @@ export type ToChunkWorker = version: number; // copies of the blocks of the 3x3 chunks around it, going +x then +z from -x -z, for lighting chunks: (Uint32Array | null)[]; + // the same chunks' biome colors (see "generated"), blended across their edges + biome_colors: (Uint32Array | null)[]; // where the camera is, to sort the translucent quads camera: number[]; } @@ -75,6 +77,8 @@ export type FromChunkWorker = blocks: Uint32Array; // blocks that landed in other chunks (from features like a mod's trees), flattened as x, y, z, numeric id spills: Int32Array; + // each column's biome grass color as 0xRRGGBB, x then z, then each column's foliage color + biome_colors: Uint32Array; } | { type: "meshed"; diff --git a/client/workers/chunk_worker.ts b/client/workers/chunk_worker.ts index 98a4a83..1403f82 100644 --- a/client/workers/chunk_worker.ts +++ b/client/workers/chunk_worker.ts @@ -26,9 +26,17 @@ import { UNALIGNED_GROUP, } from "./chunk_messages.ts"; import { generate_raw_chunk, WorldgenSetup } from "$/common/generation.ts"; +import { foliage_color, grass_color } from "$/common/worldgen/biome_colors.ts"; import { load_worldgen } from "$/common/worldgen_loader.ts"; import { default_block_value, get_state_value } from "$/common/utils.ts"; -import { bake_model, block_variant, FACE_CORNERS, find_model, type ModelJson } from "$/common/block_models.ts"; +import { + bake_model, + block_variant, + FACE_CORNERS, + find_model, + is_tinted, + type ModelJson, +} from "$/common/block_models.ts"; import { choose_sort_type, FACE_AXIS, @@ -105,6 +113,8 @@ interface MeshQuad { sprite: SpriteRegion; // 4 weights per corner light_weights: number[]; + // 0xRRGGBB it's drawn in, GRASS or FOLIAGE for the biome's (see "tint"), or white + tint: number; } let models: Record = {}; @@ -142,6 +152,7 @@ self.onmessage = async (event: MessageEvent) => { case "mesh": { region.fill(message.chunks); region.compute(light_tables); + blend_biome_colors(message.biome_colors); const { solid, cutout, translucent, min_y, max_y } = make_chunk_mesh( message.chunk_x, message.chunk_z, @@ -193,8 +204,66 @@ function post(message: FromChunkWorker, transfer: Transferable[]) { } function generate(chunk_x: number, chunk_z: number, seed: string) { - const { blocks, spills } = generate_raw_chunk(chunk_x, chunk_z, seed, block_ids, worldgen, default_values); - post({ type: "generated", chunk_x, chunk_z, blocks, spills }, [blocks.buffer, spills.buffer]); + const { blocks, spills, biomes } = generate_raw_chunk(chunk_x, chunk_z, seed, block_ids, worldgen, default_values); + const biome_colors = new Uint32Array(CHUNK_AREA * 2); + biomes.forEach((biome, column) => { + biome_colors[column] = grass_color(biome); + biome_colors[CHUNK_AREA + column] = foliage_color(biome); + }); + post({ type: "generated", chunk_x, chunk_z, blocks, spills, biome_colors }, [ + blocks.buffer, + spills.buffer, + biome_colors.buffer, + ]); +} + +// like minecraft's biome blend at its default radius: each column's grass and foliage color is the average of the 5x5 +// columns around it, so biome edges fade instead of being a line. neighbors that aren't there are left out +const BLEND_RADIUS = 2; +// the middle chunk's blended colors, x then z, grass then foliage +const blended = new Uint32Array(CHUNK_AREA * 2); +// what MeshQuad.tint is for the biome's colors, they aren't colors since those only go up to 0xffffff +const GRASS = -1; +const FOLIAGE = -2; + +function blend_biome_colors(colors: (Uint32Array | null)[]) { + for (const offset of [0, CHUNK_AREA]) { + for (let z = 0; z < CHUNK_SIZE; z++) { + for (let x = 0; x < CHUNK_SIZE; x++) { + let r = 0; + let g = 0; + let b = 0; + let count = 0; + for (let dz = -BLEND_RADIUS; dz <= BLEND_RADIUS; dz++) { + for (let dx = -BLEND_RADIUS; dx <= BLEND_RADIUS; dx++) { + // which of the 3x3 chunks, and where in it + const sx = x + dx + CHUNK_SIZE; + const sz = z + dz + CHUNK_SIZE; + const chunk = colors[Math.floor(sz / CHUNK_SIZE) * 3 + Math.floor(sx / CHUNK_SIZE)]; + if (!chunk) continue; + const color = chunk[offset + (sz % CHUNK_SIZE) * CHUNK_SIZE + (sx % CHUNK_SIZE)]; + r += color >> 16; + g += (color >> 8) & 0xff; + b += color & 0xff; + count++; + } + } + const color = count === 0 + ? 0xffffff + : (Math.round(r / count) << 16) | (Math.round(g / count) << 8) | Math.round(b / count); + blended[offset + z * CHUNK_SIZE + x] = color; + } + } + } +} + +// a quad's MeshQuad.tint from its block's "tint" +function quad_tint(block: BlockRegistry, variables: string[]) { + if (!is_tinted(block, variables)) return 0xffffff; + const color = block.tint!.color; + if (color === "grass") return GRASS; + if (color === "foliage") return FOLIAGE; + return parseInt(color.slice(1), 16); } function build_block_tables() { @@ -319,7 +388,16 @@ class QuadBuffer { let mesh_min_y = Infinity; let mesh_max_y = -Infinity; -function push_quad(buffer: QuadBuffer, quad: MeshQuad, x: number, y: number, z: number, alpha: number) { +// tint is 0xRRGGBB, multiplied into the quad's color +function push_quad( + buffer: QuadBuffer, + quad: MeshQuad, + x: number, + y: number, + z: number, + alpha: number, + tint = 0xffffff, +) { buffer.reserve(); const { f32, u16, bytes } = buffer; const sprite = quad.sprite; @@ -336,10 +414,10 @@ function push_quad(buffer: QuadBuffer, quad: MeshQuad, x: number, y: number, z: f32[byte / 4 + 2] = z + quad.positions[corner * 3 + 2]; u16[byte / 2 + 6] = Math.round(atlas_u(sprite, quad.uvs[corner * 2]) * 65535); u16[byte / 2 + 7] = Math.round(atlas_v(sprite, quad.uvs[corner * 2 + 1]) * 65535); - const brightness = Math.round(quad.shade * corner_ao[corner] * 255); - bytes[byte + 16] = brightness; - bytes[byte + 17] = brightness; - bytes[byte + 18] = brightness; + const brightness = quad.shade * corner_ao[corner]; + bytes[byte + 16] = Math.round(brightness * (tint >> 16)); + bytes[byte + 17] = Math.round(brightness * ((tint >> 8) & 0xff)); + bytes[byte + 18] = Math.round(brightness * (tint & 0xff)); bytes[byte + 19] = alpha_byte; // where to read the lightmap, block light across and sky light down bytes[byte + 20] = Math.round((corner_block[corner] + 0.5) / 16 * 255); @@ -385,6 +463,7 @@ function block_quads(value: number): MeshQuad[] { shade: quad.shade ? FACE_SHADE[quad.face] : 1, sprite: textures_info[quad.texture] ?? textures_info["engine:missing"], light_weights: light_weights(quad.face, quad.positions), + tint: quad_tint(block, quad.variables), })); baked.set(key, quads); return quads; @@ -490,10 +569,15 @@ function make_chunk_mesh(chunk_x: number, chunk_z: number, values: Uint32Array, } light_quad(quad, index, y, face_offsets); + const tint = quad.tint === GRASS + ? blended[z * CHUNK_SIZE + x] + : quad.tint === FOLIAGE + ? blended[CHUNK_AREA + z * CHUNK_SIZE + x] + : quad.tint; if (layer_id !== TRANSLUCENT) { const group = opaque[layer_id][quad.group]; - push_quad(group.buffer, quad, wx, y, wz, alpha); + push_quad(group.buffer, quad, wx, y, wz, alpha, tint); if (quad.group !== UNALIGNED_GROUP) { const axis = FACE_AXIS[quad.face]; const plane = (axis === 0 ? wx : axis === 1 ? y : wz) + quad.positions[axis]; @@ -501,7 +585,7 @@ function make_chunk_mesh(chunk_x: number, chunk_z: number, values: Uint32Array, if (plane > group.max) group.max = plane; } } else { - push_quad(translucent_quads, quad, wx, y, wz, alpha); + push_quad(translucent_quads, quad, wx, y, wz, alpha, tint); // sorting treats every quad as facing along an axis, rotated ones too const q = translucent_quads.count - 1; centers = ensure_capacity(centers, (q + 1) * 3); diff --git a/common/block_models.ts b/common/block_models.ts index ad79262..1a9cdff 100644 --- a/common/block_models.ts +++ b/common/block_models.ts @@ -2,6 +2,7 @@ // a block picks one with "model" and fills in its texture variables with "textures". baking turns a model // into quads in block space (0 to 1) that the chunk mesher and the item renderers draw import type { BlockRegistry, BlockTextures } from "./everything_registry.ts"; +import { tint_without_biome } from "./worldgen/biome_colors.ts"; export type ModelFace = "top" | "bottom" | "north" | "south" | "west" | "east"; export const MODEL_FACES: ModelFace[] = ["top", "bottom", "north", "south", "west", "east"]; @@ -126,6 +127,20 @@ export function resolve_texture(reference: string, textures: BlockTextures | und return reference.startsWith("#") ? "engine:missing" : reference; } +// the variables a texture reference goes through before it's a texture id, "#front" on a cube is front then side +export function texture_variables(reference: string, textures: BlockTextures | undefined, model?: ModelJson) { + const variables: string[] = []; + for (let depth = 0; depth < 8 && reference.startsWith("#"); depth++) { + const name = reference.slice(1); + variables.push(name); + if (typeof textures === "string") break; + const next = (textures as Record | undefined)?.[name] ?? model?.textures?.[name]; + if (next === undefined) break; + reference = next; + } + return variables; +} + // the block's model and textures for a value with state bits, from the first variant whose conditions match export function block_variant(block: BlockRegistry, states?: Record): Required { const variant: Required = { @@ -168,6 +183,21 @@ export function cube_face_texture(block: BlockRegistry, face: "top" | "bottom" | return resolve_texture(`#${face}`, block.textures, BUILTIN_MODELS[DEFAULT_MODEL]); } +// the color to draw a face of a block's item in, as r g b from 0 to 1. items aren't in a biome, so a biome "tint" +// gets the default grass or foliage color, like minecraft's grass block item +export function cube_face_tint(block: BlockRegistry, face: "top" | "bottom" | "front" | "side"): number[] { + const variables = texture_variables(`#${face}`, block.textures, BUILTIN_MODELS[DEFAULT_MODEL]); + if (!is_tinted(block, variables)) return [1, 1, 1]; + const color = tint_without_biome(block.tint!.color); + return [color >> 16, (color >> 8) & 0xff, color & 0xff].map((c) => c / 255); +} + +// whether a face that got its texture through these variables is drawn in the block's tint +export function is_tinted(block: BlockRegistry, variables: string[]) { + if (!block.tint) return false; + return !block.tint.textures || block.tint.textures.some((name) => variables.includes(name)); +} + // baking export interface BakedQuad { @@ -176,6 +206,8 @@ export interface BakedQuad { // u v per corner, in pixels of the texture (0-16) uvs: number[]; texture: string; + // the texture variables it went through to get there, like ["front", "side"], for "tint" + variables: string[]; // the side it faces most, as the mesher's face index (see FACE_INDEX) face: number; // the side whose neighbor can hide it, or -1 @@ -257,6 +289,7 @@ export function bake_model(model: ModelJson, textures: BlockTextures | undefined positions, uvs, texture: resolve_texture(face_json.texture, textures, model), + variables: texture_variables(face_json.texture, textures, model), face: facing, cull, flush, diff --git a/common/everything_registry.ts b/common/everything_registry.ts index 51a6bad..fddb4c7 100644 --- a/common/everything_registry.ts +++ b/common/everything_registry.ts @@ -1,3 +1,4 @@ +import type { TintColor } from "./worldgen/biome_colors.ts"; import type { ItemStack } from "./inventory.ts"; import type { BlockVariant } from "./block_models.ts"; @@ -108,6 +109,9 @@ export interface BlockRegistry { render_layer?: RenderLayer; // hide faces between two of this block, like glass and water. defaults to true for translucent blocks cull_same?: boolean; + // drawn in a color: the biome's grass or foliage color, like minecraft's grass block and leaves, or a fixed one + // like "#80a755". only the texture variables listed (like "top"), or all of them + tint?: { color: TintColor; textures?: string[] }; // light level 0-15 it gives off light_emission?: number; // how much light going through it loses, 0-15. see block_light_opacity for the default diff --git a/common/generation.ts b/common/generation.ts index 4b5521b..b5304a2 100644 --- a/common/generation.ts +++ b/common/generation.ts @@ -5,6 +5,7 @@ import { AIR, CHUNK_AREA, CHUNK_HEIGHT, CHUNK_SIZE, ID_MASK } from "$/common/con import type { FeatureChunk } from "$/common/mod_api/worldgen.ts"; import type { OreJson } from "$/common/mod_data.ts"; import { generate_overworld } from "./worldgen/overworld.ts"; +import { type Wood, WOODS } from "./worldgen/trees.ts"; import { named_noise_2d, named_noise_3d } from "./worldgen/noise.ts"; export { named_noise_2d, named_noise_3d }; @@ -29,6 +30,8 @@ export interface RawChunk { blocks: Uint32Array; // blocks it generated in other chunks (from features like a mod's trees), flattened as x, y, z, numeric id spills: Int32Array; + // each column's biome id, x then z + biomes: string[]; } // features that threw, so each is only reported once @@ -70,6 +73,11 @@ export function generate_raw_chunk( const nid = block_ids[name]; return nid === undefined ? AIR : default_values?.[nid] ?? nid; }; + // oak's are the plain bworld:log and bworld:leaves, the others are named after their wood + const wood_ids = (part: "log" | "leaves") => + Object.fromEntries( + WOODS.map((wood) => [wood, id(wood === "oak" ? `bworld:${part}` : `bworld:${wood}_${part}`)]), + ) as Record; generate_overworld(blocks, heights, biomes, chunk_x, chunk_z, seed, { stone: id("bworld:stone"), dirt: id("bworld:dirt"), @@ -77,8 +85,8 @@ export function generate_raw_chunk( sand: id("bworld:sand"), snow: id("bworld:snow"), water: id("bworld:water"), - log: id("bworld:log"), - leaves: id("bworld:leaves"), + logs: wood_ids("log"), + leaves: wood_ids("leaves"), }, (x, y, z, block) => spills.push(x, y, z, block)); generate_ores(blocks, chunk_x, chunk_z, seed, block_ids, BASE_ORES, default_values); @@ -87,7 +95,7 @@ export function generate_raw_chunk( generate_features(blocks, heights, biomes, set, chunk_x, chunk_z, seed, block_ids, worldgen.features); } - return { blocks, spills: new Int32Array(spills) }; + return { blocks, spills: new Int32Array(spills), biomes }; } // each block an ore replaces becomes the first ore whose noise is above its threshold diff --git a/common/mod_check.ts b/common/mod_check.ts index 2c2b2cd..3da43ab 100644 --- a/common/mod_check.ts +++ b/common/mod_check.ts @@ -1,6 +1,6 @@ // checks between mods: dependencies, load order, and ids one mod uses from another. pure, so the build, check-mods // and the server (on .bmod files) all use it -import type { BlockJson, ItemJson, OreJson, RecipeJson } from "./mod_data.ts"; +import { type BlockJson, choice_ids, type ItemJson, type OreJson, type RecipeJson } from "./mod_data.ts"; import { BUILTIN_MODELS, type ModelJson } from "./block_models.ts"; export interface ModReport { @@ -135,15 +135,15 @@ export function check_references(mods: LoadedMod[], engine_textures: Iterable; render_layer?: RenderLayer; cull_same?: boolean; + tint?: { color: TintColor; textures?: string[] }; light_emission?: number; light_opacity?: number; // replaced by render_layer, true means translucent @@ -76,15 +78,22 @@ export interface ItemJson { components?: Record; } +// an item a recipe takes: its id, or a list of ids any of which fits, like every kind of planks +export type ItemChoice = string | string[]; + +export function choice_ids(choice: ItemChoice): string[] { + return typeof choice === "string" ? [choice] : choice; +} + export type RecipeJson = | { type: "shaped"; pattern: string[]; - key: Record; + key: Record; result: { id: string; count: number }; } - | { type: "furnace"; input: string; output: { id: string; count: number }; cook_time: number } - | { type: "fuel"; item: string; burn_time: number } + | { type: "furnace"; input: ItemChoice; output: { id: string; count: number }; cook_time: number } + | { type: "fuel"; item: ItemChoice; burn_time: number } // upgrades a tool at a smithing table, with some of a material and maybe one more item | { type: "smithing"; @@ -111,7 +120,7 @@ export function is_mod_recipe(recipe: RecipeJson): recipe is ModRecipeJson { export interface GridRecipe { width: number; height: number; - pattern: (string | undefined)[]; + pattern: (ItemChoice | undefined)[]; result: { id: string; count: number }; } @@ -124,6 +133,7 @@ export function block_to_json(block: BlockRegistry, has_item: boolean): BlockJso if (block.variants !== undefined) json.variants = block.variants; if (block.render_layer && block.render_layer !== "solid") json.render_layer = block.render_layer; if (block.cull_same !== undefined) json.cull_same = block.cull_same; + if (block.tint !== undefined) json.tint = block.tint; if (block.light_emission !== undefined) json.light_emission = block.light_emission; if (block.light_opacity !== undefined) json.light_opacity = block.light_opacity; if (block.alpha !== undefined) json.alpha = block.alpha; @@ -156,6 +166,7 @@ export function block_from_json(json: BlockJson): { block: BlockRegistry; has_it const render_layer = json.render_layer ?? (json.transparent ? "translucent" : undefined); if (render_layer && render_layer !== "solid") block.render_layer = render_layer; if (json.cull_same !== undefined) block.cull_same = json.cull_same; + if (json.tint !== undefined) block.tint = json.tint; if (json.light_emission !== undefined) block.light_emission = json.light_emission; if (json.light_opacity !== undefined) block.light_opacity = json.light_opacity; if (json.alpha !== undefined) block.alpha = json.alpha; @@ -206,21 +217,22 @@ export function item_from_json(json: ItemJson): ItemRegistry { // shaped recipes <-> the grid format export function grid_recipe_to_json(recipe: GridRecipe): RecipeJson { - const key: Record = {}; + const key: Record = {}; + // by the choice as json, so equal lists share a letter const letters = new Map(); - for (const id of recipe.pattern) { - if (id === undefined || letters.has(id)) continue; - const letter = pick_letter(id, new Set(letters.values())); - letters.set(id, letter); - key[letter] = id; + for (const choice of recipe.pattern) { + if (choice === undefined || letters.has(JSON.stringify(choice))) continue; + const letter = pick_letter(choice_ids(choice)[0], new Set(letters.values())); + letters.set(JSON.stringify(choice), letter); + key[letter] = choice; } const pattern: string[] = []; for (let y = 0; y < recipe.height; y++) { let row = ""; for (let x = 0; x < recipe.width; x++) { - const id = recipe.pattern[y * recipe.width + x]; - row += id === undefined ? " " : letters.get(id); + const choice = recipe.pattern[y * recipe.width + x]; + row += choice === undefined ? " " : letters.get(JSON.stringify(choice)); } pattern.push(row); } @@ -231,7 +243,7 @@ export function grid_recipe_to_json(recipe: GridRecipe): RecipeJson { export function grid_recipe_from_json(json: Extract): GridRecipe { const height = json.pattern.length; const width = Math.max(...json.pattern.map((row) => row.length)); - const pattern: (string | undefined)[] = []; + const pattern: (ItemChoice | undefined)[] = []; for (const row of json.pattern) { for (let x = 0; x < width; x++) { const letter = row[x] ?? " "; @@ -351,6 +363,17 @@ export function validate_block(json: unknown): Problems { for (const key of ["cull_same", "transparent", "collision", "item", "interactive", "replaceable"]) { if (json[key] !== undefined && typeof json[key] !== "boolean") problems.push(`${key} must be true or false`); } + if (json.tint !== undefined) { + const tint = json.tint; + if (!is_object(tint) || !is_tint_color(tint.color)) { + problems.push('tint.color must be "grass", "foliage" or a color like "#80a755"'); + } else if ( + tint.textures !== undefined && + !(Array.isArray(tint.textures) && tint.textures.every((name) => typeof name === "string")) + ) { + problems.push('tint.textures must be a list of texture variables, like ["top"]'); + } + } if (json.alpha !== undefined && (typeof json.alpha !== "number" || json.alpha < 0 || json.alpha > 1)) { problems.push("alpha must be between 0 and 1"); } @@ -493,21 +516,21 @@ export function validate_recipe(json: unknown): Problems { } } if (!is_object(json.key)) { - problems.push("key must map letters to item ids"); + problems.push("key must map letters to item ids, or lists of them"); } else { - for (const id of Object.values(json.key)) problems.push(...validate_id(id, "key")); + for (const choice of Object.values(json.key)) problems.push(...validate_choice(choice, "key")); } problems.push(...validate_stack(json.result, "result")); break; } case "furnace": - problems.push(...validate_id(json.input, "input"), ...validate_stack(json.output, "output")); + problems.push(...validate_choice(json.input, "input"), ...validate_stack(json.output, "output")); if (!Number.isInteger(json.cook_time) || (json.cook_time as number) < 1) { problems.push("cook_time must be a positive number of ticks"); } break; case "fuel": - problems.push(...validate_id(json.item, "item")); + problems.push(...validate_choice(json.item, "item")); if (!Number.isInteger(json.burn_time) || (json.burn_time as number) < 1) { problems.push("burn_time must be a positive number of ticks"); } @@ -544,6 +567,13 @@ export function validate_ore(json: unknown): Problems { return problems; } +// an item id, or a list of them any of which fits +function validate_choice(value: unknown, field: string): Problems { + if (!Array.isArray(value)) return validate_id(value, field); + if (value.length === 0) return [`${field} must list at least one item`]; + return value.flatMap((id) => validate_id(id, field)); +} + // optional text players see function validate_text(value: unknown, field: string): Problems { return value === undefined || (typeof value === "string" && value.length > 0) ? [] : [`${field} must be text`]; diff --git a/common/mod_loader.ts b/common/mod_loader.ts index 9bc8b2e..a3a20c1 100644 --- a/common/mod_loader.ts +++ b/common/mod_loader.ts @@ -3,6 +3,7 @@ import { BlockRegistry, EverythingRegistry, ItemRegistry } from "./everything_re import { block_from_json, BlockJson, + choice_ids, grid_recipe_from_json, GridRecipe, is_mod_recipe, @@ -95,11 +96,13 @@ export function register_mod_data(mods: { id: string; data: ModData }[]): Recipe recipes.shaped.push(grid_recipe_from_json(recipe)); break; case "furnace": - if (recipes.furnace.has(recipe.input)) fail(`two furnace recipes for ${recipe.input}`); - recipes.furnace.set(recipe.input, { output: recipe.output, cook_time: recipe.cook_time }); + for (const input of choice_ids(recipe.input)) { + if (recipes.furnace.has(input)) fail(`two furnace recipes for ${input}`); + recipes.furnace.set(input, { output: recipe.output, cook_time: recipe.cook_time }); + } break; case "fuel": - recipes.fuel.set(recipe.item, recipe.burn_time); + for (const item of choice_ids(recipe.item)) recipes.fuel.set(item, recipe.burn_time); break; case "smithing": if ( diff --git a/common/worldgen/biome_colors.ts b/common/worldgen/biome_colors.ts new file mode 100644 index 0000000..63a2978 --- /dev/null +++ b/common/worldgen/biome_colors.ts @@ -0,0 +1,99 @@ +// what color each biome tints grass and leaves, as 0xRRGGBB. minecraft's grass and foliage colors, with the terralith +// style biomes given the ones of the vanilla biome closest to them. blocks pick them with "tint" +export const BIOME_GRASS_COLORS: Record = { + "bworld:deep_ocean": 0x8eb971, + "bworld:deep_frozen_ocean": 0x80b497, + "bworld:deep_lukewarm_ocean": 0x8eb971, + "bworld:ocean": 0x8eb971, + "bworld:frozen_ocean": 0x80b497, + "bworld:warm_ocean": 0x8eb971, + "bworld:river": 0x8eb971, + "bworld:frozen_river": 0x80b497, + "bworld:beach": 0x91bd59, + "bworld:snowy_beach": 0x83b593, + "bworld:stony_shore": 0x8ab689, + "bworld:plains": 0x91bd59, + "bworld:meadow": 0x83bb6d, + "bworld:forest": 0x79c05a, + "bworld:dark_forest": 0x507a32, + "bworld:swamp": 0x6a7039, + "bworld:taiga": 0x86b783, + "bworld:snowy_plains": 0x80b497, + "bworld:snowy_taiga": 0x80b497, + "bworld:savanna": 0xbfb755, + "bworld:jungle": 0x59c93c, + "bworld:desert": 0xbfb755, + "bworld:alpine_highlands": 0x8ab689, + "bworld:snowy_slopes": 0x80b497, + "bworld:stony_peaks": 0x9abe4b, + "bworld:jagged_peaks": 0x80b497, + "bworld:frozen_peaks": 0x80b497, + "bworld:yosemite_cliffs": 0x86b783, + "bworld:snowy_cliffs": 0x80b497, + "bworld:painted_mountains": 0x90814d, + "bworld:stony_spires": 0x8ab689, + "bworld:shattered_savanna": 0xbfb755, + "bworld:skylands": 0x79c05a, +}; + +export const BIOME_FOLIAGE_COLORS: Record = { + "bworld:deep_ocean": 0x71a74d, + "bworld:deep_frozen_ocean": 0x60a17b, + "bworld:deep_lukewarm_ocean": 0x71a74d, + "bworld:ocean": 0x71a74d, + "bworld:frozen_ocean": 0x60a17b, + "bworld:warm_ocean": 0x71a74d, + "bworld:river": 0x71a74d, + "bworld:frozen_river": 0x60a17b, + "bworld:beach": 0x77ab2f, + "bworld:snowy_beach": 0x64a278, + "bworld:stony_shore": 0x6da36b, + "bworld:plains": 0x77ab2f, + "bworld:meadow": 0x63a948, + "bworld:forest": 0x59ae30, + "bworld:dark_forest": 0x59ae30, + "bworld:swamp": 0x6a7039, + "bworld:taiga": 0x68a464, + "bworld:snowy_plains": 0x60a17b, + "bworld:snowy_taiga": 0x60a17b, + "bworld:savanna": 0xaea42a, + "bworld:jungle": 0x30bb0b, + "bworld:desert": 0xaea42a, + "bworld:alpine_highlands": 0x6da36b, + "bworld:snowy_slopes": 0x60a17b, + "bworld:stony_peaks": 0x82ac1e, + "bworld:jagged_peaks": 0x60a17b, + "bworld:frozen_peaks": 0x60a17b, + "bworld:yosemite_cliffs": 0x68a464, + "bworld:snowy_cliffs": 0x60a17b, + "bworld:painted_mountains": 0x9e814d, + "bworld:stony_spires": 0x6da36b, + "bworld:shattered_savanna": 0xaea42a, + "bworld:skylands": 0x59ae30, +}; + +// biomes mods add without a color, and items, which aren't in any biome +export const DEFAULT_GRASS_COLOR = BIOME_GRASS_COLORS["bworld:plains"]; +export const DEFAULT_FOLIAGE_COLOR = BIOME_FOLIAGE_COLORS["bworld:plains"]; + +export function grass_color(biome: string | undefined) { + return (biome !== undefined ? BIOME_GRASS_COLORS[biome] : undefined) ?? DEFAULT_GRASS_COLOR; +} + +export function foliage_color(biome: string | undefined) { + return (biome !== undefined ? BIOME_FOLIAGE_COLORS[biome] : undefined) ?? DEFAULT_FOLIAGE_COLOR; +} + +// a block's "tint" color: the biome's grass or foliage color, or a fixed one like "#80a755" +export type TintColor = "grass" | "foliage" | `#${string}`; + +export function is_tint_color(value: unknown): value is TintColor { + return value === "grass" || value === "foliage" || (typeof value === "string" && /^#[0-9a-fA-F]{6}$/.test(value)); +} + +// the color outside any biome, for items: the default grass or foliage color, or the fixed one +export function tint_without_biome(color: TintColor) { + if (color === "grass") return DEFAULT_GRASS_COLOR; + if (color === "foliage") return DEFAULT_FOLIAGE_COLOR; + return parseInt(color.slice(1), 16); +} diff --git a/common/worldgen/overworld.ts b/common/worldgen/overworld.ts index 2da532e..b8cfd20 100644 --- a/common/worldgen/overworld.ts +++ b/common/worldgen/overworld.ts @@ -3,7 +3,7 @@ import { CHUNK_AREA, CHUNK_HEIGHT, CHUNK_SIZE, SEA_LEVEL } from "$/common/constants.ts"; import { OctaveNoise2D } from "./noise.ts"; import { OverworldTerrain, TerrainColumn } from "./terrain.ts"; -import { BIOME_TREES, grow_tree, tree_sites } from "./trees.ts"; +import { BIOME_TREES, grow_tree, tree_sites, tree_wood, type Wood } from "./trees.ts"; // density is sampled every CELL_WIDTH blocks across and CELL_HEIGHT up, caves every CAVE_CELL_HEIGHT up since // tunnels are thinner than terrain features @@ -29,8 +29,8 @@ export interface OverworldBlocks { sand: number; snow: number; water: number; - log: number; - leaves: number; + logs: Record; + leaves: Record; } type Palette = "stone" | "dirt" | "grass" | "sand" | "snow"; @@ -244,19 +244,22 @@ export function generate_overworld( grow_trees(); function grow_trees() { - const place = (x: number, y: number, z: number, block: "log" | "leaves") => { + // logs replace any tree's leaves + const all_leaves = new Set(Object.values(ids.leaves)); + const place = (x: number, y: number, z: number, block: "log" | "leaves", wood: Wood) => { if (y < 0 || y >= CHUNK_HEIGHT) return; + const id = block === "log" ? ids.logs[wood] : ids.leaves[wood]; const lx = x - x0; const lz = z - z0; if (lx < 0 || lx >= CHUNK_SIZE || lz < 0 || lz >= CHUNK_SIZE) { // the other chunk only takes it where it has air - spill(x, y, z, ids[block]); + spill(x, y, z, id); return; } const i = y * CHUNK_AREA + lz * CHUNK_SIZE + lx; const current = blocks[i]; - if (current === 0 || (block === "log" && current === ids.leaves)) { - blocks[i] = ids[block]; + if (current === 0 || (block === "log" && all_leaves.has(current))) { + blocks[i] = id; } }; @@ -272,7 +275,8 @@ export function generate_overworld( if ((ground !== ids.grass && ground !== ids.dirt && ground !== ids.snow) || above !== 0) continue; const kind = trees.kinds[Math.floor(site.rng.next() * trees.kinds.length)]; - grow_tree(kind, site.x, ground_y + 1, site.z, site.rng, place); + const wood = tree_wood(kind, biomes[column]); + grow_tree(kind, site.x, ground_y + 1, site.z, site.rng, (x, y, z, block) => place(x, y, z, block, wood)); } } diff --git a/common/worldgen/trees.ts b/common/worldgen/trees.ts index df46fe6..f1ea664 100644 --- a/common/worldgen/trees.ts +++ b/common/worldgen/trees.ts @@ -15,14 +15,32 @@ const REACH = Math.ceil(MIN_DISTANCE / CELL); // the widest a canopy layer gets const MAX_CANOPY = 3; -export type TreeKind = "oak" | "big_oak" | "spruce" | "jungle" | "acacia"; +export type TreeKind = "oak" | "big_oak" | "birch" | "spruce" | "jungle" | "acacia" | "cherry"; +export const WOODS = ["oak", "spruce", "birch", "jungle", "acacia", "dark_oak", "cherry"] as const; +export type Wood = typeof WOODS[number]; + +// the logs and leaves a tree grows, big oaks are dark oak in the dark forest like minecraft's +export function tree_wood(kind: TreeKind, biome: string): Wood { + switch (kind) { + case "big_oak": + return biome === "bworld:dark_forest" ? "dark_oak" : "oak"; + case "birch": + case "spruce": + case "jungle": + case "acacia": + case "cherry": + return kind; + default: + return "oak"; + } +} // how likely each biome's cells are to have a tree, and which kinds grow there export const BIOME_TREES: Record = { - "bworld:forest": { chance: 0.85, kinds: ["oak", "oak", "big_oak"] }, + "bworld:forest": { chance: 0.85, kinds: ["oak", "oak", "big_oak", "birch"] }, "bworld:dark_forest": { chance: 1, kinds: ["big_oak", "big_oak", "oak"] }, "bworld:plains": { chance: 0.05, kinds: ["oak"] }, - "bworld:meadow": { chance: 0.04, kinds: ["oak"] }, + "bworld:meadow": { chance: 0.06, kinds: ["oak", "birch", "cherry", "cherry"] }, "bworld:swamp": { chance: 0.4, kinds: ["big_oak"] }, "bworld:river": { chance: 0.05, kinds: ["oak"] }, "bworld:taiga": { chance: 0.75, kinds: ["spruce"] }, @@ -126,6 +144,30 @@ export function grow_tree(kind: TreeKind, x: number, y: number, z: number, rng: layer(y + height + 1, 1, false); break; } + case "birch": { + // oak's canopy on a taller, straight trunk + const height = random(5, 7); + top = y + height + 1; + if (top >= CHUNK_HEIGHT - 1) return false; + trunk(height); + layer(y + height - 2, 2, true); + layer(y + height - 1, 2, true); + layer(y + height, 1, true); + layer(y + height + 1, 1, false); + break; + } + case "cherry": { + // a short trunk under a wide, rounded canopy + const height = random(4, 6); + top = y + height + 1; + if (top >= CHUNK_HEIGHT - 1) return false; + trunk(height); + layer(y + height - 2, 2, false); + layer(y + height - 1, MAX_CANOPY, false); + layer(y + height, MAX_CANOPY, false); + layer(y + height + 1, 2, false); + break; + } case "big_oak": { const height = random(6, 8); top = y + height + 1; diff --git a/mods/bworld/blocks/acacia_leaves.json b/mods/bworld/blocks/acacia_leaves.json new file mode 100644 index 0000000..39cfe48 --- /dev/null +++ b/mods/bworld/blocks/acacia_leaves.json @@ -0,0 +1,13 @@ +{ + "format_version": 1, + "block": { + "id": "bworld:acacia_leaves", + "textures": "bworld:acacia_leaves", + "render_layer": "cutout", + "light_opacity": 1, + "mining": { + "toughness": 3, + "tool": "hoe" + } + } +} diff --git a/mods/bworld/blocks/acacia_log.json b/mods/bworld/blocks/acacia_log.json new file mode 100644 index 0000000..2d87b4c --- /dev/null +++ b/mods/bworld/blocks/acacia_log.json @@ -0,0 +1,16 @@ +{ + "format_version": 1, + "block": { + "id": "bworld:acacia_log", + "textures": { + "side": "bworld:acacia_log", + "top": "bworld:acacia_log_top", + "bottom": "bworld:acacia_log_top" + }, + "mining": { + "toughness": 3, + "tool": "axe" + }, + "drops": "bworld:acacia_log" + } +} diff --git a/mods/bworld/blocks/acacia_planks.json b/mods/bworld/blocks/acacia_planks.json new file mode 100644 index 0000000..cc4f6e5 --- /dev/null +++ b/mods/bworld/blocks/acacia_planks.json @@ -0,0 +1,12 @@ +{ + "format_version": 1, + "block": { + "id": "bworld:acacia_planks", + "textures": "bworld:acacia_planks", + "mining": { + "toughness": 3, + "tool": "axe" + }, + "drops": "bworld:acacia_planks" + } +} diff --git a/mods/bworld/blocks/birch_leaves.json b/mods/bworld/blocks/birch_leaves.json new file mode 100644 index 0000000..fcff914 --- /dev/null +++ b/mods/bworld/blocks/birch_leaves.json @@ -0,0 +1,16 @@ +{ + "format_version": 1, + "block": { + "id": "bworld:birch_leaves", + "textures": "bworld:birch_leaves", + "tint": { + "color": "#80a755" + }, + "render_layer": "cutout", + "light_opacity": 1, + "mining": { + "toughness": 3, + "tool": "hoe" + } + } +} diff --git a/mods/bworld/blocks/birch_log.json b/mods/bworld/blocks/birch_log.json new file mode 100644 index 0000000..884284a --- /dev/null +++ b/mods/bworld/blocks/birch_log.json @@ -0,0 +1,16 @@ +{ + "format_version": 1, + "block": { + "id": "bworld:birch_log", + "textures": { + "side": "bworld:birch_log", + "top": "bworld:birch_log_top", + "bottom": "bworld:birch_log_top" + }, + "mining": { + "toughness": 3, + "tool": "axe" + }, + "drops": "bworld:birch_log" + } +} diff --git a/mods/bworld/blocks/birch_planks.json b/mods/bworld/blocks/birch_planks.json new file mode 100644 index 0000000..cddc037 --- /dev/null +++ b/mods/bworld/blocks/birch_planks.json @@ -0,0 +1,12 @@ +{ + "format_version": 1, + "block": { + "id": "bworld:birch_planks", + "textures": "bworld:birch_planks", + "mining": { + "toughness": 3, + "tool": "axe" + }, + "drops": "bworld:birch_planks" + } +} diff --git a/mods/bworld/blocks/cherry_leaves.json b/mods/bworld/blocks/cherry_leaves.json new file mode 100644 index 0000000..fb0dc13 --- /dev/null +++ b/mods/bworld/blocks/cherry_leaves.json @@ -0,0 +1,13 @@ +{ + "format_version": 1, + "block": { + "id": "bworld:cherry_leaves", + "textures": "bworld:cherry_leaves", + "render_layer": "cutout", + "light_opacity": 1, + "mining": { + "toughness": 3, + "tool": "hoe" + } + } +} diff --git a/mods/bworld/blocks/cherry_log.json b/mods/bworld/blocks/cherry_log.json new file mode 100644 index 0000000..b540e67 --- /dev/null +++ b/mods/bworld/blocks/cherry_log.json @@ -0,0 +1,16 @@ +{ + "format_version": 1, + "block": { + "id": "bworld:cherry_log", + "textures": { + "side": "bworld:cherry_log", + "top": "bworld:cherry_log_top", + "bottom": "bworld:cherry_log_top" + }, + "mining": { + "toughness": 3, + "tool": "axe" + }, + "drops": "bworld:cherry_log" + } +} diff --git a/mods/bworld/blocks/cherry_planks.json b/mods/bworld/blocks/cherry_planks.json new file mode 100644 index 0000000..fc6a4a7 --- /dev/null +++ b/mods/bworld/blocks/cherry_planks.json @@ -0,0 +1,12 @@ +{ + "format_version": 1, + "block": { + "id": "bworld:cherry_planks", + "textures": "bworld:cherry_planks", + "mining": { + "toughness": 3, + "tool": "axe" + }, + "drops": "bworld:cherry_planks" + } +} diff --git a/mods/bworld/blocks/chest.json b/mods/bworld/blocks/chest.json index 2fefe62..4747066 100644 --- a/mods/bworld/blocks/chest.json +++ b/mods/bworld/blocks/chest.json @@ -2,7 +2,7 @@ "format_version": 1, "block": { "id": "bworld:chest", - "textures": "bworld:planks", + "textures": "bworld:oak_planks", "mining": { "toughness": 8, "tool": "axe" diff --git a/mods/bworld/blocks/dark_oak_leaves.json b/mods/bworld/blocks/dark_oak_leaves.json new file mode 100644 index 0000000..376f4a7 --- /dev/null +++ b/mods/bworld/blocks/dark_oak_leaves.json @@ -0,0 +1,13 @@ +{ + "format_version": 1, + "block": { + "id": "bworld:dark_oak_leaves", + "textures": "bworld:dark_oak_leaves", + "render_layer": "cutout", + "light_opacity": 1, + "mining": { + "toughness": 3, + "tool": "hoe" + } + } +} diff --git a/mods/bworld/blocks/dark_oak_log.json b/mods/bworld/blocks/dark_oak_log.json new file mode 100644 index 0000000..f2a3b96 --- /dev/null +++ b/mods/bworld/blocks/dark_oak_log.json @@ -0,0 +1,16 @@ +{ + "format_version": 1, + "block": { + "id": "bworld:dark_oak_log", + "textures": { + "side": "bworld:dark_oak_log", + "top": "bworld:dark_oak_log_top", + "bottom": "bworld:dark_oak_log_top" + }, + "mining": { + "toughness": 3, + "tool": "axe" + }, + "drops": "bworld:dark_oak_log" + } +} diff --git a/mods/bworld/blocks/dark_oak_planks.json b/mods/bworld/blocks/dark_oak_planks.json new file mode 100644 index 0000000..b40c551 --- /dev/null +++ b/mods/bworld/blocks/dark_oak_planks.json @@ -0,0 +1,12 @@ +{ + "format_version": 1, + "block": { + "id": "bworld:dark_oak_planks", + "textures": "bworld:dark_oak_planks", + "mining": { + "toughness": 3, + "tool": "axe" + }, + "drops": "bworld:dark_oak_planks" + } +} diff --git a/mods/bworld/blocks/dirt.json b/mods/bworld/blocks/dirt.json index af17b2c..7587126 100644 --- a/mods/bworld/blocks/dirt.json +++ b/mods/bworld/blocks/dirt.json @@ -10,7 +10,7 @@ "drops": "bworld:dirt", "components": { "bworld:hoeable": { - "tool": "bworld:hoe", + "tool": "hoe", "into": "bworld:hoed_dirt" } } diff --git a/mods/bworld/blocks/grass.json b/mods/bworld/blocks/grass.json index cc272bd..80085cf 100644 --- a/mods/bworld/blocks/grass.json +++ b/mods/bworld/blocks/grass.json @@ -3,10 +3,11 @@ "block": { "id": "bworld:grass", "textures": { - "top": "bworld:grass_top", + "top": "bworld:grass_block_top", "bottom": "bworld:dirt", - "side": "bworld:grass_side" + "side": "bworld:grass_block_side" }, + "tint": { "color": "grass", "textures": ["top"] }, "mining": { "toughness": 2, "tool": "shovel" @@ -15,7 +16,7 @@ "item": false, "components": { "bworld:hoeable": { - "tool": "bworld:hoe", + "tool": "hoe", "into": "bworld:hoed_dirt" } } diff --git a/mods/bworld/blocks/jungle_leaves.json b/mods/bworld/blocks/jungle_leaves.json new file mode 100644 index 0000000..185aecd --- /dev/null +++ b/mods/bworld/blocks/jungle_leaves.json @@ -0,0 +1,16 @@ +{ + "format_version": 1, + "block": { + "id": "bworld:jungle_leaves", + "textures": "bworld:jungle_leaves", + "tint": { + "color": "foliage" + }, + "render_layer": "cutout", + "light_opacity": 1, + "mining": { + "toughness": 3, + "tool": "hoe" + } + } +} diff --git a/mods/bworld/blocks/jungle_log.json b/mods/bworld/blocks/jungle_log.json new file mode 100644 index 0000000..e8dd6ed --- /dev/null +++ b/mods/bworld/blocks/jungle_log.json @@ -0,0 +1,16 @@ +{ + "format_version": 1, + "block": { + "id": "bworld:jungle_log", + "textures": { + "side": "bworld:jungle_log", + "top": "bworld:jungle_log_top", + "bottom": "bworld:jungle_log_top" + }, + "mining": { + "toughness": 3, + "tool": "axe" + }, + "drops": "bworld:jungle_log" + } +} diff --git a/mods/bworld/blocks/jungle_planks.json b/mods/bworld/blocks/jungle_planks.json new file mode 100644 index 0000000..2d8f2f8 --- /dev/null +++ b/mods/bworld/blocks/jungle_planks.json @@ -0,0 +1,12 @@ +{ + "format_version": 1, + "block": { + "id": "bworld:jungle_planks", + "textures": "bworld:jungle_planks", + "mining": { + "toughness": 3, + "tool": "axe" + }, + "drops": "bworld:jungle_planks" + } +} diff --git a/mods/bworld/blocks/leaves.json b/mods/bworld/blocks/leaves.json index 433525d..0cbd973 100644 --- a/mods/bworld/blocks/leaves.json +++ b/mods/bworld/blocks/leaves.json @@ -2,7 +2,11 @@ "format_version": 1, "block": { "id": "bworld:leaves", - "textures": "bworld:leaves", + "name": "Oak Leaves", + "textures": "bworld:oak_leaves", + "tint": { + "color": "foliage" + }, "render_layer": "cutout", "light_opacity": 1, "mining": { diff --git a/mods/bworld/blocks/log.json b/mods/bworld/blocks/log.json index 6299611..7ced3d9 100644 --- a/mods/bworld/blocks/log.json +++ b/mods/bworld/blocks/log.json @@ -2,10 +2,11 @@ "format_version": 1, "block": { "id": "bworld:log", + "name": "Oak Log", "textures": { - "side": "bworld:log_side", - "top": "bworld:log_top", - "bottom": "bworld:log_top" + "side": "bworld:oak_log", + "top": "bworld:oak_log_top", + "bottom": "bworld:oak_log_top" }, "mining": { "toughness": 3, diff --git a/mods/bworld/blocks/planks.json b/mods/bworld/blocks/planks.json index 7af6dfc..e18d5e1 100644 --- a/mods/bworld/blocks/planks.json +++ b/mods/bworld/blocks/planks.json @@ -2,7 +2,8 @@ "format_version": 1, "block": { "id": "bworld:planks", - "textures": "bworld:planks", + "name": "Oak Planks", + "textures": "bworld:oak_planks", "mining": { "toughness": 3, "tool": "axe" diff --git a/mods/bworld/blocks/spruce_leaves.json b/mods/bworld/blocks/spruce_leaves.json new file mode 100644 index 0000000..b4142e9 --- /dev/null +++ b/mods/bworld/blocks/spruce_leaves.json @@ -0,0 +1,13 @@ +{ + "format_version": 1, + "block": { + "id": "bworld:spruce_leaves", + "textures": "bworld:spruce_leaves", + "render_layer": "cutout", + "light_opacity": 1, + "mining": { + "toughness": 3, + "tool": "hoe" + } + } +} diff --git a/mods/bworld/blocks/spruce_log.json b/mods/bworld/blocks/spruce_log.json new file mode 100644 index 0000000..2deee13 --- /dev/null +++ b/mods/bworld/blocks/spruce_log.json @@ -0,0 +1,16 @@ +{ + "format_version": 1, + "block": { + "id": "bworld:spruce_log", + "textures": { + "side": "bworld:spruce_log", + "top": "bworld:spruce_log_top", + "bottom": "bworld:spruce_log_top" + }, + "mining": { + "toughness": 3, + "tool": "axe" + }, + "drops": "bworld:spruce_log" + } +} diff --git a/mods/bworld/blocks/spruce_planks.json b/mods/bworld/blocks/spruce_planks.json new file mode 100644 index 0000000..95915d9 --- /dev/null +++ b/mods/bworld/blocks/spruce_planks.json @@ -0,0 +1,12 @@ +{ + "format_version": 1, + "block": { + "id": "bworld:spruce_planks", + "textures": "bworld:spruce_planks", + "mining": { + "toughness": 3, + "tool": "axe" + }, + "drops": "bworld:spruce_planks" + } +} diff --git a/mods/bworld/items/axe.json b/mods/bworld/items/axe.json deleted file mode 100644 index dfee3f4..0000000 --- a/mods/bworld/items/axe.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "format_version": 1, - "item": { - "id": "bworld:axe", - "texture": "bworld:axe", - "tool": "axe" - } -} diff --git a/mods/bworld/items/copper_axe.json b/mods/bworld/items/copper_axe.json new file mode 100644 index 0000000..8f7582a --- /dev/null +++ b/mods/bworld/items/copper_axe.json @@ -0,0 +1,8 @@ +{ + "format_version": 1, + "item": { + "id": "bworld:copper_axe", + "texture": "bworld:copper_axe", + "tool": "axe" + } +} diff --git a/mods/bworld/items/copper_hoe.json b/mods/bworld/items/copper_hoe.json new file mode 100644 index 0000000..e24bb76 --- /dev/null +++ b/mods/bworld/items/copper_hoe.json @@ -0,0 +1,8 @@ +{ + "format_version": 1, + "item": { + "id": "bworld:copper_hoe", + "texture": "bworld:copper_hoe", + "tool": "hoe" + } +} diff --git a/mods/bworld/items/copper_pickaxe.json b/mods/bworld/items/copper_pickaxe.json new file mode 100644 index 0000000..a72cf76 --- /dev/null +++ b/mods/bworld/items/copper_pickaxe.json @@ -0,0 +1,8 @@ +{ + "format_version": 1, + "item": { + "id": "bworld:copper_pickaxe", + "texture": "bworld:copper_pickaxe", + "tool": "pickaxe" + } +} diff --git a/mods/bworld/items/copper_shovel.json b/mods/bworld/items/copper_shovel.json new file mode 100644 index 0000000..bf2311a --- /dev/null +++ b/mods/bworld/items/copper_shovel.json @@ -0,0 +1,8 @@ +{ + "format_version": 1, + "item": { + "id": "bworld:copper_shovel", + "texture": "bworld:copper_shovel", + "tool": "shovel" + } +} diff --git a/mods/bworld/items/golden_axe.json b/mods/bworld/items/golden_axe.json new file mode 100644 index 0000000..06e3916 --- /dev/null +++ b/mods/bworld/items/golden_axe.json @@ -0,0 +1,8 @@ +{ + "format_version": 1, + "item": { + "id": "bworld:golden_axe", + "texture": "bworld:golden_axe", + "tool": "axe" + } +} diff --git a/mods/bworld/items/golden_hoe.json b/mods/bworld/items/golden_hoe.json new file mode 100644 index 0000000..96fbf5f --- /dev/null +++ b/mods/bworld/items/golden_hoe.json @@ -0,0 +1,8 @@ +{ + "format_version": 1, + "item": { + "id": "bworld:golden_hoe", + "texture": "bworld:golden_hoe", + "tool": "hoe" + } +} diff --git a/mods/bworld/items/golden_pickaxe.json b/mods/bworld/items/golden_pickaxe.json new file mode 100644 index 0000000..61cd3f5 --- /dev/null +++ b/mods/bworld/items/golden_pickaxe.json @@ -0,0 +1,8 @@ +{ + "format_version": 1, + "item": { + "id": "bworld:golden_pickaxe", + "texture": "bworld:golden_pickaxe", + "tool": "pickaxe" + } +} diff --git a/mods/bworld/items/golden_shovel.json b/mods/bworld/items/golden_shovel.json new file mode 100644 index 0000000..36a17e3 --- /dev/null +++ b/mods/bworld/items/golden_shovel.json @@ -0,0 +1,8 @@ +{ + "format_version": 1, + "item": { + "id": "bworld:golden_shovel", + "texture": "bworld:golden_shovel", + "tool": "shovel" + } +} diff --git a/mods/bworld/items/hoe.json b/mods/bworld/items/hoe.json deleted file mode 100644 index a745f42..0000000 --- a/mods/bworld/items/hoe.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "format_version": 1, - "item": { - "id": "bworld:hoe", - "texture": "bworld:hoe" - } -} diff --git a/mods/bworld/items/iron_axe.json b/mods/bworld/items/iron_axe.json new file mode 100644 index 0000000..20e4dd9 --- /dev/null +++ b/mods/bworld/items/iron_axe.json @@ -0,0 +1,8 @@ +{ + "format_version": 1, + "item": { + "id": "bworld:iron_axe", + "texture": "bworld:iron_axe", + "tool": "axe" + } +} diff --git a/mods/bworld/items/iron_hoe.json b/mods/bworld/items/iron_hoe.json new file mode 100644 index 0000000..6853730 --- /dev/null +++ b/mods/bworld/items/iron_hoe.json @@ -0,0 +1,8 @@ +{ + "format_version": 1, + "item": { + "id": "bworld:iron_hoe", + "texture": "bworld:iron_hoe", + "tool": "hoe" + } +} diff --git a/mods/bworld/items/iron_pickaxe.json b/mods/bworld/items/iron_pickaxe.json new file mode 100644 index 0000000..3534b4d --- /dev/null +++ b/mods/bworld/items/iron_pickaxe.json @@ -0,0 +1,8 @@ +{ + "format_version": 1, + "item": { + "id": "bworld:iron_pickaxe", + "texture": "bworld:iron_pickaxe", + "tool": "pickaxe" + } +} diff --git a/mods/bworld/items/iron_shovel.json b/mods/bworld/items/iron_shovel.json new file mode 100644 index 0000000..2df0589 --- /dev/null +++ b/mods/bworld/items/iron_shovel.json @@ -0,0 +1,8 @@ +{ + "format_version": 1, + "item": { + "id": "bworld:iron_shovel", + "texture": "bworld:iron_shovel", + "tool": "shovel" + } +} diff --git a/mods/bworld/items/pickaxe.json b/mods/bworld/items/pickaxe.json deleted file mode 100644 index 4fb0c77..0000000 --- a/mods/bworld/items/pickaxe.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "format_version": 1, - "item": { - "id": "bworld:pickaxe", - "texture": "bworld:pickaxe" - } -} diff --git a/mods/bworld/items/stone_axe.json b/mods/bworld/items/stone_axe.json new file mode 100644 index 0000000..ed5466b --- /dev/null +++ b/mods/bworld/items/stone_axe.json @@ -0,0 +1,8 @@ +{ + "format_version": 1, + "item": { + "id": "bworld:stone_axe", + "texture": "bworld:stone_axe", + "tool": "axe" + } +} diff --git a/mods/bworld/items/stone_hoe.json b/mods/bworld/items/stone_hoe.json new file mode 100644 index 0000000..57df3d6 --- /dev/null +++ b/mods/bworld/items/stone_hoe.json @@ -0,0 +1,8 @@ +{ + "format_version": 1, + "item": { + "id": "bworld:stone_hoe", + "texture": "bworld:stone_hoe", + "tool": "hoe" + } +} diff --git a/mods/bworld/items/stone_shovel.json b/mods/bworld/items/stone_shovel.json new file mode 100644 index 0000000..85fad72 --- /dev/null +++ b/mods/bworld/items/stone_shovel.json @@ -0,0 +1,8 @@ +{ + "format_version": 1, + "item": { + "id": "bworld:stone_shovel", + "texture": "bworld:stone_shovel", + "tool": "shovel" + } +} diff --git a/mods/bworld/items/wood_axe.json b/mods/bworld/items/wood_axe.json new file mode 100644 index 0000000..df8a067 --- /dev/null +++ b/mods/bworld/items/wood_axe.json @@ -0,0 +1,8 @@ +{ + "format_version": 1, + "item": { + "id": "bworld:wood_axe", + "texture": "bworld:wood_axe", + "tool": "axe" + } +} diff --git a/mods/bworld/items/wood_hoe.json b/mods/bworld/items/wood_hoe.json new file mode 100644 index 0000000..3ed47b5 --- /dev/null +++ b/mods/bworld/items/wood_hoe.json @@ -0,0 +1,8 @@ +{ + "format_version": 1, + "item": { + "id": "bworld:wood_hoe", + "texture": "bworld:wood_hoe", + "tool": "hoe" + } +} diff --git a/mods/bworld/items/wood_shovel.json b/mods/bworld/items/wood_shovel.json new file mode 100644 index 0000000..708c982 --- /dev/null +++ b/mods/bworld/items/wood_shovel.json @@ -0,0 +1,8 @@ +{ + "format_version": 1, + "item": { + "id": "bworld:wood_shovel", + "texture": "bworld:wood_shovel", + "tool": "shovel" + } +} diff --git a/mods/bworld/recipes/crafting_acacia_planks.json b/mods/bworld/recipes/crafting_acacia_planks.json new file mode 100644 index 0000000..5b2d14f --- /dev/null +++ b/mods/bworld/recipes/crafting_acacia_planks.json @@ -0,0 +1,16 @@ +{ + "format_version": 1, + "recipe": { + "type": "shaped", + "pattern": [ + "L" + ], + "key": { + "L": "bworld:acacia_log" + }, + "result": { + "id": "bworld:acacia_planks", + "count": 2 + } + } +} diff --git a/mods/bworld/recipes/crafting_birch_planks.json b/mods/bworld/recipes/crafting_birch_planks.json new file mode 100644 index 0000000..e795022 --- /dev/null +++ b/mods/bworld/recipes/crafting_birch_planks.json @@ -0,0 +1,16 @@ +{ + "format_version": 1, + "recipe": { + "type": "shaped", + "pattern": [ + "L" + ], + "key": { + "L": "bworld:birch_log" + }, + "result": { + "id": "bworld:birch_planks", + "count": 2 + } + } +} diff --git a/mods/bworld/recipes/crafting_bowl.json b/mods/bworld/recipes/crafting_bowl.json index 9448b95..53cf594 100644 --- a/mods/bworld/recipes/crafting_bowl.json +++ b/mods/bworld/recipes/crafting_bowl.json @@ -7,7 +7,15 @@ " P " ], "key": { - "P": "bworld:planks" + "P": [ + "bworld:planks", + "bworld:spruce_planks", + "bworld:birch_planks", + "bworld:jungle_planks", + "bworld:acacia_planks", + "bworld:dark_oak_planks", + "bworld:cherry_planks" + ] }, "result": { "id": "bworld:bowl", diff --git a/mods/bworld/recipes/crafting_cherry_planks.json b/mods/bworld/recipes/crafting_cherry_planks.json new file mode 100644 index 0000000..6ddcea9 --- /dev/null +++ b/mods/bworld/recipes/crafting_cherry_planks.json @@ -0,0 +1,16 @@ +{ + "format_version": 1, + "recipe": { + "type": "shaped", + "pattern": [ + "L" + ], + "key": { + "L": "bworld:cherry_log" + }, + "result": { + "id": "bworld:cherry_planks", + "count": 2 + } + } +} diff --git a/mods/bworld/recipes/crafting_chest.json b/mods/bworld/recipes/crafting_chest.json index 1b7f572..ddd5164 100644 --- a/mods/bworld/recipes/crafting_chest.json +++ b/mods/bworld/recipes/crafting_chest.json @@ -8,7 +8,15 @@ "PPP" ], "key": { - "P": "bworld:planks" + "P": [ + "bworld:planks", + "bworld:spruce_planks", + "bworld:birch_planks", + "bworld:jungle_planks", + "bworld:acacia_planks", + "bworld:dark_oak_planks", + "bworld:cherry_planks" + ] }, "result": { "id": "bworld:chest", diff --git a/mods/bworld/recipes/crafting_dark_oak_planks.json b/mods/bworld/recipes/crafting_dark_oak_planks.json new file mode 100644 index 0000000..a147845 --- /dev/null +++ b/mods/bworld/recipes/crafting_dark_oak_planks.json @@ -0,0 +1,16 @@ +{ + "format_version": 1, + "recipe": { + "type": "shaped", + "pattern": [ + "L" + ], + "key": { + "L": "bworld:dark_oak_log" + }, + "result": { + "id": "bworld:dark_oak_planks", + "count": 2 + } + } +} diff --git a/mods/bworld/recipes/crafting_jungle_planks.json b/mods/bworld/recipes/crafting_jungle_planks.json new file mode 100644 index 0000000..1c00117 --- /dev/null +++ b/mods/bworld/recipes/crafting_jungle_planks.json @@ -0,0 +1,16 @@ +{ + "format_version": 1, + "recipe": { + "type": "shaped", + "pattern": [ + "L" + ], + "key": { + "L": "bworld:jungle_log" + }, + "result": { + "id": "bworld:jungle_planks", + "count": 2 + } + } +} diff --git a/mods/bworld/recipes/crafting_spruce_planks.json b/mods/bworld/recipes/crafting_spruce_planks.json new file mode 100644 index 0000000..fa70f01 --- /dev/null +++ b/mods/bworld/recipes/crafting_spruce_planks.json @@ -0,0 +1,16 @@ +{ + "format_version": 1, + "recipe": { + "type": "shaped", + "pattern": [ + "L" + ], + "key": { + "L": "bworld:spruce_log" + }, + "result": { + "id": "bworld:spruce_planks", + "count": 2 + } + } +} diff --git a/mods/bworld/recipes/crafting_stick.json b/mods/bworld/recipes/crafting_stick.json index 8b4fa38..95b0bcd 100644 --- a/mods/bworld/recipes/crafting_stick.json +++ b/mods/bworld/recipes/crafting_stick.json @@ -7,7 +7,15 @@ "P" ], "key": { - "P": "bworld:planks" + "P": [ + "bworld:planks", + "bworld:spruce_planks", + "bworld:birch_planks", + "bworld:jungle_planks", + "bworld:acacia_planks", + "bworld:dark_oak_planks", + "bworld:cherry_planks" + ] }, "result": { "id": "bworld:stick", diff --git a/mods/bworld/recipes/crafting_wood_axe.json b/mods/bworld/recipes/crafting_wood_axe.json new file mode 100644 index 0000000..88f1b1a --- /dev/null +++ b/mods/bworld/recipes/crafting_wood_axe.json @@ -0,0 +1,27 @@ +{ + "format_version": 1, + "recipe": { + "type": "shaped", + "pattern": [ + "PP", + "PS", + " S" + ], + "key": { + "P": [ + "bworld:planks", + "bworld:spruce_planks", + "bworld:birch_planks", + "bworld:jungle_planks", + "bworld:acacia_planks", + "bworld:dark_oak_planks", + "bworld:cherry_planks" + ], + "S": "bworld:stick" + }, + "result": { + "id": "bworld:wood_axe", + "count": 1 + } + } +} diff --git a/mods/bworld/recipes/crafting_wood_hoe.json b/mods/bworld/recipes/crafting_wood_hoe.json new file mode 100644 index 0000000..a6ab9f0 --- /dev/null +++ b/mods/bworld/recipes/crafting_wood_hoe.json @@ -0,0 +1,27 @@ +{ + "format_version": 1, + "recipe": { + "type": "shaped", + "pattern": [ + "PP", + " S", + " S" + ], + "key": { + "P": [ + "bworld:planks", + "bworld:spruce_planks", + "bworld:birch_planks", + "bworld:jungle_planks", + "bworld:acacia_planks", + "bworld:dark_oak_planks", + "bworld:cherry_planks" + ], + "S": "bworld:stick" + }, + "result": { + "id": "bworld:wood_hoe", + "count": 1 + } + } +} diff --git a/mods/bworld/recipes/crafting_wood_pickaxe.json b/mods/bworld/recipes/crafting_wood_pickaxe.json index 625f0ae..12a3e33 100644 --- a/mods/bworld/recipes/crafting_wood_pickaxe.json +++ b/mods/bworld/recipes/crafting_wood_pickaxe.json @@ -8,7 +8,15 @@ " S " ], "key": { - "P": "bworld:planks", + "P": [ + "bworld:planks", + "bworld:spruce_planks", + "bworld:birch_planks", + "bworld:jungle_planks", + "bworld:acacia_planks", + "bworld:dark_oak_planks", + "bworld:cherry_planks" + ], "S": "bworld:stick" }, "result": { diff --git a/mods/bworld/recipes/crafting_wood_shovel.json b/mods/bworld/recipes/crafting_wood_shovel.json new file mode 100644 index 0000000..f91edfd --- /dev/null +++ b/mods/bworld/recipes/crafting_wood_shovel.json @@ -0,0 +1,27 @@ +{ + "format_version": 1, + "recipe": { + "type": "shaped", + "pattern": [ + "P", + "S", + "S" + ], + "key": { + "P": [ + "bworld:planks", + "bworld:spruce_planks", + "bworld:birch_planks", + "bworld:jungle_planks", + "bworld:acacia_planks", + "bworld:dark_oak_planks", + "bworld:cherry_planks" + ], + "S": "bworld:stick" + }, + "result": { + "id": "bworld:wood_shovel", + "count": 1 + } + } +} diff --git a/mods/bworld/recipes/fuel_log.json b/mods/bworld/recipes/fuel_log.json index 52283b9..0b2edb8 100644 --- a/mods/bworld/recipes/fuel_log.json +++ b/mods/bworld/recipes/fuel_log.json @@ -2,7 +2,15 @@ "format_version": 1, "recipe": { "type": "fuel", - "item": "bworld:log", + "item": [ + "bworld:log", + "bworld:spruce_log", + "bworld:birch_log", + "bworld:jungle_log", + "bworld:acacia_log", + "bworld:dark_oak_log", + "bworld:cherry_log" + ], "burn_time": 100 } } diff --git a/mods/bworld/recipes/smelting_log.json b/mods/bworld/recipes/smelting_log.json index cd859c5..6b44dff 100644 --- a/mods/bworld/recipes/smelting_log.json +++ b/mods/bworld/recipes/smelting_log.json @@ -2,7 +2,15 @@ "format_version": 1, "recipe": { "type": "furnace", - "input": "bworld:log", + "input": [ + "bworld:log", + "bworld:spruce_log", + "bworld:birch_log", + "bworld:jungle_log", + "bworld:acacia_log", + "bworld:dark_oak_log", + "bworld:cherry_log" + ], "output": { "id": "bworld:coal", "count": 1 diff --git a/mods/bworld/recipes/smithing_copper_axe.json b/mods/bworld/recipes/smithing_copper_axe.json new file mode 100644 index 0000000..2cfb640 --- /dev/null +++ b/mods/bworld/recipes/smithing_copper_axe.json @@ -0,0 +1,12 @@ +{ + "format_version": 1, + "recipe": { + "type": "smithing", + "tool": "bworld:stone_axe", + "material": { + "id": "bworld:copper_ingot", + "count": 3 + }, + "result": "bworld:copper_axe" + } +} diff --git a/mods/bworld/recipes/smithing_copper_hoe.json b/mods/bworld/recipes/smithing_copper_hoe.json new file mode 100644 index 0000000..49d2d78 --- /dev/null +++ b/mods/bworld/recipes/smithing_copper_hoe.json @@ -0,0 +1,12 @@ +{ + "format_version": 1, + "recipe": { + "type": "smithing", + "tool": "bworld:stone_hoe", + "material": { + "id": "bworld:copper_ingot", + "count": 2 + }, + "result": "bworld:copper_hoe" + } +} diff --git a/mods/bworld/recipes/smithing_copper_pickaxe.json b/mods/bworld/recipes/smithing_copper_pickaxe.json new file mode 100644 index 0000000..df73cdf --- /dev/null +++ b/mods/bworld/recipes/smithing_copper_pickaxe.json @@ -0,0 +1,12 @@ +{ + "format_version": 1, + "recipe": { + "type": "smithing", + "tool": "bworld:stone_pickaxe", + "material": { + "id": "bworld:copper_ingot", + "count": 3 + }, + "result": "bworld:copper_pickaxe" + } +} diff --git a/mods/bworld/recipes/smithing_copper_shovel.json b/mods/bworld/recipes/smithing_copper_shovel.json new file mode 100644 index 0000000..3433a4b --- /dev/null +++ b/mods/bworld/recipes/smithing_copper_shovel.json @@ -0,0 +1,12 @@ +{ + "format_version": 1, + "recipe": { + "type": "smithing", + "tool": "bworld:stone_shovel", + "material": { + "id": "bworld:copper_ingot", + "count": 1 + }, + "result": "bworld:copper_shovel" + } +} diff --git a/mods/bworld/recipes/smithing_golden_axe.json b/mods/bworld/recipes/smithing_golden_axe.json new file mode 100644 index 0000000..d020e04 --- /dev/null +++ b/mods/bworld/recipes/smithing_golden_axe.json @@ -0,0 +1,12 @@ +{ + "format_version": 1, + "recipe": { + "type": "smithing", + "tool": "bworld:stone_axe", + "material": { + "id": "bworld:gold_ingot", + "count": 3 + }, + "result": "bworld:golden_axe" + } +} diff --git a/mods/bworld/recipes/smithing_golden_hoe.json b/mods/bworld/recipes/smithing_golden_hoe.json new file mode 100644 index 0000000..932530a --- /dev/null +++ b/mods/bworld/recipes/smithing_golden_hoe.json @@ -0,0 +1,12 @@ +{ + "format_version": 1, + "recipe": { + "type": "smithing", + "tool": "bworld:stone_hoe", + "material": { + "id": "bworld:gold_ingot", + "count": 2 + }, + "result": "bworld:golden_hoe" + } +} diff --git a/mods/bworld/recipes/smithing_golden_pickaxe.json b/mods/bworld/recipes/smithing_golden_pickaxe.json new file mode 100644 index 0000000..c05e69d --- /dev/null +++ b/mods/bworld/recipes/smithing_golden_pickaxe.json @@ -0,0 +1,12 @@ +{ + "format_version": 1, + "recipe": { + "type": "smithing", + "tool": "bworld:stone_pickaxe", + "material": { + "id": "bworld:gold_ingot", + "count": 3 + }, + "result": "bworld:golden_pickaxe" + } +} diff --git a/mods/bworld/recipes/smithing_golden_shovel.json b/mods/bworld/recipes/smithing_golden_shovel.json new file mode 100644 index 0000000..5402e6d --- /dev/null +++ b/mods/bworld/recipes/smithing_golden_shovel.json @@ -0,0 +1,12 @@ +{ + "format_version": 1, + "recipe": { + "type": "smithing", + "tool": "bworld:stone_shovel", + "material": { + "id": "bworld:gold_ingot", + "count": 1 + }, + "result": "bworld:golden_shovel" + } +} diff --git a/mods/bworld/recipes/smithing_iron_axe.json b/mods/bworld/recipes/smithing_iron_axe.json new file mode 100644 index 0000000..6dd6765 --- /dev/null +++ b/mods/bworld/recipes/smithing_iron_axe.json @@ -0,0 +1,12 @@ +{ + "format_version": 1, + "recipe": { + "type": "smithing", + "tool": "bworld:stone_axe", + "material": { + "id": "bworld:iron_ingot", + "count": 3 + }, + "result": "bworld:iron_axe" + } +} diff --git a/mods/bworld/recipes/smithing_iron_hoe.json b/mods/bworld/recipes/smithing_iron_hoe.json new file mode 100644 index 0000000..cec0cbb --- /dev/null +++ b/mods/bworld/recipes/smithing_iron_hoe.json @@ -0,0 +1,12 @@ +{ + "format_version": 1, + "recipe": { + "type": "smithing", + "tool": "bworld:stone_hoe", + "material": { + "id": "bworld:iron_ingot", + "count": 2 + }, + "result": "bworld:iron_hoe" + } +} diff --git a/mods/bworld/recipes/smithing_iron_pickaxe.json b/mods/bworld/recipes/smithing_iron_pickaxe.json new file mode 100644 index 0000000..f743051 --- /dev/null +++ b/mods/bworld/recipes/smithing_iron_pickaxe.json @@ -0,0 +1,12 @@ +{ + "format_version": 1, + "recipe": { + "type": "smithing", + "tool": "bworld:stone_pickaxe", + "material": { + "id": "bworld:iron_ingot", + "count": 3 + }, + "result": "bworld:iron_pickaxe" + } +} diff --git a/mods/bworld/recipes/smithing_iron_shovel.json b/mods/bworld/recipes/smithing_iron_shovel.json new file mode 100644 index 0000000..caff3ac --- /dev/null +++ b/mods/bworld/recipes/smithing_iron_shovel.json @@ -0,0 +1,12 @@ +{ + "format_version": 1, + "recipe": { + "type": "smithing", + "tool": "bworld:stone_shovel", + "material": { + "id": "bworld:iron_ingot", + "count": 1 + }, + "result": "bworld:iron_shovel" + } +} diff --git a/mods/bworld/recipes/smithing_stone_axe.json b/mods/bworld/recipes/smithing_stone_axe.json new file mode 100644 index 0000000..b3e3ced --- /dev/null +++ b/mods/bworld/recipes/smithing_stone_axe.json @@ -0,0 +1,12 @@ +{ + "format_version": 1, + "recipe": { + "type": "smithing", + "tool": "bworld:wood_axe", + "material": { + "id": "bworld:stone", + "count": 3 + }, + "result": "bworld:stone_axe" + } +} diff --git a/mods/bworld/recipes/smithing_stone_hoe.json b/mods/bworld/recipes/smithing_stone_hoe.json new file mode 100644 index 0000000..1d64006 --- /dev/null +++ b/mods/bworld/recipes/smithing_stone_hoe.json @@ -0,0 +1,12 @@ +{ + "format_version": 1, + "recipe": { + "type": "smithing", + "tool": "bworld:wood_hoe", + "material": { + "id": "bworld:stone", + "count": 2 + }, + "result": "bworld:stone_hoe" + } +} diff --git a/mods/bworld/recipes/smithing_stone_shovel.json b/mods/bworld/recipes/smithing_stone_shovel.json new file mode 100644 index 0000000..c8d06f7 --- /dev/null +++ b/mods/bworld/recipes/smithing_stone_shovel.json @@ -0,0 +1,12 @@ +{ + "format_version": 1, + "recipe": { + "type": "smithing", + "tool": "bworld:wood_shovel", + "material": { + "id": "bworld:stone", + "count": 1 + }, + "result": "bworld:stone_shovel" + } +} diff --git a/mods/bworld/scripts/server.ts b/mods/bworld/scripts/server.ts index f7e9ae7..958d4b6 100644 --- a/mods/bworld/scripts/server.ts +++ b/mods/bworld/scripts/server.ts @@ -9,11 +9,12 @@ export function setup(ctx: ServerContext) { register_farming(ctx); } -// right clicking with a tool turns the block into another, like a hoe on grass +// right clicking with a type of tool turns the block into another, like any hoe on grass function register_hoeable(ctx: ServerContext) { ctx.components.register_block<{ tool: string; into: string }>("bworld:hoeable", { on_interact(block, params, player) { - if (player.held_item?.id !== params.tool) { + const held = player.held_item; + if (!held || ctx.items.tool(held.id) !== params.tool) { return false; } ctx.world.set_block(block.x, block.y, block.z, params.into); diff --git a/mods/bworld/textures/acacia_leaves.png b/mods/bworld/textures/acacia_leaves.png new file mode 100644 index 0000000..941e384 Binary files /dev/null and b/mods/bworld/textures/acacia_leaves.png differ diff --git a/mods/bworld/textures/acacia_log.png b/mods/bworld/textures/acacia_log.png new file mode 100644 index 0000000..fbe0b3f Binary files /dev/null and b/mods/bworld/textures/acacia_log.png differ diff --git a/mods/bworld/textures/acacia_log_top.png b/mods/bworld/textures/acacia_log_top.png new file mode 100644 index 0000000..2e40745 Binary files /dev/null and b/mods/bworld/textures/acacia_log_top.png differ diff --git a/mods/bworld/textures/acacia_planks.png b/mods/bworld/textures/acacia_planks.png new file mode 100644 index 0000000..c2cffd2 Binary files /dev/null and b/mods/bworld/textures/acacia_planks.png differ diff --git a/mods/bworld/textures/arrow.png b/mods/bworld/textures/arrow.png deleted file mode 100644 index 4daf6d1..0000000 Binary files a/mods/bworld/textures/arrow.png and /dev/null differ diff --git a/mods/bworld/textures/axe.png b/mods/bworld/textures/axe.png deleted file mode 100644 index cd998d7..0000000 Binary files a/mods/bworld/textures/axe.png and /dev/null differ diff --git a/mods/bworld/textures/baked_potato.png b/mods/bworld/textures/baked_potato.png new file mode 100644 index 0000000..3ba5ff7 Binary files /dev/null and b/mods/bworld/textures/baked_potato.png differ diff --git a/mods/bworld/textures/birch_leaves.png b/mods/bworld/textures/birch_leaves.png new file mode 100644 index 0000000..d4860be Binary files /dev/null and b/mods/bworld/textures/birch_leaves.png differ diff --git a/mods/bworld/textures/birch_log.png b/mods/bworld/textures/birch_log.png new file mode 100644 index 0000000..561e8b9 Binary files /dev/null and b/mods/bworld/textures/birch_log.png differ diff --git a/mods/bworld/textures/birch_log_top.png b/mods/bworld/textures/birch_log_top.png new file mode 100644 index 0000000..3cc33bf Binary files /dev/null and b/mods/bworld/textures/birch_log_top.png differ diff --git a/mods/bworld/textures/birch_planks.png b/mods/bworld/textures/birch_planks.png new file mode 100644 index 0000000..d28db49 Binary files /dev/null and b/mods/bworld/textures/birch_planks.png differ diff --git a/mods/bworld/textures/bomb.png b/mods/bworld/textures/bomb.png deleted file mode 100644 index 8155baf..0000000 Binary files a/mods/bworld/textures/bomb.png and /dev/null differ diff --git a/mods/bworld/textures/bow.png b/mods/bworld/textures/bow.png deleted file mode 100644 index 2d9e559..0000000 Binary files a/mods/bworld/textures/bow.png and /dev/null differ diff --git a/mods/bworld/textures/bucket.png b/mods/bworld/textures/bucket.png new file mode 100644 index 0000000..51f9ebb Binary files /dev/null and b/mods/bworld/textures/bucket.png differ diff --git a/mods/bworld/textures/cabbage_seeds.png b/mods/bworld/textures/cabbage_seeds.png deleted file mode 100644 index 692218a..0000000 Binary files a/mods/bworld/textures/cabbage_seeds.png and /dev/null differ diff --git a/mods/bworld/textures/carrot.png b/mods/bworld/textures/carrot.png index fbfe2cf..dbd2646 100644 Binary files a/mods/bworld/textures/carrot.png and b/mods/bworld/textures/carrot.png differ diff --git a/mods/bworld/textures/carrot_seeds.png b/mods/bworld/textures/carrot_seeds.png deleted file mode 100644 index b256f17..0000000 Binary files a/mods/bworld/textures/carrot_seeds.png and /dev/null differ diff --git a/mods/bworld/textures/cherry_leaves.png b/mods/bworld/textures/cherry_leaves.png new file mode 100644 index 0000000..1d4412f Binary files /dev/null and b/mods/bworld/textures/cherry_leaves.png differ diff --git a/mods/bworld/textures/cherry_log.png b/mods/bworld/textures/cherry_log.png new file mode 100644 index 0000000..dfe8349 Binary files /dev/null and b/mods/bworld/textures/cherry_log.png differ diff --git a/mods/bworld/textures/cherry_log_top.png b/mods/bworld/textures/cherry_log_top.png new file mode 100644 index 0000000..8049d0e Binary files /dev/null and b/mods/bworld/textures/cherry_log_top.png differ diff --git a/mods/bworld/textures/cherry_planks.png b/mods/bworld/textures/cherry_planks.png new file mode 100644 index 0000000..7d9c0e0 Binary files /dev/null and b/mods/bworld/textures/cherry_planks.png differ diff --git a/mods/bworld/textures/coal.png b/mods/bworld/textures/coal.png index 6a72f69..846f775 100644 Binary files a/mods/bworld/textures/coal.png and b/mods/bworld/textures/coal.png differ diff --git a/mods/bworld/textures/copper_axe.png b/mods/bworld/textures/copper_axe.png new file mode 100644 index 0000000..9fb165b Binary files /dev/null and b/mods/bworld/textures/copper_axe.png differ diff --git a/mods/bworld/textures/copper_hoe.png b/mods/bworld/textures/copper_hoe.png new file mode 100644 index 0000000..ce31767 Binary files /dev/null and b/mods/bworld/textures/copper_hoe.png differ diff --git a/mods/bworld/textures/copper_pickaxe.png b/mods/bworld/textures/copper_pickaxe.png new file mode 100644 index 0000000..3924fc5 Binary files /dev/null and b/mods/bworld/textures/copper_pickaxe.png differ diff --git a/mods/bworld/textures/copper_shovel.png b/mods/bworld/textures/copper_shovel.png new file mode 100644 index 0000000..e645a7b Binary files /dev/null and b/mods/bworld/textures/copper_shovel.png differ diff --git a/mods/bworld/textures/dark_oak_leaves.png b/mods/bworld/textures/dark_oak_leaves.png new file mode 100644 index 0000000..6517ab6 Binary files /dev/null and b/mods/bworld/textures/dark_oak_leaves.png differ diff --git a/mods/bworld/textures/dark_oak_log.png b/mods/bworld/textures/dark_oak_log.png new file mode 100644 index 0000000..91ec0f8 Binary files /dev/null and b/mods/bworld/textures/dark_oak_log.png differ diff --git a/mods/bworld/textures/dark_oak_log_top.png b/mods/bworld/textures/dark_oak_log_top.png new file mode 100644 index 0000000..bb1c0cb Binary files /dev/null and b/mods/bworld/textures/dark_oak_log_top.png differ diff --git a/mods/bworld/textures/dark_oak_planks.png b/mods/bworld/textures/dark_oak_planks.png new file mode 100644 index 0000000..98f9a15 Binary files /dev/null and b/mods/bworld/textures/dark_oak_planks.png differ diff --git a/mods/bworld/textures/dirt.png b/mods/bworld/textures/dirt.png index 6f449a5..21b93b7 100644 Binary files a/mods/bworld/textures/dirt.png and b/mods/bworld/textures/dirt.png differ diff --git a/mods/bworld/textures/empty_bucket.png b/mods/bworld/textures/empty_bucket.png deleted file mode 100644 index 5176ea7..0000000 Binary files a/mods/bworld/textures/empty_bucket.png and /dev/null differ diff --git a/mods/bworld/textures/golden_axe.png b/mods/bworld/textures/golden_axe.png new file mode 100644 index 0000000..b27b8b9 Binary files /dev/null and b/mods/bworld/textures/golden_axe.png differ diff --git a/mods/bworld/textures/golden_hoe.png b/mods/bworld/textures/golden_hoe.png new file mode 100644 index 0000000..b4cfb0a Binary files /dev/null and b/mods/bworld/textures/golden_hoe.png differ diff --git a/mods/bworld/textures/golden_pickaxe.png b/mods/bworld/textures/golden_pickaxe.png new file mode 100644 index 0000000..8e591bc Binary files /dev/null and b/mods/bworld/textures/golden_pickaxe.png differ diff --git a/mods/bworld/textures/golden_shovel.png b/mods/bworld/textures/golden_shovel.png new file mode 100644 index 0000000..a61880a Binary files /dev/null and b/mods/bworld/textures/golden_shovel.png differ diff --git a/mods/bworld/textures/grass_block_side.png b/mods/bworld/textures/grass_block_side.png new file mode 100644 index 0000000..58571b5 Binary files /dev/null and b/mods/bworld/textures/grass_block_side.png differ diff --git a/mods/bworld/textures/grass_block_top.png b/mods/bworld/textures/grass_block_top.png new file mode 100644 index 0000000..2f575dd Binary files /dev/null and b/mods/bworld/textures/grass_block_top.png differ diff --git a/mods/bworld/textures/grass_side.png b/mods/bworld/textures/grass_side.png deleted file mode 100644 index 2977b21..0000000 Binary files a/mods/bworld/textures/grass_side.png and /dev/null differ diff --git a/mods/bworld/textures/grass_top.png b/mods/bworld/textures/grass_top.png deleted file mode 100644 index 4682149..0000000 Binary files a/mods/bworld/textures/grass_top.png and /dev/null differ diff --git a/mods/bworld/textures/hoe.png b/mods/bworld/textures/hoe.png deleted file mode 100644 index 29db045..0000000 Binary files a/mods/bworld/textures/hoe.png and /dev/null differ diff --git a/mods/bworld/textures/hoed_dirt.png b/mods/bworld/textures/hoed_dirt.png index 34ad403..28b7526 100644 Binary files a/mods/bworld/textures/hoed_dirt.png and b/mods/bworld/textures/hoed_dirt.png differ diff --git a/mods/bworld/textures/hoed_watered_dirt.png b/mods/bworld/textures/hoed_watered_dirt.png index 3571357..bceb584 100644 Binary files a/mods/bworld/textures/hoed_watered_dirt.png and b/mods/bworld/textures/hoed_watered_dirt.png differ diff --git a/mods/bworld/textures/iron_axe.png b/mods/bworld/textures/iron_axe.png new file mode 100644 index 0000000..f936a00 Binary files /dev/null and b/mods/bworld/textures/iron_axe.png differ diff --git a/mods/bworld/textures/iron_hoe.png b/mods/bworld/textures/iron_hoe.png new file mode 100644 index 0000000..7910505 Binary files /dev/null and b/mods/bworld/textures/iron_hoe.png differ diff --git a/mods/bworld/textures/iron_pickaxe.png b/mods/bworld/textures/iron_pickaxe.png index 60e9e9e..b0f9473 100644 Binary files a/mods/bworld/textures/iron_pickaxe.png and b/mods/bworld/textures/iron_pickaxe.png differ diff --git a/mods/bworld/textures/iron_shovel.png b/mods/bworld/textures/iron_shovel.png new file mode 100644 index 0000000..f569788 Binary files /dev/null and b/mods/bworld/textures/iron_shovel.png differ diff --git a/mods/bworld/textures/jungle_leaves.png b/mods/bworld/textures/jungle_leaves.png new file mode 100644 index 0000000..dacfba4 Binary files /dev/null and b/mods/bworld/textures/jungle_leaves.png differ diff --git a/mods/bworld/textures/jungle_log.png b/mods/bworld/textures/jungle_log.png new file mode 100644 index 0000000..3544c9f Binary files /dev/null and b/mods/bworld/textures/jungle_log.png differ diff --git a/mods/bworld/textures/jungle_log_top.png b/mods/bworld/textures/jungle_log_top.png new file mode 100644 index 0000000..ef392dd Binary files /dev/null and b/mods/bworld/textures/jungle_log_top.png differ diff --git a/mods/bworld/textures/jungle_planks.png b/mods/bworld/textures/jungle_planks.png new file mode 100644 index 0000000..0e333bd Binary files /dev/null and b/mods/bworld/textures/jungle_planks.png differ diff --git a/mods/bworld/textures/key.png b/mods/bworld/textures/key.png deleted file mode 100644 index fc7854c..0000000 Binary files a/mods/bworld/textures/key.png and /dev/null differ diff --git a/mods/bworld/textures/knife.png b/mods/bworld/textures/knife.png deleted file mode 100644 index b6e1a26..0000000 Binary files a/mods/bworld/textures/knife.png and /dev/null differ diff --git a/mods/bworld/textures/log_side.png b/mods/bworld/textures/log_side.png deleted file mode 100644 index 7a9f56c..0000000 Binary files a/mods/bworld/textures/log_side.png and /dev/null differ diff --git a/mods/bworld/textures/log_top.png b/mods/bworld/textures/log_top.png deleted file mode 100644 index 47e1c1a..0000000 Binary files a/mods/bworld/textures/log_top.png and /dev/null differ diff --git a/mods/bworld/textures/milk_bucket.png b/mods/bworld/textures/milk_bucket.png new file mode 100644 index 0000000..f29c328 Binary files /dev/null and b/mods/bworld/textures/milk_bucket.png differ diff --git a/mods/bworld/textures/oak_leaves.png b/mods/bworld/textures/oak_leaves.png new file mode 100644 index 0000000..fe213a3 Binary files /dev/null and b/mods/bworld/textures/oak_leaves.png differ diff --git a/mods/bworld/textures/oak_log.png b/mods/bworld/textures/oak_log.png new file mode 100644 index 0000000..238aa45 Binary files /dev/null and b/mods/bworld/textures/oak_log.png differ diff --git a/mods/bworld/textures/oak_log_top.png b/mods/bworld/textures/oak_log_top.png new file mode 100644 index 0000000..c134503 Binary files /dev/null and b/mods/bworld/textures/oak_log_top.png differ diff --git a/mods/bworld/textures/oak_planks.png b/mods/bworld/textures/oak_planks.png new file mode 100644 index 0000000..407d1e7 Binary files /dev/null and b/mods/bworld/textures/oak_planks.png differ diff --git a/mods/bworld/textures/onion.png b/mods/bworld/textures/onion.png deleted file mode 100644 index 6bb444d..0000000 Binary files a/mods/bworld/textures/onion.png and /dev/null differ diff --git a/mods/bworld/textures/pickaxe.png b/mods/bworld/textures/pickaxe.png deleted file mode 100644 index 98ccead..0000000 Binary files a/mods/bworld/textures/pickaxe.png and /dev/null differ diff --git a/mods/bworld/textures/pitchfork.png b/mods/bworld/textures/pitchfork.png deleted file mode 100644 index 6f46308..0000000 Binary files a/mods/bworld/textures/pitchfork.png and /dev/null differ diff --git a/mods/bworld/textures/planks.png b/mods/bworld/textures/planks.png deleted file mode 100644 index c7de16b..0000000 Binary files a/mods/bworld/textures/planks.png and /dev/null differ diff --git a/mods/bworld/textures/potato.png b/mods/bworld/textures/potato.png index ad88136..01831c7 100644 Binary files a/mods/bworld/textures/potato.png and b/mods/bworld/textures/potato.png differ diff --git a/mods/bworld/textures/potato_seeds.png b/mods/bworld/textures/potato_seeds.png deleted file mode 100644 index ab36283..0000000 Binary files a/mods/bworld/textures/potato_seeds.png and /dev/null differ diff --git a/mods/bworld/textures/sand.png b/mods/bworld/textures/sand.png index 6f03173..7fc254a 100644 Binary files a/mods/bworld/textures/sand.png and b/mods/bworld/textures/sand.png differ diff --git a/mods/bworld/textures/shovel.png b/mods/bworld/textures/shovel.png deleted file mode 100644 index a2ef784..0000000 Binary files a/mods/bworld/textures/shovel.png and /dev/null differ diff --git a/mods/bworld/textures/spruce_leaves.png b/mods/bworld/textures/spruce_leaves.png new file mode 100644 index 0000000..305cea6 Binary files /dev/null and b/mods/bworld/textures/spruce_leaves.png differ diff --git a/mods/bworld/textures/spruce_log.png b/mods/bworld/textures/spruce_log.png new file mode 100644 index 0000000..29de114 Binary files /dev/null and b/mods/bworld/textures/spruce_log.png differ diff --git a/mods/bworld/textures/spruce_log_top.png b/mods/bworld/textures/spruce_log_top.png new file mode 100644 index 0000000..e5fe25c Binary files /dev/null and b/mods/bworld/textures/spruce_log_top.png differ diff --git a/mods/bworld/textures/spruce_planks.png b/mods/bworld/textures/spruce_planks.png new file mode 100644 index 0000000..ade9efd Binary files /dev/null and b/mods/bworld/textures/spruce_planks.png differ diff --git a/mods/bworld/textures/stone_axe.png b/mods/bworld/textures/stone_axe.png new file mode 100644 index 0000000..f164b16 Binary files /dev/null and b/mods/bworld/textures/stone_axe.png differ diff --git a/mods/bworld/textures/stone_hoe.png b/mods/bworld/textures/stone_hoe.png new file mode 100644 index 0000000..ff13556 Binary files /dev/null and b/mods/bworld/textures/stone_hoe.png differ diff --git a/mods/bworld/textures/stone_pickaxe.png b/mods/bworld/textures/stone_pickaxe.png index 98ccead..a115787 100644 Binary files a/mods/bworld/textures/stone_pickaxe.png and b/mods/bworld/textures/stone_pickaxe.png differ diff --git a/mods/bworld/textures/stone_shovel.png b/mods/bworld/textures/stone_shovel.png new file mode 100644 index 0000000..407e680 Binary files /dev/null and b/mods/bworld/textures/stone_shovel.png differ diff --git a/mods/bworld/textures/straw.png b/mods/bworld/textures/straw.png deleted file mode 100644 index 2cd2b42..0000000 Binary files a/mods/bworld/textures/straw.png and /dev/null differ diff --git a/mods/bworld/textures/sword.png b/mods/bworld/textures/sword.png deleted file mode 100644 index 0f227cc..0000000 Binary files a/mods/bworld/textures/sword.png and /dev/null differ diff --git a/mods/bworld/textures/tomato.png b/mods/bworld/textures/tomato.png deleted file mode 100644 index 9f080ea..0000000 Binary files a/mods/bworld/textures/tomato.png and /dev/null differ diff --git a/mods/bworld/textures/tomato_seeds.png b/mods/bworld/textures/tomato_seeds.png deleted file mode 100644 index 33c7e3c..0000000 Binary files a/mods/bworld/textures/tomato_seeds.png and /dev/null differ diff --git a/mods/bworld/textures/water_bucket.png b/mods/bworld/textures/water_bucket.png index ea9d33f..15b58d2 100644 Binary files a/mods/bworld/textures/water_bucket.png and b/mods/bworld/textures/water_bucket.png differ diff --git a/mods/bworld/textures/wood_axe.png b/mods/bworld/textures/wood_axe.png new file mode 100644 index 0000000..37d1799 Binary files /dev/null and b/mods/bworld/textures/wood_axe.png differ diff --git a/mods/bworld/textures/wood_hoe.png b/mods/bworld/textures/wood_hoe.png new file mode 100644 index 0000000..0c0e1ce Binary files /dev/null and b/mods/bworld/textures/wood_hoe.png differ diff --git a/mods/bworld/textures/wood_pickaxe.png b/mods/bworld/textures/wood_pickaxe.png index cf2fe8e..ac0d644 100644 Binary files a/mods/bworld/textures/wood_pickaxe.png and b/mods/bworld/textures/wood_pickaxe.png differ diff --git a/mods/bworld/textures/wood_shovel.png b/mods/bworld/textures/wood_shovel.png new file mode 100644 index 0000000..e6a0084 Binary files /dev/null and b/mods/bworld/textures/wood_shovel.png differ diff --git a/mods/recipe_viewer/scripts/client.ts b/mods/recipe_viewer/scripts/client.ts index 131a02d..3669f4b 100644 --- a/mods/recipe_viewer/scripts/client.ts +++ b/mods/recipe_viewer/scripts/client.ts @@ -220,8 +220,12 @@ class RecipeViewer { for (let row = 0; row < 3; row++) { for (let column = 0; column < 3; column++) { const letter = recipe.pattern[row]?.[column]; - const id = letter && letter !== " " && column < width_in ? recipe.key[letter] : undefined; - cell(id ? { ids: [id], count: 1 } : undefined, x + column * CELL, top + row * CELL); + const choice = letter && letter !== " " && column < width_in ? recipe.key[letter] : undefined; + cell( + choice ? { ids: choice_ids(choice), count: 1 } : undefined, + x + column * CELL, + top + row * CELL, + ); } } texture("bworld:arrow_full", x + 3.5 * CELL, top + CELL); @@ -229,14 +233,14 @@ class RecipeViewer { break; } case "furnace": - cell({ ids: [recipe.input], count: 1 }, x, top); + cell({ ids: choice_ids(recipe.input), count: 1 }, x, top); texture("bworld:fire_full", x, top + CELL); texture("bworld:arrow_full", x + 1.5 * CELL, top + CELL / 2); cell(stack(recipe.output), x + 3 * CELL, top + CELL / 2); g.text(seconds(recipe.cook_time), x + 1.5 * CELL, top + CELL * 1.5, { color: LABEL_COLOR }); break; case "fuel": - cell({ ids: [recipe.item], count: 1 }, x, top); + cell({ ids: choice_ids(recipe.item), count: 1 }, x, top); texture("bworld:fire_full", x, top + CELL); g.text(`Burns for ${seconds(recipe.burn_time)}`, x + 1.5 * CELL, top + CELL / 2, { color: LABEL_COLOR, @@ -296,6 +300,11 @@ function paginate(recipes: Recipe[], height: number): Recipe[][] { return pages; } +// shaped keys, furnace inputs and fuels can be one item or a list any of which fits +function choice_ids(choice: string | string[]): string[] { + return typeof choice === "string" ? [choice] : choice; +} + // what a recipe makes export function outputs(recipe: Recipe): Ingredient[] { switch (recipe.type) { @@ -320,11 +329,14 @@ export function outputs(recipe: Recipe): Ingredient[] { export function inputs(recipe: Recipe): Ingredient[] { switch (recipe.type) { case "shaped": - return Object.values(recipe.key as Record).map((id) => ({ ids: [id], count: 1 })); + return Object.values(recipe.key as Record).map((choice) => ({ + ids: choice_ids(choice), + count: 1, + })); case "furnace": - return [{ ids: [recipe.input], count: 1 }]; + return [{ ids: choice_ids(recipe.input), count: 1 }]; case "fuel": - return [{ ids: [recipe.item], count: 1 }]; + return [{ ids: choice_ids(recipe.item), count: 1 }]; case "smithing": return [{ ids: [recipe.tool], count: 1 }, stack(recipe.material)].concat( recipe.addition ? [{ ids: [recipe.addition], count: 1 }] : [], diff --git a/server/game/crafting.ts b/server/game/crafting.ts index 4492432..f6ffcf0 100644 --- a/server/game/crafting.ts +++ b/server/game/crafting.ts @@ -1,6 +1,6 @@ import { Container, ItemStack } from "$/common/inventory.ts"; import { CRAFTING_RESULT_SLOT } from "$/common/protocol.ts"; -import type { GridRecipe } from "$/common/mod_data.ts"; +import { choice_ids, type GridRecipe } from "$/common/mod_data.ts"; // recipes come from mods, see RecipeBook in common/mod_loader.ts @@ -23,7 +23,13 @@ function matches_recipe(grid: (string | undefined)[], recipe: GridRecipe): boole if (gx >= x && gx < x + recipe.width && gy >= y && gy < y + recipe.height) { const recipe_index = (gy - y) * recipe.width + (gx - x); - if (grid[grid_index] !== recipe.pattern[recipe_index]) { + const choice = recipe.pattern[recipe_index]; + const item = grid[grid_index]; + if ( + choice === undefined + ? item !== undefined + : item === undefined || !choice_ids(choice).includes(item) + ) { match = false; break; } diff --git a/tests/base_game_test.ts b/tests/base_game_test.ts index 548a46d..12f3955 100644 --- a/tests/base_game_test.ts +++ b/tests/base_game_test.ts @@ -37,10 +37,10 @@ function move_to_screen(t: Game, from: number, to: number) { } Deno.test("a hoe turns grass and dirt into hoed dirt, anything else places nothing", async () => { - const t = await setup([["bworld:hoe", 1]]); + const t = await setup([["bworld:wood_hoe", 1]]); t.game.set_block(1, 100, 0, "bworld:grass"); t.game.set_block(2, 100, 0, "bworld:dirt"); - t.send(1, { type: "select_slot", slot: slot_of(t.take(1), "bworld:hoe") }); + t.send(1, { type: "select_slot", slot: slot_of(t.take(1), "bworld:wood_hoe") }); t.send(1, { type: "use_block", x: 1, y: 100, z: 0, face: "top" }); t.send(1, { type: "use_block", x: 2, y: 100, z: 0, face: "top" }); diff --git a/tests/bmod_test.ts b/tests/bmod_test.ts index 9750622..1bfdb08 100644 --- a/tests/bmod_test.ts +++ b/tests/bmod_test.ts @@ -41,7 +41,7 @@ Deno.test("packing a mod keeps its data, scripts, textures and credits, and give assert(bmod.credits); const bworld = read_bmod(Deno.readFileSync(`${folder}/bworld.bmod`), "bworld.bmod"); - assertEquals(bworld.data.blocks.length, 23); + assertEquals(bworld.data.blocks.length, 41); assertEquals(Object.keys(bworld.scripts), ["server"]); Deno.removeSync(sources, { recursive: true }); diff --git a/tests/farming_test.ts b/tests/farming_test.ts index 25021f0..3dea126 100644 --- a/tests/farming_test.ts +++ b/tests/farming_test.ts @@ -41,12 +41,12 @@ async function setup(items: string[] = []) { } Deno.test("hoe, fill the can, plant, water, and the crop grows the next morning", async () => { - const t = await setup(["bworld:hoe", "bworld:watering_can", "bworld:wheat_seeds 4"]); + const t = await setup(["bworld:wood_hoe", "bworld:watering_can", "bworld:wheat_seeds 4"]); t.game.set_block(1, 100, 0, "bworld:grass"); t.game.set_block(0, 100, 1, "bworld:grass"); t.game.set_block(2, 100, 0, "bworld:water"); - t.hold("bworld:hoe"); + t.hold("bworld:wood_hoe"); t.use(1, 100, 0); assertEquals(t.game.world.get_block_id(1, 100, 0), "bworld:hoed_dirt"); diff --git a/tests/mod_loading_test.ts b/tests/mod_loading_test.ts index 9492789..d09e697 100644 --- a/tests/mod_loading_test.ts +++ b/tests/mod_loading_test.ts @@ -24,13 +24,15 @@ const inventory_of = (messages: Msg[]) => Deno.test("the base game loads from mods/bworld", async () => { const { game } = await test_game("mods"); const bworld = (entries: [string, unknown][]) => entries.filter(([id]) => id.startsWith("bworld:")).length; - assertEquals(bworld(EverythingRegistry.entries("blocks")), 23); - // 18 items plus the item forms of the 18 blocks that have one - assertEquals(bworld(EverythingRegistry.entries("items")), 36); - // the bowl is bworld's 6th, the cooking pot and stove are farmersdelight's - assertEquals(game.recipes.shaped.length, 8); - assertEquals(game.recipes.furnace.size, 6); - assertEquals(game.recipes.fuel.size, 2); + // 7 kinds of log, planks and leaves + assertEquals(bworld(EverythingRegistry.entries("blocks")), 41); + // 33 items (20 of them tools) plus the item forms of the 36 blocks that have one + assertEquals(bworld(EverythingRegistry.entries("items")), 69); + // bworld's 15 (4 wood tools, 7 planks), the cooking pot and stove are farmersdelight's + assertEquals(game.recipes.shaped.length, 17); + // every log smelts and burns + assertEquals(game.recipes.furnace.size, 12); + assertEquals(game.recipes.fuel.size, 8); assertEquals(EverythingRegistry.get("blocks", "bworld:water")?.replaceable, true); // still has its code until it's a component assert(EverythingRegistry.get("items", "bworld:watering_can")?.on_create); @@ -219,3 +221,20 @@ Deno.test("broken mods stop the game from starting", async () => { assert(error.includes("uses component copper_tools:announce, which nothing registered"), error); Deno.removeSync(dir, { recursive: true }); }); + +Deno.test("every tier of pickaxe, axe, shovel and hoe exists and can be made", async () => { + const { game } = await test_game("mods"); + const made = new Set([ + ...game.recipes.shaped.map((recipe) => recipe.result.id), + ...game.recipes.smithing.map((recipe) => recipe.result), + ]); + for (const tier of ["wood", "stone", "copper", "iron", "golden"]) { + for (const tool of ["pickaxe", "axe", "shovel", "hoe"]) { + const id = `bworld:${tier}_${tool}`; + const item = EverythingRegistry.get("items", id); + assertEquals(item?.tool_type, tool, id); + assertEquals(item?.texture_id, id); + assert(made.has(id), `nothing makes ${id}`); + } + } +}); diff --git a/tests/terrain_culling_test.ts b/tests/terrain_culling_test.ts index 24f37ac..f2c1af1 100644 --- a/tests/terrain_culling_test.ts +++ b/tests/terrain_culling_test.ts @@ -76,7 +76,15 @@ async function mesh_chunks(radius: number) { for (let dx = -1; dx <= 1; dx++) chunks.push(generated.get(`${x + dx},${z + dz}`)!.slice()); } meshes.push( - await ask({ type: "mesh", chunk_x: x, chunk_z: z, version: 1, chunks, camera: [0, 0, 0] }, "meshed"), + await ask({ + type: "mesh", + chunk_x: x, + chunk_z: z, + version: 1, + chunks, + biome_colors: chunks.map(() => null), + camera: [0, 0, 0], + }, "meshed"), ); } } diff --git a/tests/tint_test.ts b/tests/tint_test.ts new file mode 100644 index 0000000..46d03ca --- /dev/null +++ b/tests/tint_test.ts @@ -0,0 +1,120 @@ +// blocks with a "tint" are drawn in their biome's grass or foliage color, blended across biome edges, or a fixed one +import { assert, assertEquals } from "@std/assert"; +import { BlockRegistry, EverythingRegistry } from "$/common/everything_registry.ts"; +import { CHUNK_AREA, CHUNK_HEIGHT, CHUNK_SIZE } from "$/common/constants.ts"; +import { generate_raw_chunk } from "$/common/generation.ts"; +import { BIOME_FOLIAGE_COLORS, BIOME_GRASS_COLORS } from "$/common/worldgen/biome_colors.ts"; +import { type LayerMesh, TERRAIN_VERTEX_BYTES } from "$/client/workers/chunk_messages.ts"; +import { test_game } from "./helpers.ts"; + +type Colors = { grass: number; foliage: number }; + +// one block at x, 10, 8 of the middle chunk, meshed with these biome colors for the middle chunk and the one to its +// -x side (the others aren't there). returns the colors of the quads on its top and on its sides +async function mesh_block(id: string, x: number, middle: Colors, west: Colors | null) { + await test_game("mods"); + const blocks = EverythingRegistry.get_registry("blocks"); + const block_ids: Record = {}; + blocks.forEach((b, nid) => block_ids[b.id] = nid); + const worker = new Worker(new URL("../client/workers/chunk_worker.ts", import.meta.url).href, { type: "module" }); + worker.postMessage({ + type: "init", + blocks_registry: JSON.parse(JSON.stringify(blocks)), + block_ids, + models: {}, + textures_info: { "engine:missing": { x: 0, y: 0 } }, + image: { width: 1024, height: 1024 }, + worldgen_scripts: [], + ores: [], + }); + + const chunk = new Uint32Array(CHUNK_AREA * CHUNK_HEIGHT); + chunk[10 * CHUNK_AREA + 8 * CHUNK_SIZE + x] = block_ids[id]; + const empty = () => new Uint32Array(CHUNK_AREA * CHUNK_HEIGHT); + const chunks = [empty(), empty(), empty(), empty(), chunk, empty(), empty(), empty(), empty()]; + const colors = chunks.map(() => null as Uint32Array | null); + const biome_colors = ({ grass, foliage }: Colors) => { + const array = new Uint32Array(CHUNK_AREA * 2); + array.fill(grass, 0, CHUNK_AREA); + array.fill(foliage, CHUNK_AREA); + return array; + }; + colors[4] = biome_colors(middle); + if (west) colors[3] = biome_colors(west); + + const meshed = await new Promise<{ solid: LayerMesh; cutout: LayerMesh }>((resolve) => { + worker.onmessage = (e) => resolve(e.data); + worker.postMessage({ + type: "mesh", + chunk_x: 0, + chunk_z: 0, + version: 1, + chunks, + biome_colors: colors, + camera: [0, 0, 0], + }); + }); + worker.terminate(); + + const top: number[][] = []; + const sides: number[][] = []; + for (const mesh of [meshed.solid, meshed.cutout]) { + const f32 = new Float32Array(mesh.vertices.buffer); + for (let quad = 0; quad < mesh.quad_count; quad++) { + const byte = quad * 4 * TERRAIN_VERTEX_BYTES; + const ys = [0, 1, 2, 3].map((k) => f32[(byte + k * TERRAIN_VERTEX_BYTES) / 4 + 1]); + const rgb = [...mesh.vertices.subarray(byte + 16, byte + 19)]; + if (ys.every((y) => y === 11)) top.push(rgb); + else if (!ys.every((y) => y === 10)) sides.push(rgb); + } + } + return { top, sides }; +} + +// the vertex color of an unlit face: the color times the face's directional shade, 1 on top and 0.8 north and south +const shaded = (color: number, shade: number) => + [color >> 16, (color >> 8) & 0xff, color & 0xff].map((c) => Math.round(shade * c)); + +Deno.test("the grass block's top is its biome's grass color, and only the top", async () => { + const { top, sides } = await mesh_block("bworld:grass", 8, { grass: 0xff8000, foliage: 0x0000ff }, null); + assertEquals(top, [[255, 128, 0]]); + assertEquals(sides.length, 4); + for (const [r, g, b] of sides) assert(r === g && g === b, "sides aren't tinted"); +}); + +Deno.test("biome colors blend over the 5x5 columns around, across chunk edges", async () => { + // at x 0 the two columns to its -x are in the other chunk: 10 of the 25 are blue, 15 red + const { top } = await mesh_block("bworld:grass", 0, { grass: 0xff0000, foliage: 0 }, { + grass: 0x0000ff, + foliage: 0, + }); + assertEquals(top, [[153, 0, 102]]); +}); + +Deno.test("oak leaves are the biome's foliage color on every side, birch a fixed green, spruce isn't tinted", async () => { + const colors = { grass: 0xff0000, foliage: 0x00ff80 }; + const oak = await mesh_block("bworld:leaves", 8, colors, null); + assertEquals(oak.top, [[0, 255, 128]]); + assert(oak.sides.some((rgb) => JSON.stringify(rgb) === JSON.stringify(shaded(0x00ff80, 0.8)))); + + const birch = await mesh_block("bworld:birch_leaves", 8, colors, null); + assertEquals(birch.top, [shaded(0x80a755, 1)]); + + const spruce = await mesh_block("bworld:spruce_leaves", 8, colors, null); + assertEquals(spruce.top, [[255, 255, 255]]); +}); + +Deno.test("every column the overworld generates has a biome with grass and foliage colors", async () => { + const { game } = await test_game("mods"); + const blocks = EverythingRegistry.get_registry("blocks"); + const block_ids: Record = {}; + blocks.forEach((b, nid) => block_ids[b.id] = nid); + for (const [x, z] of [[0, 0], [30, -12], [-80, 45]]) { + const { biomes } = generate_raw_chunk(x, z, game.world.seed, block_ids); + assertEquals(biomes.length, CHUNK_AREA); + for (const biome of biomes) { + assert(biome in BIOME_GRASS_COLORS, `${biome} has no grass color`); + assert(biome in BIOME_FOLIAGE_COLORS, `${biome} has no foliage color`); + } + } +}); diff --git a/tests/wood_test.ts b/tests/wood_test.ts new file mode 100644 index 0000000..e712683 --- /dev/null +++ b/tests/wood_test.ts @@ -0,0 +1,78 @@ +import { assert, assertEquals } from "@std/assert"; +import { CHUNK_AREA, CHUNK_SIZE } from "$/common/constants.ts"; +import { Container, ItemStack } from "$/common/inventory.ts"; +import { CRAFTING_RESULT_SLOT } from "$/common/protocol.ts"; +import { generate_raw_chunk } from "$/common/generation.ts"; +import { BIOME_TREES, tree_wood } from "$/common/worldgen/trees.ts"; +import { update_crafting_result } from "$/server/game/crafting.ts"; +import { test_game } from "./helpers.ts"; + +Deno.test("recipes that take planks take any kind, even mixed, but nothing else", async () => { + const { game } = await test_game("mods"); + const craft = (top: string, bottom: string) => { + const grid = new Container(10); + grid.set_item(0, new ItemStack(top, 1)); + grid.set_item(3, new ItemStack(bottom, 1)); + update_crafting_result(grid, game.recipes.shaped); + return grid.get_item(CRAFTING_RESULT_SLOT); + }; + assertEquals(craft("bworld:planks", "bworld:planks")?.type_id, "bworld:stick"); + assertEquals(craft("bworld:birch_planks", "bworld:cherry_planks")?.type_id, "bworld:stick"); + assertEquals(craft("bworld:birch_planks", "bworld:stone"), undefined); + + // and each log makes its own planks + const grid = new Container(10); + grid.set_item(4, new ItemStack("bworld:dark_oak_log", 1)); + update_crafting_result(grid, game.recipes.shaped); + assertEquals(grid.get_item(CRAFTING_RESULT_SLOT)?.type_id, "bworld:dark_oak_planks"); + + // every log burns and smelts + for (const log of ["bworld:log", "bworld:spruce_log", "bworld:cherry_log"]) { + assert(game.recipes.fuel.has(log), log); + assert(game.recipes.furnace.has(log), log); + } +}); + +Deno.test("trees grow the wood of their kind and biome", async () => { + const { game } = await test_game("mods"); + const ids = game.world.block_ids; + const woods: Record = { + "bworld:log": "oak", + "bworld:spruce_log": "spruce", + "bworld:birch_log": "birch", + "bworld:jungle_log": "jungle", + "bworld:acacia_log": "acacia", + "bworld:dark_oak_log": "dark_oak", + }; + const wood_of = new Map(Object.entries(woods).map(([id, wood]) => [ids[id], wood])); + const ground = new Set([ids["bworld:grass"], ids["bworld:dirt"], ids["bworld:snow"]]); + + const leaves_of = new Map( + Object.entries(woods).map(([id, wood]) => [ids[id.replace("log", "leaves")], wood]), + ); + const found = new Set(); + const found_leaves = new Set(); + for (let cx = -8; cx < 8; cx++) { + for (let cz = -8; cz < 8; cz++) { + const { blocks, biomes } = generate_raw_chunk(cx, cz, "wood-test", ids); + blocks.forEach((block, i) => { + const leaves = leaves_of.get(block); + if (leaves) found_leaves.add(leaves); + const wood = wood_of.get(block); + // the bottom of a trunk + if (!wood || !ground.has(blocks[i - CHUNK_AREA])) return; + const column = i % CHUNK_AREA; + const biome = biomes[column]; + const allowed = BIOME_TREES[biome].kinds.map((kind) => tree_wood(kind, biome)); + assert( + allowed.includes(wood as never), + `${wood} in ${biome} at ${cx * CHUNK_SIZE}, ${cz * CHUNK_SIZE}`, + ); + found.add(wood); + }); + } + } + assert(found.size >= 3, `only found ${[...found]}`); + // each tree's leaves are its own wood's + assertEquals([...found_leaves].sort(), [...found].sort()); +}); diff --git a/tests/worldgen_test.ts b/tests/worldgen_test.ts index 8a8e93b..bab05c0 100644 --- a/tests/worldgen_test.ts +++ b/tests/worldgen_test.ts @@ -42,7 +42,12 @@ Deno.test("new players spawn on dry land, all in the same place", async () => { Deno.test("trees grow on the ground, never closer than 4 blocks, even across chunk borders", async () => { const { game } = await test_game("mods"); const ids = game.world.block_ids; - const log = ids["bworld:log"]; + const id_names = Object.fromEntries(Object.entries(ids).map(([name, id]) => [id, name])); + const logs = new Set( + ["log", "spruce_log", "birch_log", "jungle_log", "acacia_log", "dark_oak_log", "cherry_log"].map((name) => + ids[`bworld:${name}`] + ), + ); const ground = new Set([ids["bworld:grass"], ids["bworld:dirt"], ids["bworld:snow"]]); // the bottom log of every trunk, in world coordinates @@ -52,14 +57,14 @@ Deno.test("trees grow on the ground, never closer than 4 blocks, even across chu for (let cz = -6; cz < 6; cz++) { const { blocks, spills } = generate_raw_chunk(cx, cz, "trees-test", ids); blocks.forEach((block, i) => { - if (block === log && ground.has(blocks[i - CHUNK_AREA])) { + if (logs.has(block) && ground.has(blocks[i - CHUNK_AREA])) { const x = cx * 16 + (i % 16); const z = cz * 16 + Math.floor(i / 16) % 16; trunks.push([x, z]); } }); for (let i = 3; i < spills.length; i += 4) { - if (spills[i] === ids["bworld:leaves"]) spilled_leaves++; + if (id_names[spills[i]]?.endsWith("leaves")) spilled_leaves++; } } }