From 7e5bcaa239b0e5a2736e21fb3e6664a036fae9cd Mon Sep 17 00:00:00 2001 From: Paula Date: Sat, 26 Sep 2026 21:35:17 -0300 Subject: [PATCH] Add a bunch of crops and farmer's delight crops --- MODS.md | 58 ++++++- client/game_mode.ts | 24 +-- common/everything_registry.ts | 2 + common/mod_api/server.ts | 2 + common/mod_check.ts | 4 +- common/mod_data.ts | 13 +- common/utils.ts | 25 +++ mods/bworld/blocks/carrots.json | 60 +++++++ mods/bworld/blocks/potatoes.json | 60 +++++++ mods/bworld/blocks/wheat.json | 21 ++- mods/bworld/items/carrot.json | 3 +- mods/bworld/items/potato.json | 3 +- mods/bworld/scripts/server.ts | 158 ++++++++++++++---- mods/bworld/textures/carrot_stage_0.png | Bin 0 -> 192 bytes mods/bworld/textures/carrot_stage_1.png | Bin 0 -> 202 bytes mods/bworld/textures/carrot_stage_2.png | Bin 0 -> 212 bytes mods/bworld/textures/carrot_stage_3.png | Bin 0 -> 240 bytes mods/bworld/textures/potatoes_stage_0.png | Bin 0 -> 134 bytes mods/bworld/textures/potatoes_stage_1.png | Bin 0 -> 150 bytes mods/bworld/textures/potatoes_stage_2.png | Bin 0 -> 146 bytes mods/bworld/textures/potatoes_stage_3.png | Bin 0 -> 185 bytes mods/farmersdelight/CREDITS.md | 28 ++++ mods/farmersdelight/blocks/cabbages.json | 80 +++++++++ mods/farmersdelight/blocks/onions.json | 60 +++++++ mods/farmersdelight/blocks/rice.json | 76 +++++++++ mods/farmersdelight/blocks/rice_panicles.json | 56 +++++++ mods/farmersdelight/blocks/tomatoes.json | 90 ++++++++++ mods/farmersdelight/items/cabbage.json | 11 ++ mods/farmersdelight/items/cabbage_seeds.json | 8 + mods/farmersdelight/items/onion.json | 12 ++ mods/farmersdelight/items/rice.json | 8 + mods/farmersdelight/items/rice_panicle.json | 7 + mods/farmersdelight/items/tomato.json | 11 ++ mods/farmersdelight/items/tomato_seeds.json | 8 + mods/farmersdelight/manifest.json | 19 +++ .../textures/budding_tomatoes_stage0.png | Bin 0 -> 151 bytes .../textures/budding_tomatoes_stage1.png | Bin 0 -> 207 bytes .../textures/budding_tomatoes_stage2.png | Bin 0 -> 290 bytes .../textures/budding_tomatoes_stage3.png | Bin 0 -> 342 bytes mods/farmersdelight/textures/cabbage.png | Bin 0 -> 417 bytes .../farmersdelight/textures/cabbage_seeds.png | Bin 0 -> 236 bytes .../textures/cabbages_stage0.png | Bin 0 -> 123 bytes .../textures/cabbages_stage1.png | Bin 0 -> 152 bytes .../textures/cabbages_stage2.png | Bin 0 -> 157 bytes .../textures/cabbages_stage3.png | Bin 0 -> 226 bytes .../textures/cabbages_stage4.png | Bin 0 -> 286 bytes .../textures/cabbages_stage5.png | Bin 0 -> 297 bytes .../textures/cabbages_stage6.png | Bin 0 -> 318 bytes .../textures/cabbages_stage7.png | Bin 0 -> 399 bytes mods/farmersdelight/textures/onion.png | Bin 0 -> 383 bytes .../farmersdelight/textures/onions_stage0.png | Bin 0 -> 125 bytes .../farmersdelight/textures/onions_stage1.png | Bin 0 -> 168 bytes .../farmersdelight/textures/onions_stage2.png | Bin 0 -> 235 bytes .../farmersdelight/textures/onions_stage3.png | Bin 0 -> 325 bytes mods/farmersdelight/textures/rice.png | Bin 0 -> 411 bytes mods/farmersdelight/textures/rice_panicle.png | Bin 0 -> 394 bytes .../textures/rice_panicles_stage0.png | Bin 0 -> 174 bytes .../textures/rice_panicles_stage1.png | Bin 0 -> 296 bytes .../textures/rice_panicles_stage2.png | Bin 0 -> 433 bytes .../textures/rice_panicles_stage3.png | Bin 0 -> 568 bytes mods/farmersdelight/textures/rice_stage0.png | Bin 0 -> 123 bytes mods/farmersdelight/textures/rice_stage1.png | Bin 0 -> 200 bytes mods/farmersdelight/textures/rice_stage2.png | Bin 0 -> 324 bytes mods/farmersdelight/textures/rice_stage3.png | Bin 0 -> 362 bytes .../textures/rice_supporting.png | Bin 0 -> 473 bytes mods/farmersdelight/textures/tomato.png | Bin 0 -> 361 bytes mods/farmersdelight/textures/tomato_seeds.png | Bin 0 -> 288 bytes .../textures/tomatoes_stage0.png | Bin 0 -> 395 bytes .../textures/tomatoes_stage1.png | Bin 0 -> 448 bytes .../textures/tomatoes_stage2.png | Bin 0 -> 443 bytes .../textures/tomatoes_stage3.png | Bin 0 -> 509 bytes server/game/game_server.ts | 39 +++-- server/game/mod_runtime.ts | 5 + tests/bmod_test.ts | 2 +- tests/farming_test.ts | 99 +++++++++++ tests/handshake_test.ts | 2 +- tests/mod_loading_test.ts | 7 +- 77 files changed, 980 insertions(+), 81 deletions(-) create mode 100644 mods/bworld/blocks/carrots.json create mode 100644 mods/bworld/blocks/potatoes.json create mode 100644 mods/bworld/textures/carrot_stage_0.png create mode 100644 mods/bworld/textures/carrot_stage_1.png create mode 100644 mods/bworld/textures/carrot_stage_2.png create mode 100644 mods/bworld/textures/carrot_stage_3.png create mode 100644 mods/bworld/textures/potatoes_stage_0.png create mode 100644 mods/bworld/textures/potatoes_stage_1.png create mode 100644 mods/bworld/textures/potatoes_stage_2.png create mode 100644 mods/bworld/textures/potatoes_stage_3.png create mode 100644 mods/farmersdelight/CREDITS.md create mode 100644 mods/farmersdelight/blocks/cabbages.json create mode 100644 mods/farmersdelight/blocks/onions.json create mode 100644 mods/farmersdelight/blocks/rice.json create mode 100644 mods/farmersdelight/blocks/rice_panicles.json create mode 100644 mods/farmersdelight/blocks/tomatoes.json create mode 100644 mods/farmersdelight/items/cabbage.json create mode 100644 mods/farmersdelight/items/cabbage_seeds.json create mode 100644 mods/farmersdelight/items/onion.json create mode 100644 mods/farmersdelight/items/rice.json create mode 100644 mods/farmersdelight/items/rice_panicle.json create mode 100644 mods/farmersdelight/items/tomato.json create mode 100644 mods/farmersdelight/items/tomato_seeds.json create mode 100644 mods/farmersdelight/manifest.json create mode 100644 mods/farmersdelight/textures/budding_tomatoes_stage0.png create mode 100644 mods/farmersdelight/textures/budding_tomatoes_stage1.png create mode 100644 mods/farmersdelight/textures/budding_tomatoes_stage2.png create mode 100644 mods/farmersdelight/textures/budding_tomatoes_stage3.png create mode 100644 mods/farmersdelight/textures/cabbage.png create mode 100644 mods/farmersdelight/textures/cabbage_seeds.png create mode 100644 mods/farmersdelight/textures/cabbages_stage0.png create mode 100644 mods/farmersdelight/textures/cabbages_stage1.png create mode 100644 mods/farmersdelight/textures/cabbages_stage2.png create mode 100644 mods/farmersdelight/textures/cabbages_stage3.png create mode 100644 mods/farmersdelight/textures/cabbages_stage4.png create mode 100644 mods/farmersdelight/textures/cabbages_stage5.png create mode 100644 mods/farmersdelight/textures/cabbages_stage6.png create mode 100644 mods/farmersdelight/textures/cabbages_stage7.png create mode 100644 mods/farmersdelight/textures/onion.png create mode 100644 mods/farmersdelight/textures/onions_stage0.png create mode 100644 mods/farmersdelight/textures/onions_stage1.png create mode 100644 mods/farmersdelight/textures/onions_stage2.png create mode 100644 mods/farmersdelight/textures/onions_stage3.png create mode 100644 mods/farmersdelight/textures/rice.png create mode 100644 mods/farmersdelight/textures/rice_panicle.png create mode 100644 mods/farmersdelight/textures/rice_panicles_stage0.png create mode 100644 mods/farmersdelight/textures/rice_panicles_stage1.png create mode 100644 mods/farmersdelight/textures/rice_panicles_stage2.png create mode 100644 mods/farmersdelight/textures/rice_panicles_stage3.png create mode 100644 mods/farmersdelight/textures/rice_stage0.png create mode 100644 mods/farmersdelight/textures/rice_stage1.png create mode 100644 mods/farmersdelight/textures/rice_stage2.png create mode 100644 mods/farmersdelight/textures/rice_stage3.png create mode 100644 mods/farmersdelight/textures/rice_supporting.png create mode 100644 mods/farmersdelight/textures/tomato.png create mode 100644 mods/farmersdelight/textures/tomato_seeds.png create mode 100644 mods/farmersdelight/textures/tomatoes_stage0.png create mode 100644 mods/farmersdelight/textures/tomatoes_stage1.png create mode 100644 mods/farmersdelight/textures/tomatoes_stage2.png create mode 100644 mods/farmersdelight/textures/tomatoes_stage3.png diff --git a/MODS.md b/MODS.md index 358a0e1..ab65300 100644 --- a/MODS.md +++ b/MODS.md @@ -26,7 +26,7 @@ bworld's modding takes from three places: - [Mod layout](#mod-layout) - [manifest.json](#manifestjson) - [Identifiers](#identifiers) -- Data: [Textures](#textures), [Blocks](#blocks), [Block models](#block-models), [Items](#items), +- Data: [Textures](#textures), [Blocks](#blocks), [Block models](#block-models), [Crops](#crops), [Items](#items), [Recipes](#recipes), [Overrides](#overrides) - Game API: [Common scripts](#common-scripts), [Server scripts](#server-scripts), [Client scripts](#client-scripts), [GUIs](#guis), [Mod channels](#mod-channels), [World generation](#world-generation) @@ -250,6 +250,7 @@ program**, so the server and each client can number blocks differently. Saves an | `item` | `true` | `register_block_item` | Also register an item that places this block, with the same id. | | `interactive` | `false` | `interactive` | Right clicking it does something (opens a screen), so clients don't guess it places a block. | | `replaceable` | `false` | new | Placing a block into it replaces it, like water. | +| `place_in` | see meaning | `place_in` | Block ids it can be placed into, replacing them, like `["bworld:water"]` for rice. Air and `replaceable` blocks when not set. | | `place_on` | anywhere | `place_on` | Block ids it can stand on, like `["bworld:hoed_dirt"]` for crops. Players can't place it anywhere else, and it breaks (with its drops) when the block under it becomes something else, like Minecraft's `canSurvive`. | | `states` | none | `states` | Up to 16 bits of named state, like `hoed_dirt` has now. | | `components` | none | `components` | Custom components with parameters, handled by server scripts. | @@ -338,6 +339,60 @@ texture per face. `models/slab.json`: Faces flat against the block's edge get smooth lighting and ambient occlusion like a full block's. Anything inside the block is lit evenly with the block's own light. +## Crops + +Like a Fabric `CropBlock`, a crop is a block with an `age` state and a seeds item that places it, so adding one is only +data. The base game's `bworld:crop` component (in `mods/bworld/scripts/server.ts`) does the growing, with Stardew +Valley's clock: every morning at 06:00 a crop whose farmland was watered the day before grows a day, and it shows the +stage for how far along it is. `mods/farmersdelight` adds its cabbages, onions, tomatoes and rice this way. + +`blocks/cabbages.json`, with its `variants` giving one texture per age (see [Block models](#block-models)): + +```json +{ + "format_version": 1, + "block": { + "id": "farmersdelight:cabbages", + "model": "engine:cross", + "render_layer": "cutout", + "collision": false, + "mining": { "toughness": 0 }, + "item": false, + "place_on": ["bworld:hoed_dirt"], + "states": [{ "name": "age", "bits": 3, "default": 0 }], + "components": { + "bworld:crop": { + "days": 12, + "stages": 8, + "fertilizer": "bworld:bone_meal", + "drops": { + "young": "farmersdelight:cabbage_seeds", + "mature": "farmersdelight:cabbage", + "bonus": "farmersdelight:cabbage_seeds" + } + } + } + } +} +``` + +and `items/cabbage_seeds.json` with `"places": "farmersdelight:cabbages"`. + +| Param | Meaning | +| --------------- | ------------------------------------------------------------------------------------------------------------ | +| `days` | Watered mornings from planting to fully grown. | +| `stages` | How many ages it shows, 0 to `stages - 1`, spread evenly over `days`. The `age` state must fit them. | +| `drops` | Like a crop's loot table: `young` (not grown yet), `mature` (grown), and `bonus`, 0 to 3 more of an item when grown, like wheat's extra seeds. `young` and `mature` can be one id or a list. | +| `fertilizer` | An item that grows it a day right away, like bone meal. | +| `regrow_days`, `harvest` | Picked by right clicking once grown, dropping `harvest.item` (`count` is `[min, max]`), then grown again after `regrow_days`, like tomatoes. | +| `water` | `"farmland"` (the default): needs watered farmland under it. `"always"`: grows every morning, like rice in water. | +| `upper` | `{ block, stages, supporting_age }`: its last stages grow a second block on top, like rice's panicles. The top block uses the `bworld:crop_top` component with `{ stages, drops }`; breaking it harvests the whole plant. | +| `leaves` | What the spot becomes after it's broken, like water where rice was. | + +Players place blocks into the block they click when it's `replaceable`, like Minecraft, so rice (with +`"place_in": ["bworld:water"]`) is planted by clicking water. Food that places a block, like potatoes, is planted when +clicked on somewhere it can go and eaten otherwise. + ## Items `items/copper_pickaxe.json`: @@ -663,6 +718,7 @@ or place, the server tells that player's client to undo what it already showed. interface ServerWorld { get_block(x: number, y: number, z: number): string | undefined; // undefined when the chunk isn't loaded set_block(x: number, y: number, z: number, id: string): boolean; // runs on_break / on_create, synced to everyone + break_block(x: number, y: number, z: number): boolean; // like breaking it by hand: on_break, then its drops get_state(x: number, y: number, z: number, name: string): number | undefined; set_state(x: number, y: number, z: number, name: string, value: number): boolean; get_block_data(x: number, y: number, z: number): T | undefined; diff --git a/client/game_mode.ts b/client/game_mode.ts index 38cbd9f..1627a9e 100644 --- a/client/game_mode.ts +++ b/client/game_mode.ts @@ -4,7 +4,7 @@ import type { Client } from "./client.ts"; import type { BlockHitResult } from "./level/client_level.ts"; import type { Container } from "$/common/inventory.ts"; import { AIR_ID, type ContainerKey } from "$/common/protocol.ts"; -import { can_stand_on } from "$/common/utils.ts"; +import { can_place, placement_target } from "$/common/utils.ts"; // breaking and using blocks against a server, like minecraft's MultiPlayerGameMode. the client times breaking // and guesses the results so they feel instant, the server decides what really happens @@ -54,20 +54,22 @@ export class MultiPlayerGameMode { const level = this.client.level; this.client.connection.send({ type: "use_block", x: hit.x, y: hit.y, z: hit.z, face: hit.face }); - // guess that it places the held block, unless the block does something when used + // guess that it places the held block, unless the block does something when used. the same rules as the server: + // into the clicked block when it's replaceable, and only where place_in and place_on allow const block_info = EverythingRegistry.get_by_id("blocks", hit.block)!; - const offset = FACE_OFFSETS[hit.face]; - const target = { x: hit.x + offset.x, y: hit.y + offset.y, z: hit.z + offset.z }; - const target_id = level.get_block(target.x, target.y, target.z); - const replaceable = target_id === AIR || - EverythingRegistry.get_by_id("blocks", target_id)?.replaceable; + const target = placement_target(hit.x, hit.y, hit.z, FACE_OFFSETS[hit.face], block_info); + const current = level.get_block(target.x, target.y, target.z); + const below = level.get_block(target.x, target.y - 1, target.z); + const below_id = EverythingRegistry.get_by_id("blocks", below)?.id ?? AIR_ID; const held = this.#held_item(); // items with components might do something else on the server, like on_use const place_id = held?.components ? undefined : held?.block_id; - const below = level.get_block(target.x, target.y - 1, target.z); - const below_id = EverythingRegistry.get_by_id("blocks", below)?.id ?? AIR_ID; - const stands = can_stand_on(EverythingRegistry.get("blocks", place_id ?? ""), below_id); - if (!block_info.interactive && place_id && replaceable && stands) { + const placeable = place_id !== undefined && can_place( + EverythingRegistry.get("blocks", place_id), + current === AIR ? undefined : EverythingRegistry.get_by_id("blocks", current), + below_id, + ); + if (!block_info.interactive && place_id && placeable) { level.add_block({ ...target, id: place_id }); const slot = this.#held_slot(); slot.amount = slot.amount! - 1; diff --git a/common/everything_registry.ts b/common/everything_registry.ts index e894099..51a6bad 100644 --- a/common/everything_registry.ts +++ b/common/everything_registry.ts @@ -132,6 +132,8 @@ export interface BlockRegistry { // the blocks it can stand on, like crops on farmland. it can't be placed elsewhere, and breaks when the block // under it becomes something else. anything when not set place_on?: string[]; + // the blocks it can be placed into, replacing them, like rice into water. air and replaceable blocks when not set + place_in?: string[]; // custom components from mods and their params, the server runs them components?: Record; diff --git a/common/mod_api/server.ts b/common/mod_api/server.ts index 0b05456..a208707 100644 --- a/common/mod_api/server.ts +++ b/common/mod_api/server.ts @@ -141,6 +141,8 @@ export interface ServerAfterEvents { export interface ServerWorld { get_block(x: number, y: number, z: number): Id | undefined; // undefined when the chunk isn't loaded set_block(x: number, y: number, z: number, id: Id): boolean; // runs on_break / on_create, synced to everyone + // like breaking it by hand without a tool: on_break, then its drops. false when there was nothing to break + break_block(x: number, y: number, z: number): boolean; get_state(x: number, y: number, z: number, name: string): number | undefined; set_state(x: number, y: number, z: number, name: string, value: number): boolean; get_block_data(x: number, y: number, z: number): T | undefined; diff --git a/common/mod_check.ts b/common/mod_check.ts index bf6b9eb..2c2b2cd 100644 --- a/common/mod_check.ts +++ b/common/mod_check.ts @@ -107,7 +107,9 @@ export function check_references(mods: LoadedMod[], engine_textures: Iterable 1 || BUILTIN_MODELS[json.id]) { diff --git a/common/mod_data.ts b/common/mod_data.ts index ee689f1..11c8169 100644 --- a/common/mod_data.ts +++ b/common/mod_data.ts @@ -50,6 +50,7 @@ export interface BlockJson { interactive?: boolean; replaceable?: boolean; place_on?: string[]; + place_in?: string[]; states?: BlockStateDefinition[]; components?: Record; } @@ -124,6 +125,7 @@ export function block_to_json(block: BlockRegistry, has_item: boolean): BlockJso if (block.interactive) json.interactive = true; if (block.replaceable) json.replaceable = true; if (block.place_on) json.place_on = block.place_on; + if (block.place_in) json.place_in = block.place_in; if (block.states) json.states = block.states; if (block.components) json.components = block.components; return json; @@ -153,6 +155,7 @@ export function block_from_json(json: BlockJson): { block: BlockRegistry; has_it if (json.interactive) block.interactive = true; if (json.replaceable) block.replaceable = true; if (json.place_on) block.place_on = json.place_on; + if (json.place_in) block.place_in = json.place_in; if (json.states) block.states = json.states; if (json.components) block.components = json.components; return { block, has_item: json.item ?? true }; @@ -344,11 +347,13 @@ export function validate_block(json: unknown): Problems { } } if (json.drops !== undefined) problems.push(...validate_id(json.drops, "drops")); - if (json.place_on !== undefined) { - if (!Array.isArray(json.place_on) || json.place_on.length === 0) { - problems.push("place_on must be a list of block ids"); + for (const key of ["place_on", "place_in"]) { + const list = json[key]; + if (list === undefined) continue; + if (!Array.isArray(list) || list.length === 0) { + problems.push(`${key} must be a list of block ids`); } else { - for (const id of json.place_on) problems.push(...validate_id(id, "place_on")); + for (const id of list) problems.push(...validate_id(id, key)); } } if (json.states !== undefined) { diff --git a/common/utils.ts b/common/utils.ts index 3d1a9f2..8478e89 100644 --- a/common/utils.ts +++ b/common/utils.ts @@ -123,6 +123,31 @@ export function can_stand_on(block: BlockRegistry | undefined, below: string): b return !block?.place_on || block.place_on.includes(below); } +// where a block placed by clicking a face of another goes: into the clicked block when it can be replaced (like water), +// like minecraft, otherwise next to it +export function placement_target( + x: number, + y: number, + z: number, + offset: { x: number; y: number; z: number }, + clicked: BlockRegistry | undefined, +) { + return clicked?.replaceable ? { x, y, z } : { x: x + offset.x, y: y + offset.y, z: z + offset.z }; +} + +// whether a player can place block where current is now, with below under it. current is undefined for air +export function can_place( + block: BlockRegistry | undefined, + current: BlockRegistry | undefined, + below: string, +): boolean { + if (!block) return false; + const into = current?.id ?? "bworld:air"; + const replaceable = !current || current.replaceable === true; + const in_ok = block.place_in ? block.place_in.includes(into) : replaceable; + return in_ok && can_stand_on(block, below); +} + // numeric so looking chunks up doesnt allocate a string every time, fine for |x|, |z| < 32768 export function chunk_key(x: number, z: number) { return (x + 32768) * 65536 + (z + 32768); diff --git a/mods/bworld/blocks/carrots.json b/mods/bworld/blocks/carrots.json new file mode 100644 index 0000000..6e67658 --- /dev/null +++ b/mods/bworld/blocks/carrots.json @@ -0,0 +1,60 @@ +{ + "format_version": 1, + "block": { + "id": "bworld:carrots", + "textures": { + "crop": "bworld:carrot_stage_0" + }, + "model": "engine:crop", + "variants": { + "age=0": { + "textures": { + "crop": "bworld:carrot_stage_0" + } + }, + "age=1": { + "textures": { + "crop": "bworld:carrot_stage_1" + } + }, + "age=2": { + "textures": { + "crop": "bworld:carrot_stage_2" + } + }, + "age=3": { + "textures": { + "crop": "bworld:carrot_stage_3" + } + } + }, + "render_layer": "cutout", + "collision": false, + "mining": { + "toughness": 0 + }, + "item": false, + "place_on": [ + "bworld:hoed_dirt" + ], + "states": [ + { + "name": "age", + "bits": 2, + "default": 0 + } + ], + "components": { + "bworld:crop": { + "days": 3, + "stages": 4, + "fertilizer": "bworld:bone_meal", + "drops": { + "young": "bworld:carrot", + "mature": "bworld:carrot", + "bonus": "bworld:carrot" + } + } + } + } +} diff --git a/mods/bworld/blocks/potatoes.json b/mods/bworld/blocks/potatoes.json new file mode 100644 index 0000000..510079b --- /dev/null +++ b/mods/bworld/blocks/potatoes.json @@ -0,0 +1,60 @@ +{ + "format_version": 1, + "block": { + "id": "bworld:potatoes", + "textures": { + "crop": "bworld:potatoes_stage_0" + }, + "model": "engine:crop", + "variants": { + "age=0": { + "textures": { + "crop": "bworld:potatoes_stage_0" + } + }, + "age=1": { + "textures": { + "crop": "bworld:potatoes_stage_1" + } + }, + "age=2": { + "textures": { + "crop": "bworld:potatoes_stage_2" + } + }, + "age=3": { + "textures": { + "crop": "bworld:potatoes_stage_3" + } + } + }, + "render_layer": "cutout", + "collision": false, + "mining": { + "toughness": 0 + }, + "item": false, + "place_on": [ + "bworld:hoed_dirt" + ], + "states": [ + { + "name": "age", + "bits": 2, + "default": 0 + } + ], + "components": { + "bworld:crop": { + "days": 6, + "stages": 4, + "fertilizer": "bworld:bone_meal", + "drops": { + "young": "bworld:potato", + "mature": "bworld:potato", + "bonus": "bworld:potato" + } + } + } + } +} diff --git a/mods/bworld/blocks/wheat.json b/mods/bworld/blocks/wheat.json index c3da7d9..124f523 100644 --- a/mods/bworld/blocks/wheat.json +++ b/mods/bworld/blocks/wheat.json @@ -53,8 +53,10 @@ "mining": { "toughness": 0 }, - "drops": "bworld:wheat_seeds", "item": false, + "place_on": [ + "bworld:hoed_dirt" + ], "states": [ { "name": "age", @@ -64,14 +66,15 @@ ], "components": { "bworld:crop": { - "max_age": 7, - "produce": "bworld:wheat", - "seeds": "bworld:wheat_seeds", - "fertilizer": "bworld:bone_meal" + "days": 7, + "stages": 8, + "fertilizer": "bworld:bone_meal", + "drops": { + "young": "bworld:wheat_seeds", + "mature": "bworld:wheat", + "bonus": "bworld:wheat_seeds" + } } - }, - "place_on": [ - "bworld:hoed_dirt" - ] + } } } diff --git a/mods/bworld/items/carrot.json b/mods/bworld/items/carrot.json index 313788a..7198131 100644 --- a/mods/bworld/items/carrot.json +++ b/mods/bworld/items/carrot.json @@ -6,6 +6,7 @@ "food": { "nutrition": 3, "saturation_modifier": 0.6 - } + }, + "places": "bworld:carrots" } } diff --git a/mods/bworld/items/potato.json b/mods/bworld/items/potato.json index 3031d73..4832374 100644 --- a/mods/bworld/items/potato.json +++ b/mods/bworld/items/potato.json @@ -6,6 +6,7 @@ "food": { "nutrition": 1, "saturation_modifier": 0.3 - } + }, + "places": "bworld:potatoes" } } diff --git a/mods/bworld/scripts/server.ts b/mods/bworld/scripts/server.ts index 51b23dc..9222529 100644 --- a/mods/bworld/scripts/server.ts +++ b/mods/bworld/scripts/server.ts @@ -283,13 +283,44 @@ interface WateringCanData { max_water: number; } +// items as they appear in crop params: one id, or several +type Items = string | string[]; + +// what a crop drops when broken, like the loot tables of minecraft's and farmer's delight's crops +interface CropDrops { + // before it's fully grown, like wheat's seeds + young?: Items; + // fully grown, like wheat's wheat + mature?: Items; + // fully grown, 0 to 3 more of this, like the extra seeds from wheat (minecraft's binomial with 3 tries at 57%) + bonus?: string; +} + +// a crop, like a fabric CropBlock: its "age" state is its stage, and it grows one day every morning its farmland was +// watered the day before. see "Crops" in MODS.md interface CropParams { - max_age: number; - // what a fully grown crop drops besides its seeds, and the seeds for the extra ones - produce?: string; - seeds?: string; - // grows it one stage right away, like bone meal + // watered mornings from planting to fully grown + days: number; + // how many stages it shows, ages 0 to stages - 1. its "age" state must fit them + stages: number; + drops?: CropDrops; + // grows back after it's harvested by right clicking, like tomatoes + regrow_days?: number; + harvest?: { item: string; count: [number, number] }; + // grows it a day right away, like bone meal fertilizer?: string; + // "farmland" (the default) needs watered farmland under it, "always" grows every morning, like rice in water + water?: "farmland" | "always"; + // the last stages grow a second block on top, like rice's panicles. the crop stays at supporting_age meanwhile + upper?: { block: string; stages: number; supporting_age: number }; + // what the spot becomes when it's broken, like water where rice was + leaves?: string; +} + +// the top of a two block crop. it grows with the crop under it, and breaking it breaks the whole plant +interface CropTopParams { + stages: number; + drops?: CropDrops; } function register_farming(ctx: ServerContext) { @@ -335,46 +366,115 @@ function register_farming(ctx: ServerContext) { }, }); + const list = (items: Items | undefined) => items === undefined ? [] : typeof items === "string" ? [items] : items; + + const drop = (x: number, y: number, z: number, drops: CropDrops | undefined, mature: boolean) => { + for (const id of list(mature ? drops?.mature : drops?.young)) ctx.world.drop_item(x, y, z, { id, count: 1 }); + if (mature && drops?.bonus) { + let count = 0; + for (let i = 0; i < 3; i++) if (Math.random() < 0.5714) count++; + if (count > 0) ctx.world.drop_item(x, y, z, { id: drops.bonus, count }); + } + }; + + // the stage for how many days it has grown: evenly spread, fully grown on the last day + const stage_for = (params: CropParams, days: number) => { + const stages = params.stages + (params.upper?.stages ?? 0); + return Math.min(stages - 1, Math.floor(days * (stages - 1) / params.days)); + }; + + // days grown, kept in the block's data. crops from before this start at the first day of the stage they show + const days_of = (block: BlockRef, params: CropParams) => { + if (typeof block.data?.days === "number") return block.data.days as number; + const age = ctx.world.get_state(block.x, block.y, block.z, "age") ?? 0; + let days = 0; + while (days < params.days && stage_for(params, days) < age) days++; + return days; + }; + + // shows the stage for days, growing or taking away the top block for two block crops + const set_days = (block: BlockRef, params: CropParams, days: number) => { + block.data = { ...block.data, days }; + const stage = stage_for(params, days); + const upper = params.upper; + const above = ctx.world.get_block(block.x, block.y + 1, block.z); + if (!upper || stage < params.stages) { + ctx.world.set_state(block.x, block.y, block.z, "age", stage); + if (upper && above === upper.block) ctx.world.set_block(block.x, block.y + 1, block.z, "bworld:air"); + return; + } + // the top needs room, like farmer's delight's rice + if (above !== upper.block && above !== "bworld:air") { + ctx.world.set_state(block.x, block.y, block.z, "age", params.stages - 1); + return; + } + ctx.world.set_state(block.x, block.y, block.z, "age", upper.supporting_age); + if (above !== upper.block) ctx.world.set_block(block.x, block.y + 1, block.z, upper.block); + ctx.world.set_state(block.x, block.y + 1, block.z, "age", stage - params.stages); + }; + + const is_grown = (block: BlockRef, params: CropParams) => days_of(block, params) >= params.days; + ctx.components.register_block("bworld:crop", { - on_create(block) { + // block data so on_new_day runs for it. placed at a later stage (by a script), it has grown that long + on_create(block, params) { block.data = {}; + block.data = { days: days_of(block, params) }; }, on_new_day(block, params) { - const age = ctx.world.get_state(block.x, block.y, block.z, "age") ?? 0; - if (age < params.max_age && is_watered(block.x, block.y - 1, block.z)) { - ctx.world.set_state(block.x, block.y, block.z, "age", age + 1); - } + const days = days_of(block, params); + if (days >= params.days) return; + const watered = params.water === "always" || is_watered(block.x, block.y - 1, block.z); + if (watered) set_days(block, params, days + 1); }, on_interact(block, params, player) { - block.data ??= {}; const held = player.held_item; // watering a crop waters the farmland under it if (held?.id === WATERING_CAN) { + block.data ??= { days: days_of(block, params) }; return water(block.x, block.y - 1, block.z, player); } - if (!params.fertilizer || held?.id !== params.fertilizer) { - return false; + const days = days_of(block, params); + if (params.fertilizer && held?.id === params.fertilizer) { + // fully grown, keep the fertilizer + if (days >= params.days) return false; + set_days(block, params, days + 1); + held.count -= 1; + return true; } - const age = ctx.world.get_state(block.x, block.y, block.z, "age") ?? 0; - // fully grown, keep the fertilizer - if (age >= params.max_age) { - return false; + // regrowing crops are picked by hand and grow back, like farmer's delight's tomatoes + if (params.regrow_days && params.harvest && days >= params.days) { + const [min, max] = params.harvest.count; + const count = min + Math.floor(Math.random() * (max - min + 1)); + ctx.world.drop_item(block.x, block.y, block.z, { id: params.harvest.item, count }); + set_days(block, params, Math.max(0, params.days - params.regrow_days)); + return true; } - ctx.world.set_state(block.x, block.y, block.z, "age", age + 1); - held.count -= 1; - return true; + return false; }, - // the block's own drops are one seed. fully grown it also drops its produce and 0 to 3 more seeds, like - // minecraft's wheat + on_break(block, params) { + drop(block.x, block.y, block.z, params.drops, is_grown(block, params)); + if (params.leaves) { + const { x, y, z } = block; + const leaves = params.leaves; + // after it's gone, it's still there while on_break runs + ctx.system.run_timeout(() => { + if (ctx.world.get_block(x, y, z) === "bworld:air") ctx.world.set_block(x, y, z, leaves); + }, 0); + } + }, + }); + + ctx.components.register_block("bworld:crop_top", { on_break(block, params) { const age = ctx.world.get_state(block.x, block.y, block.z, "age") ?? 0; - if (age < params.max_age) return; - if (params.produce) ctx.world.drop_item(block.x, block.y, block.z, { id: params.produce, count: 1 }); - let extra = 0; - for (let i = 0; i < 3; i++) if (Math.random() < 0.5714) extra++; - if (params.seeds && extra > 0) { - ctx.world.drop_item(block.x, block.y, block.z, { id: params.seeds, count: extra }); - } + drop(block.x, block.y, block.z, params.drops, age >= params.stages - 1); + // the plant under it goes too, once this is gone + const { x, y, z } = block; + const lower = ctx.world.get_block(x, y - 1, z); + ctx.system.run_timeout(() => { + if (lower && ctx.world.get_block(x, y - 1, z) === lower) ctx.world.break_block(x, y - 1, z); + }, 0); }, }); diff --git a/mods/bworld/textures/carrot_stage_0.png b/mods/bworld/textures/carrot_stage_0.png new file mode 100644 index 0000000000000000000000000000000000000000..c10faffbc6b6c5fa856b404fba48a6ad4b8f25ba GIT binary patch literal 192 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`?Vc`;aG%hmmc%NYS;OFP(PZC-ft;3f+I>Ik!bD&j_?Z%R*2ZxSGK8Q`|=1#uMF}Ycq zK}cl{W1}IjLC2+oZJlNeOE@BhJ$TgmCLBJpg3aaHj=$`Q64Dum>sKTe@H{S1(0+Elu$+s-@V@{mJ!@zlfm*Jv=T}SWP0t@*gZQK$rFB?o>{?=&Dn8CQg zpedVSW%DX`Q-%)5S&l*lhZ`7fwi;MYu-fsE;o-OanU`3)76To};OXk;vd$@?2>|om BP5J-; literal 0 HcmV?d00001 diff --git a/mods/bworld/textures/carrot_stage_2.png b/mods/bworld/textures/carrot_stage_2.png new file mode 100644 index 0000000000000000000000000000000000000000..80089fc3c24a21d09e71766ec1380dfec7df3992 GIT binary patch literal 212 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`vproLLn;{G_HX1pzopr0Nl@1&j0`b literal 0 HcmV?d00001 diff --git a/mods/bworld/textures/carrot_stage_3.png b/mods/bworld/textures/carrot_stage_3.png new file mode 100644 index 0000000000000000000000000000000000000000..403257f445bd89e366eeeb0191a795412bbc94b7 GIT binary patch literal 240 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPFP2=EDUefI1b2M5RV=g)VpOnva+ z!TtO9BWv8e3v9P7jW>wW(f3i_5NkEvT6b%X!^KHa|Ns9NG|#F88B`MF7Yw9<;QxOh z0s)4fe7v)O0`Z|_OF6g>>vi`F_vqsHL=1$g{{}K}4_Sydb beOHc;L4rxhQb;fnH3o^_^$E?t>t$wfNHbjGIrJh&pl{ZLpYkmmB^j>sq#QP!z<;UX h412PzeeMoL28Vf@f8>8tUjQ_i!PC{xWt~$(695BTEPwz2 literal 0 HcmV?d00001 diff --git a/mods/bworld/textures/potatoes_stage_1.png b/mods/bworld/textures/potatoes_stage_1.png new file mode 100644 index 0000000000000000000000000000000000000000..8d4d1abcaa4c9292c0db1012ac66976e0ee603f4 GIT binary patch literal 150 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`v7RoDAr*|t2?-Lc|NsAA&cZLp z?8dvnbL)ZS9Lv~RK1wkp|L4ys_|KozoFSlgkd?!?s_s^TRaTR_MDr7Y93SQfQjIwR wZ5tEY9By(PzR1gvxI;xsy2UX^qBn_wfz6+@wJ%X`7tkUGPgg&ebxsLQ0B;d4C;$Ke literal 0 HcmV?d00001 diff --git a/mods/bworld/textures/potatoes_stage_2.png b/mods/bworld/textures/potatoes_stage_2.png new file mode 100644 index 0000000000000000000000000000000000000000..828ff7d9187f46e1e029e284a98c2ebfefabeb7e GIT binary patch literal 146 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPHV5AX?b{r~@e)C5mGKkdKzEf#xxIy85}Sb4q9e0Obce$^ZZW literal 0 HcmV?d00001 diff --git a/mods/farmersdelight/CREDITS.md b/mods/farmersdelight/CREDITS.md new file mode 100644 index 0000000..63a59f8 --- /dev/null +++ b/mods/farmersdelight/CREDITS.md @@ -0,0 +1,28 @@ +# Farmer's Delight + +A bworld port of [Farmer's Delight](https://github.com/vectorwing/FarmersDelight) by vectorwing. Its textures and game +design come from the original, version 1.3.4 for NeoForge 1.21.1, under the MIT license: + +``` +MIT License + +Copyright (c) 2020 vectorwing + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +``` diff --git a/mods/farmersdelight/blocks/cabbages.json b/mods/farmersdelight/blocks/cabbages.json new file mode 100644 index 0000000..befbb36 --- /dev/null +++ b/mods/farmersdelight/blocks/cabbages.json @@ -0,0 +1,80 @@ +{ + "format_version": 1, + "block": { + "id": "farmersdelight:cabbages", + "textures": { + "cross": "farmersdelight:cabbages_stage0" + }, + "model": "engine:cross", + "variants": { + "age=0": { + "textures": { + "cross": "farmersdelight:cabbages_stage0" + } + }, + "age=1": { + "textures": { + "cross": "farmersdelight:cabbages_stage1" + } + }, + "age=2": { + "textures": { + "cross": "farmersdelight:cabbages_stage2" + } + }, + "age=3": { + "textures": { + "cross": "farmersdelight:cabbages_stage3" + } + }, + "age=4": { + "textures": { + "cross": "farmersdelight:cabbages_stage4" + } + }, + "age=5": { + "textures": { + "cross": "farmersdelight:cabbages_stage5" + } + }, + "age=6": { + "textures": { + "cross": "farmersdelight:cabbages_stage6" + } + }, + "age=7": { + "textures": { + "cross": "farmersdelight:cabbages_stage7" + } + } + }, + "render_layer": "cutout", + "collision": false, + "mining": { + "toughness": 0 + }, + "item": false, + "place_on": [ + "bworld:hoed_dirt" + ], + "states": [ + { + "name": "age", + "bits": 3, + "default": 0 + } + ], + "components": { + "bworld:crop": { + "days": 12, + "stages": 8, + "fertilizer": "bworld:bone_meal", + "drops": { + "young": "farmersdelight:cabbage_seeds", + "mature": "farmersdelight:cabbage", + "bonus": "farmersdelight:cabbage_seeds" + } + } + } + } +} diff --git a/mods/farmersdelight/blocks/onions.json b/mods/farmersdelight/blocks/onions.json new file mode 100644 index 0000000..e750e32 --- /dev/null +++ b/mods/farmersdelight/blocks/onions.json @@ -0,0 +1,60 @@ +{ + "format_version": 1, + "block": { + "id": "farmersdelight:onions", + "textures": { + "crop": "farmersdelight:onions_stage0" + }, + "model": "engine:crop", + "variants": { + "age=0": { + "textures": { + "crop": "farmersdelight:onions_stage0" + } + }, + "age=1": { + "textures": { + "crop": "farmersdelight:onions_stage1" + } + }, + "age=2": { + "textures": { + "crop": "farmersdelight:onions_stage2" + } + }, + "age=3": { + "textures": { + "crop": "farmersdelight:onions_stage3" + } + } + }, + "render_layer": "cutout", + "collision": false, + "mining": { + "toughness": 0 + }, + "item": false, + "place_on": [ + "bworld:hoed_dirt" + ], + "states": [ + { + "name": "age", + "bits": 2, + "default": 0 + } + ], + "components": { + "bworld:crop": { + "days": 4, + "stages": 4, + "fertilizer": "bworld:bone_meal", + "drops": { + "young": "farmersdelight:onion", + "mature": "farmersdelight:onion", + "bonus": "farmersdelight:onion" + } + } + } + } +} diff --git a/mods/farmersdelight/blocks/rice.json b/mods/farmersdelight/blocks/rice.json new file mode 100644 index 0000000..b622888 --- /dev/null +++ b/mods/farmersdelight/blocks/rice.json @@ -0,0 +1,76 @@ +{ + "format_version": 1, + "block": { + "id": "farmersdelight:rice", + "textures": { + "cross": "farmersdelight:rice_stage0" + }, + "model": "engine:cross", + "variants": { + "age=0": { + "textures": { + "cross": "farmersdelight:rice_stage0" + } + }, + "age=1": { + "textures": { + "cross": "farmersdelight:rice_stage1" + } + }, + "age=2": { + "textures": { + "cross": "farmersdelight:rice_stage2" + } + }, + "age=3": { + "textures": { + "cross": "farmersdelight:rice_stage3" + } + }, + "age=4": { + "textures": { + "cross": "farmersdelight:rice_supporting" + } + } + }, + "render_layer": "cutout", + "collision": false, + "mining": { + "toughness": 0 + }, + "item": false, + "place_on": [ + "bworld:dirt", + "bworld:grass", + "bworld:hoed_dirt" + ], + "states": [ + { + "name": "age", + "bits": 3, + "default": 0 + } + ], + "place_in": [ + "bworld:water" + ], + "components": { + "bworld:crop": { + "days": 6, + "stages": 4, + "fertilizer": "bworld:bone_meal", + "water": "always", + "upper": { + "block": "farmersdelight:rice_panicles", + "stages": 4, + "supporting_age": 4 + }, + "leaves": "bworld:water", + "drops": { + "young": "farmersdelight:rice", + "mature": "farmersdelight:rice" + } + } + } + } +} diff --git a/mods/farmersdelight/blocks/rice_panicles.json b/mods/farmersdelight/blocks/rice_panicles.json new file mode 100644 index 0000000..108506d --- /dev/null +++ b/mods/farmersdelight/blocks/rice_panicles.json @@ -0,0 +1,56 @@ +{ + "format_version": 1, + "block": { + "id": "farmersdelight:rice_panicles", + "textures": { + "cross": "farmersdelight:rice_panicles_stage0" + }, + "model": "engine:cross", + "variants": { + "age=0": { + "textures": { + "cross": "farmersdelight:rice_panicles_stage0" + } + }, + "age=1": { + "textures": { + "cross": "farmersdelight:rice_panicles_stage1" + } + }, + "age=2": { + "textures": { + "cross": "farmersdelight:rice_panicles_stage2" + } + }, + "age=3": { + "textures": { + "cross": "farmersdelight:rice_panicles_stage3" + } + } + }, + "render_layer": "cutout", + "collision": false, + "mining": { + "toughness": 0 + }, + "item": false, + "place_on": [ + "farmersdelight:rice" + ], + "states": [ + { + "name": "age", + "bits": 2, + "default": 0 + } + ], + "components": { + "bworld:crop_top": { + "stages": 4, + "drops": { + "mature": "farmersdelight:rice_panicle" + } + } + } + } +} diff --git a/mods/farmersdelight/blocks/tomatoes.json b/mods/farmersdelight/blocks/tomatoes.json new file mode 100644 index 0000000..1eba9b2 --- /dev/null +++ b/mods/farmersdelight/blocks/tomatoes.json @@ -0,0 +1,90 @@ +{ + "format_version": 1, + "block": { + "id": "farmersdelight:tomatoes", + "textures": { + "cross": "farmersdelight:budding_tomatoes_stage0" + }, + "model": "engine:cross", + "variants": { + "age=0": { + "textures": { + "cross": "farmersdelight:budding_tomatoes_stage0" + } + }, + "age=1": { + "textures": { + "cross": "farmersdelight:budding_tomatoes_stage1" + } + }, + "age=2": { + "textures": { + "cross": "farmersdelight:budding_tomatoes_stage2" + } + }, + "age=3": { + "textures": { + "cross": "farmersdelight:budding_tomatoes_stage3" + } + }, + "age=4": { + "textures": { + "cross": "farmersdelight:tomatoes_stage0" + } + }, + "age=5": { + "textures": { + "cross": "farmersdelight:tomatoes_stage1" + } + }, + "age=6": { + "textures": { + "cross": "farmersdelight:tomatoes_stage2" + } + }, + "age=7": { + "textures": { + "cross": "farmersdelight:tomatoes_stage3" + } + } + }, + "render_layer": "cutout", + "collision": false, + "mining": { + "toughness": 0 + }, + "item": false, + "place_on": [ + "bworld:hoed_dirt" + ], + "states": [ + { + "name": "age", + "bits": 3, + "default": 0 + } + ], + "components": { + "bworld:crop": { + "days": 11, + "stages": 8, + "fertilizer": "bworld:bone_meal", + "regrow_days": 4, + "harvest": { + "item": "farmersdelight:tomato", + "count": [ + 1, + 2 + ] + }, + "drops": { + "young": "farmersdelight:tomato_seeds", + "mature": [ + "farmersdelight:tomato", + "farmersdelight:tomato_seeds" + ] + } + } + } + } +} diff --git a/mods/farmersdelight/items/cabbage.json b/mods/farmersdelight/items/cabbage.json new file mode 100644 index 0000000..36b9301 --- /dev/null +++ b/mods/farmersdelight/items/cabbage.json @@ -0,0 +1,11 @@ +{ + "format_version": 1, + "item": { + "id": "farmersdelight:cabbage", + "texture": "farmersdelight:cabbage", + "food": { + "nutrition": 2, + "saturation_modifier": 0.4 + } + } +} diff --git a/mods/farmersdelight/items/cabbage_seeds.json b/mods/farmersdelight/items/cabbage_seeds.json new file mode 100644 index 0000000..8a594ee --- /dev/null +++ b/mods/farmersdelight/items/cabbage_seeds.json @@ -0,0 +1,8 @@ +{ + "format_version": 1, + "item": { + "id": "farmersdelight:cabbage_seeds", + "texture": "farmersdelight:cabbage_seeds", + "places": "farmersdelight:cabbages" + } +} diff --git a/mods/farmersdelight/items/onion.json b/mods/farmersdelight/items/onion.json new file mode 100644 index 0000000..072d979 --- /dev/null +++ b/mods/farmersdelight/items/onion.json @@ -0,0 +1,12 @@ +{ + "format_version": 1, + "item": { + "id": "farmersdelight:onion", + "texture": "farmersdelight:onion", + "places": "farmersdelight:onions", + "food": { + "nutrition": 2, + "saturation_modifier": 0.4 + } + } +} diff --git a/mods/farmersdelight/items/rice.json b/mods/farmersdelight/items/rice.json new file mode 100644 index 0000000..9bd8e5e --- /dev/null +++ b/mods/farmersdelight/items/rice.json @@ -0,0 +1,8 @@ +{ + "format_version": 1, + "item": { + "id": "farmersdelight:rice", + "texture": "farmersdelight:rice", + "places": "farmersdelight:rice" + } +} diff --git a/mods/farmersdelight/items/rice_panicle.json b/mods/farmersdelight/items/rice_panicle.json new file mode 100644 index 0000000..68f2306 --- /dev/null +++ b/mods/farmersdelight/items/rice_panicle.json @@ -0,0 +1,7 @@ +{ + "format_version": 1, + "item": { + "id": "farmersdelight:rice_panicle", + "texture": "farmersdelight:rice_panicle" + } +} diff --git a/mods/farmersdelight/items/tomato.json b/mods/farmersdelight/items/tomato.json new file mode 100644 index 0000000..98ea8c5 --- /dev/null +++ b/mods/farmersdelight/items/tomato.json @@ -0,0 +1,11 @@ +{ + "format_version": 1, + "item": { + "id": "farmersdelight:tomato", + "texture": "farmersdelight:tomato", + "food": { + "nutrition": 1, + "saturation_modifier": 0.3 + } + } +} diff --git a/mods/farmersdelight/items/tomato_seeds.json b/mods/farmersdelight/items/tomato_seeds.json new file mode 100644 index 0000000..6400469 --- /dev/null +++ b/mods/farmersdelight/items/tomato_seeds.json @@ -0,0 +1,8 @@ +{ + "format_version": 1, + "item": { + "id": "farmersdelight:tomato_seeds", + "texture": "farmersdelight:tomato_seeds", + "places": "farmersdelight:tomatoes" + } +} diff --git a/mods/farmersdelight/manifest.json b/mods/farmersdelight/manifest.json new file mode 100644 index 0000000..a422e18 --- /dev/null +++ b/mods/farmersdelight/manifest.json @@ -0,0 +1,19 @@ +{ + "format_version": 1, + "id": "farmersdelight", + "name": "Farmer's Delight", + "description": "A port of vectorwing's Farmer's Delight: its crops for now, cooking to come.", + "version": "0.1.0", + "authors": [ + "vectorwing (original)", + "paula (port)" + ], + "game_version": ">=0.1.0", + "dependencies": [ + { + "id": "bworld", + "version": "*" + } + ], + "credits": "CREDITS.md" +} diff --git a/mods/farmersdelight/textures/budding_tomatoes_stage0.png b/mods/farmersdelight/textures/budding_tomatoes_stage0.png new file mode 100644 index 0000000000000000000000000000000000000000..a9f1ebddabf55c2b33d27893ab1e87c2223abbdd GIT binary patch literal 151 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|0zF+ELo9le z6C_v{CwMU2mwWx+s;cO0u^Oj=w6c}UP0S#yHboFyt=akR{08H>SfdBvi literal 0 HcmV?d00001 diff --git a/mods/farmersdelight/textures/budding_tomatoes_stage1.png b/mods/farmersdelight/textures/budding_tomatoes_stage1.png new file mode 100644 index 0000000000000000000000000000000000000000..71340bd38577ba6b99f3cd9c7e260a05201f97b4 GIT binary patch literal 207 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|Iz3$+Lo9le z6C_xb8Gn3>_`iImqR$kmb4_Q>Vom+pPH*35oTF!X>c#EkzyJRRr_EtAND|(nx#jo& zUoW%S0y6{IfS^tJZ~KN-hcg*AW#`SUI=&!H?Z|@F$4*{&ww>MC_MAb3<=pypPLQ)H(QN`acrjGg#N*Hw>Px#+(|@1R5*?8ki81RFcgJP8W9{Tbn0GlaCNB&f~%|VAvpOAg}z5eeE=cUrE7;` z_DqFl6oe87N$Fqw8QlEFn{#gNIl!NnYyw~X+&uVZ;mjK$+}9$U6GQU=#SNE}m?s%A1cnzt(AV&=xwb1E4f{`y*%; zyQQ+-5Px$5J^NqR5*>rk}+F3*m3*D|r2$e4 z&YGjaMwmwyAj~6sFSw^HNQHT1eeF}1)!i%>1X+<-0Pzn)sMpTHbOr!l`*^zNbU3S* zIXDhn;=skzJ*G1wNP=vSjjGE^iNNF^%vI{LQeht1;NyLb&uHhyGveHNO2akN3D69rUBme*a07*qoM6N<$f?pn#*Z=?k literal 0 HcmV?d00001 diff --git a/mods/farmersdelight/textures/cabbage.png b/mods/farmersdelight/textures/cabbage.png new file mode 100644 index 0000000000000000000000000000000000000000..3c90b7302405fd95b5ec94777f16b6bb7df94e29 GIT binary patch literal 417 zcmV;S0bc%zP)Px$TS-JgR5*>rld)>TP#A^3G*ZYY9i>|lG6;7nNJJ>QUVH*yphH3Els zAj3cdET7+87kf8s;FwKnq{+^7;X|G+W1uk;kJh zfHn{dC~_B-shXRV19sazw|6%zmv5w-5>SjsU5eb*NfbL*ReHK9?Xd8L9o}vC2w&K5 zj1hnZBvI@Xxl56|NI3wo!zxp?p{guEhJiMF8)qZo3!9+R_Raw^4D@)^rPKDPLICTo zGG$l$x{C^+)AnkP)wtE&&AHl-20*+zAf<^4v-uiOsEnGM%GCGsPe*JadXv6>dc3#p z@#=7PVa?XDR&rlS+Xd7e##CY@8dtWZ`M7>o^r93@Sfo6v@ fHgQSj3nqqn&vTDY@<}@fbTNactDnm{r-UW|4OU=R literal 0 HcmV?d00001 diff --git a/mods/farmersdelight/textures/cabbages_stage0.png b/mods/farmersdelight/textures/cabbages_stage0.png new file mode 100644 index 0000000000000000000000000000000000000000..6c909063c6d0bf4b8b5ac50788826be0cb40800b GIT binary patch literal 123 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|Og&v3Lo9le z6C_v{Cy4Mc25dd~biePyyY)3$5`~^C+B5%&PZdk8`1{3_83+!a4ZXf`6)QuXI(KyP Tmf&AN0~kDA{an^LB{Ts5w0I@P literal 0 HcmV?d00001 diff --git a/mods/farmersdelight/textures/cabbages_stage1.png b/mods/farmersdelight/textures/cabbages_stage1.png new file mode 100644 index 0000000000000000000000000000000000000000..9f61725508d0e7a784d8c5628992689976005f92 GIT binary patch literal 152 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|f;?RuLo9le z6C_v{Cx~2-3&}0|nID|-U4FilT8z-E#99CK@BcdY;n&M-wyy@hbJ`4&gn70-`Ex#Z x*@1#jmdwr9&!_YB$Nf!80D_3>Kh|wk4AHYC*tYp}o&%cB;OXk;vd$@?2>=8%HxB>+ literal 0 HcmV?d00001 diff --git a/mods/farmersdelight/textures/cabbages_stage2.png b/mods/farmersdelight/textures/cabbages_stage2.png new file mode 100644 index 0000000000000000000000000000000000000000..7114623d11a3c6da34004b848befd73f9032b154 GIT binary patch literal 157 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|!aZFaLo9le z6C_v{Cx{5J?6bZ0KbPz6zsJFcTl_b#lTv2}0Xyf20?#{EU;7^Z4GwI(?jQfSR8`sR zV1oC#|3yhTJpFNhlXm=WYCIUoe<-f{k9AuWL-RiADZ(***+458JYD@<);T3K0RUC0 BHkbea literal 0 HcmV?d00001 diff --git a/mods/farmersdelight/textures/cabbages_stage3.png b/mods/farmersdelight/textures/cabbages_stage3.png new file mode 100644 index 0000000000000000000000000000000000000000..81c5980570f85227c9f1464a52f44a0705b1252b GIT binary patch literal 226 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|=6Jd|hFJ6_ zCrGd^PKaP|ixJvqd+ooZgoMOB`_#0Gzh6ubpAEgfaaHP}rIF#ilN*8H;n&O8c@|w- z#Pcd~*8hzwQxB^B_@`-nIJNCP&#tUFJn!ds8SSb2CAD09gOozuBNOKBGno$G3g+R7 zv!8EhQ}wm`Vb>a_FlK{4sS8g0oDVe5F|w)A(XXdB@&D3z9)o{(#d&zd-_^TcWM-Jk WukCWyXSom1oeZ9?elF{r5}E*oomwUU literal 0 HcmV?d00001 diff --git a/mods/farmersdelight/textures/cabbages_stage4.png b/mods/farmersdelight/textures/cabbages_stage4.png new file mode 100644 index 0000000000000000000000000000000000000000..885db253e7589de95ac38e1990d2d92468edad90 GIT binary patch literal 286 zcmV+(0pb3MP)Px#*hxe|R5*?8kWXjBU>wIkX{JPT$;evD*h*$B^q%TF=(X>o?<4Ge>@}1UJB(gt zIm`~T5f9}dp&mj=pB`pm%Ts#jvESS8`_J$9gEP)J0jxv9WHHs=um+$IHqVcV(c3YR zvpCY;uqF%~3SlFKNkoMdIVxAUm##5vJmKT%-Ri%rx!p-ru9)|>JY?Shh-KD#WQ!QzI2vFyfa|L+ ktG9~Z`EvuWU*(_79Px#<4Ht8R5*?8kj-ksKoo^PjR-+EN)v=Y78R5(+$%mqRt2A=kKvQJ?Y7{m&}DHJ zVxS1hfH0D5QU(g`bP*DqXx_lHxC&AO`vq>z#dFYp*Ip3G&YRegbob$LCN4oW5#q$&%LN{3$X zTd6%OoF!R3AUAmkG)gAyMQ-l)yEnsEfZb}_V1ar3%gxj8Gojz+a6I$Tc>qAZ9j#Ba vn&+8ozD{{P96;!|S#N&IzSw>4b(#AIdqZ0^6ZY_D00000NkvXXu0mjfS|fb# literal 0 HcmV?d00001 diff --git a/mods/farmersdelight/textures/cabbages_stage6.png b/mods/farmersdelight/textures/cabbages_stage6.png new file mode 100644 index 0000000000000000000000000000000000000000..bcaed1ce31a07d82d8654b0ef9cde5779514a6e8 GIT binary patch literal 318 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|et5b#hFJ6_ zCrGd!W-v$+{_=L?zxAt+olIDed7$9oFIF}nXgj@qpK*?!W!FME=L6f1|N8%X`5B(3 zOZAc^S1lgSx^JJFR`K_X>EW}X*Ch+37&c2TYXkzvfM5DC#ykqrhnn6s0S$1@33J{W z84@)GD93nIfrt4XP~V2)l*0wvR&3FTc|5&5K7c2|>DivTU$Y)w_!nPrm}TjIqngU^ ztjp7S3=)7KfdBHJ^=WD>+ht=fU$*TJ{IXz21JJO8ub&&UZQJ@>V#+_q9Nx$OjwF2i z%G-7}B32;hPx$Nl8ROR5*?8kikjDkIULNQvRXn3W)gAhit_LAyReaMd>m{Y0yv zO>PT8lBm_tAkttI$xtNb#uyOnwHRk~P}gmGtNZS|=iK`){GY!+(yE8ks{`T0x?xeT zwwBiVSHWsVC7z1X>ka@7Y6Y=O;s-da6$C)N+L9a?pw}G`PelP0H3NXCS6k9vr6>Sy z&zh1uK{g$PT0!WBg>Ky0cOahHN9$++3{Bs(*@U6#n@un@edt&&)NG8=u{bH`r(dvh zVZ{dfW`A*s&RAh(LN*UV36G8rtO6n1V{Ox tc>b{C?F~r80yG}&U6gibvG!uQ+%NcNkXNzb2pa$Z002ovPDHLkV1i{luWA4Q literal 0 HcmV?d00001 diff --git a/mods/farmersdelight/textures/onion.png b/mods/farmersdelight/textures/onion.png new file mode 100644 index 0000000000000000000000000000000000000000..a3fc95c063d5e71230583d3d314f5a9525dc119f GIT binary patch literal 383 zcmV-_0f7FAP)Px$IY~r8R5*>jkuggGVHn4MhBVl4;Bb0$oL)7wG_|<8Bs2y3C64HGI5>tw-@rw1 zYL$>e!2)S0Bz#pajFYT`prGMx>BKuv)209N4Da*%zt8i3;6If=&B)mbu(6JTsw+Mi zAi64S6?4+DT~u8`GvlbbBG)p|%=ol+8Ulc7xfxl>z$)hC{^2$wF`?5CRLjkX_x5K7 zRxu~Dg##XMpK)y02LnWcK*`EZL+TlucyRD%PthQ3#wGx0$pm>l#n#IXb#WgG&lz~& zUgiXVr)CWeaBO$sioOiSuWx928h}Ra0)Ua-XLtOy&|q$YyLJoOEwp5Uo8C77pC9kb z4ZPsY*o3PG7b9gNe&OLjEQDd^3fHA0S*dqJo6ax$p#l0*On$;8!fbT=?tgDBu7_JbP0l+XkKKw2oV literal 0 HcmV?d00001 diff --git a/mods/farmersdelight/textures/onions_stage1.png b/mods/farmersdelight/textures/onions_stage1.png new file mode 100644 index 0000000000000000000000000000000000000000..a568e6c41c3bc0ee066dcb98d4d060eab8e0f3a7 GIT binary patch literal 168 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|l001;Lo9le z6C_v{Gq9h?DgW=kCQ8kV_o#uw=DUCYuU3~g6iE_3%+<76x4=q%wv6zuB{O*J{SI$D zd5|~4`YVgF-R;7iEXq78qOAp4Q$j?NIL>YRvA^sUr`sAf1@8w;FR~b#-zXYB4wz&G Pw2i^j)z4*}Q$iB}|LQkY literal 0 HcmV?d00001 diff --git a/mods/farmersdelight/textures/onions_stage2.png b/mods/farmersdelight/textures/onions_stage2.png new file mode 100644 index 0000000000000000000000000000000000000000..c117c1cd6d38cbefa238cd37fb566479114fb0c2 GIT binary patch literal 235 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|mU_B4hFJ6_ zCrGeHIHv9XU7vK-C@@Q*jdAANcmLyUe|9K+dv(&iZJFrA{}Zo1*upy9NkTf-_zvs( zc{M2~a?1bz|MSm!N88J(){+-v8{b*&V9Z`VFQLVgEj>CxBgXnG%j3_#-%DKcvpv{x zm7&D>g6N@`M!pTln9R=ZU}$4ZGWug7nmqZifkRLr$8yFSPddCjelT<~-ksU^f2&`7 j@`gTe~DWM4fh&zIp literal 0 HcmV?d00001 diff --git a/mods/farmersdelight/textures/rice.png b/mods/farmersdelight/textures/rice.png new file mode 100644 index 0000000000000000000000000000000000000000..d481cd371fc9452a614523425504d8e3729df0f0 GIT binary patch literal 411 zcmV;M0c8G(P)Px$RY^oaR5*>@(XmScVHn5puU6Dict->$6(SBc=nw}XEnzt8)=Jn+9Omq}>3OhPl8 zv6_VypC9{@6EkEiFba#J1Yn97fLtb_ZES`BxUF9UP;YjAMXW!=iqB8K-$N877MC5= zn;kqZnf7Cg?ocowIuMUVHO1#AUnnDrl79Q{PEh~GK&{dp3dCbk%>Yzt4f2ID9+#}^ z`9hg~zeoGA1%S=5%0R7BsWtSO2_3k(JD#6;JDOc^(s`&eXOsANd8XEU;`M!s`>P_; zqMcH)Kr)@RjB=9zsZ>e}`qz*hD;7Xgyl%Qf0T39dRn`MrlvKF9IR6#~(3?m&q$Sf? z%LqF>*hlfY_2&k*_WPx$L`g(JR5*>jlD%pIK@^3*l?k#bEK-XGRu)uH6qGa}u-H#)sjx*FpTTDcX#)|G z7w`pa(pe;!pu!RbC3O&sECyjx$WHttYl`G_cR1(Xd(IvBFXZb5Rc)5k_PcS25a6zO zL?*jn(2tU9bhR$BkGx)|6M{x;O80fdpdTfZUGRKe*1Vk!^7Vr1-98zC`2ONk3tR0s z0Lm!~fLx<%h<$6@j-}EGL1i|k)rOjkGw4UD$vDF48Ls?LXQ#&ii1n!e{$!4sj8U15 zDW@zl*#(zZ9xK6W@=e<}kZcAT__rNPRhuPcJC<^#sa$EQz_TmOohxVy{$#F0dwh7u z>x>Lf(_WOG{1a@)QrnjZg9wDh^Am>CCH`do8~yhgZO2k(GNwaJCj`Ukk|5mB20@ec o+Utx$f9eLd8ytd2IOUJ=1$0S#R(-f2+5i9m07*qoM6N<$f+pIla{vGU literal 0 HcmV?d00001 diff --git a/mods/farmersdelight/textures/rice_panicles_stage0.png b/mods/farmersdelight/textures/rice_panicles_stage0.png new file mode 100644 index 0000000000000000000000000000000000000000..25b445232113163280672291cb695a4022fbfdd4 GIT binary patch literal 174 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|GCW-zLo9le z6C_v1__KVrqR*5l7ITKX$NJCzPwo&b5w+vpVG?|vn}=t{xqmb`&XV}sywMuX^|s)|{4`&vEr?>f}+h%1GG!G_7S UrOc@KH_%Q7Pgg&ebxsLQ0ER9;1ONa4 literal 0 HcmV?d00001 diff --git a/mods/farmersdelight/textures/rice_panicles_stage1.png b/mods/farmersdelight/textures/rice_panicles_stage1.png new file mode 100644 index 0000000000000000000000000000000000000000..86254f50d82de872224f5fde97d69d6a2152d5ec GIT binary patch literal 296 zcmV+@0oVSCP)Px#;z>k7R5*>@k1>iuF%(7bi{LL){OY5S*@KWB%sR4-S%TYe4|eXrPOx{JCNPj9 zoe})cLS9JzSFsqT@HKfMH}{?kyytv=eel1Ts6RC=1=blZ?~guL1e@hIiEz6*(koO? zD@4yZU3TkCMUo99IeH#diJq}t9mzVwL$Yij_@zL1w>1R?>kOwb2EJQCaAkJu1C?i4 zqr$Pyudy76cqNeA6lH|6=g*r4^7)61%>DtCHCSpAJrIDh@PQ4!Z}_5 u0Oxo?3M!jQjfV!3Fx3+b)0(y)%5eoEGPx$Ye_^wR5*>zQZY-zKp1_OmMUlor6^Resdf-S5HbW8rAsH>x;Ys72gJ>SdvWem zr_*+%)_0NM921oQxx_WxMcIC3_bk#!ogk| z=f)7v_fy0-=PjRI8h8!v8E-D1NOv?stKIkR*!HktFGN2&Yb(IZ8<1E=OpIV=BZ8Rt bvvY=TyivEUdK?|v00000NkvXXu0mjffSkH` literal 0 HcmV?d00001 diff --git a/mods/farmersdelight/textures/rice_panicles_stage3.png b/mods/farmersdelight/textures/rice_panicles_stage3.png new file mode 100644 index 0000000000000000000000000000000000000000..cd78dca79733017efd9e3815b62205baec0a1d84 GIT binary patch literal 568 zcmV-80>}M{P)Px$@<~KNR5*=wlD}(OQ545N_cheMhzNa6At{n*KnX3>DfAyO4((9r)`Fo^H_7Bb z(9JQuUQvJiZ{fInK1EWQU)7~d5>s8RRGWKEoo^m75W@}-d& zw$jS!NHSTIM%`oX#zKl-sR`AtMPH72{o*lBN0Kj%1b}Fk6Uy#M`ceYW9$4g(F81CI z(_6*o=PNQEiQ?*;+3%a>=Ng-YVj|A|(6Z8WGJE+7rF=(I;o?pzw$7g>5sCKuh)W+C7iPMpH9y5Xl z77I~-B1eZNbJy^J+M{A28XBkJbR>39QmKt;4=jQ}fQRu1KE&=x+5;=(i=j)2v{sc)&He~I{>|buwHBZdc<0hOS%M$0sa9(-y_#L$iqSa0000 UJUkuT4K#qk)78&qol`;+0H=i{;Q#;t literal 0 HcmV?d00001 diff --git a/mods/farmersdelight/textures/rice_stage1.png b/mods/farmersdelight/textures/rice_stage1.png new file mode 100644 index 0000000000000000000000000000000000000000..0f8f0fb841b7a97a77ef25d6cb7c7ccbf7be1330 GIT binary patch literal 200 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|nmk<`Lo9le z6C_xhC3b{q{8_$AG41202;LN>V+xxqe*RxBW|yLJi($rD`T76T3)Tkw`2Sfq@LPg8 z%k;}1cQK^xj@)B&r!0mo@vAt`i{Bdm(i4C{{NHhhAPEKLvWN9NKMpmp&VLp!|KI4( wuM-Cf{(h*Pqj&T*)6V(lC3!6GKPpvZNHQ~!P%Zhx4Rj5Ir>mdKI;Vst0D+=UBLDyZ literal 0 HcmV?d00001 diff --git a/mods/farmersdelight/textures/rice_stage2.png b/mods/farmersdelight/textures/rice_stage2.png new file mode 100644 index 0000000000000000000000000000000000000000..c3ab4b7ff6212f6bf19d5241ab1986817ca92886 GIT binary patch literal 324 zcmV-K0lWT*P)Px#{z*hZR5*>zQ9Vk;Kp1_Km59iaz(~+4S?hq<><`0Y;EB- zi(3U21~Q06M&f576UNC5u@U^L@8`|;-kT5jmr>Rk{mGKq#U`MrQu58r2+ZQ?@s*iC zotJe+vUQUOc0;y=vd(DR9GKa+YwrRLG%c9ywzbIu{UEwxkS*cne)YqWt;8wIWa`B? zN0Jj{OA{*-1@=QF2P8S+_{^|v4$QXTR8UkYz3mBMw1AQWme&lu2yn_j=M`x7+cN4W1OTE_;Bkoc=KXhP)FC>Bi%WpVAw;KqFr4@XJPxsYQDY8#IB{RJ Wigl<{86*?{0000Px$BuPX;R5*>5ld*2XFc5}6hYExks2T=X8h8T4lC={|JOK-@!6Wb*yhFE)-PkH2 zwVeuGB1N(kk5~%sWE5kks5jZ?yYK(+BtszPo3Z&%KKOX=ZX>dXYwWzLG9GqSNoJ_h-On)TEwnt%s*1lF1A8$V%!5Lw{JBiyRYE?N6)8)ij zf=8S#C#JqY3u*UT-guq^TX2>Uo%rIYYgKt}03N)|)piST8}9C)UZ_>YtSfnWDjJ&` z0RXeEWH5xUPtEf=XSL`BKSOYY)uLx)sgWhbk8NbB84SZhzoRjnE3o(K#sB~S07*qo IM6N<$f-kd{ga7~l literal 0 HcmV?d00001 diff --git a/mods/farmersdelight/textures/rice_supporting.png b/mods/farmersdelight/textures/rice_supporting.png new file mode 100644 index 0000000000000000000000000000000000000000..b2d41020b24591352ae325028ed21ceea7dd2143 GIT binary patch literal 473 zcmV;~0Ve*5P)Px$lSxEDR5*=olCe$#K@f(&J@qUIfe0ZGNX*%4pd)rxYC~s70dGKS;sY3MeFH6g z0xNt0Lue?h)#NT1b7#C53O3=^g6!U%%Tzma^ZzsdKPLdX!+kZm{}2G3o~LR@ig>PA zMh-GwQ9KZo8iMDWck#d90hru>i0*J-0nDD>L_AmMa7$a18UkJG^gIJL1OOM!Z#q3s z0W2d^X19`{Yn`5_W>0Sh43JB1uZk-06JA8skYwc?$}b+riyX$uCbMZmv*mECLI7mE zGSg4?^5D^+pa8bB1dro|sMZUr*>czw2{MLwu8?s;DDzw1JuFfavk`u#?^7=_QeNGf z1-3TO5%`I5N5(7M(iZ)8$ZVQy_TcuaXzr#PmXTw&>9<1y-v%3k%j;h;8WfZ!3O`c= zPrb;JW)T2Jmv&bJn=Qwhu6ryG0)Kr*NX*2*Pv4tN%w6H`VIfiyh<>E`wh0XX{zM)9 zvx2JD*Se!0Nu}&ktz&^L2|Cu3*C23Bz9}rm^X`tSlwC79E2C0&tyBI1mWbm!w1XDQ P00000NkvXXu0mjf!AHsL literal 0 HcmV?d00001 diff --git a/mods/farmersdelight/textures/tomato.png b/mods/farmersdelight/textures/tomato.png new file mode 100644 index 0000000000000000000000000000000000000000..2231e99d7517d4b740c8efd45876d23e8bc8cbdb GIT binary patch literal 361 zcmV-v0ha!WP)Px$BS}O-R5*>zku6WdP!xurHA~j3FwJDwG{LZC%Tm`FEUpTNVRESc4ct=8A0QJ5 z5*$Gh%r-)XT@WKA4F=WB>>##V`Y}cjB)smNbD#HoT=;9LP|2>k@e`cPlV7$BkhE)n zXd@LW(Q#IlZ%tf9GEY#hV&8Fjx_ySL^83;Xk?o0wfE11<9(~8(d5<+5Drpa!LV!fJ zCj>})*c25iiEK}bCezJI64ghG?8|-yVqKU^D;}kftUIAY&UhXS71Fga7AsijU z%_WcH2YMZoyG4UpY|*N}m!?i{Fg0p?ye-zj1_r)z8_i-X7gtNg>rttThGwzF)TrfZ zxo_z^zI0d1+^E@(8rJ)l473SAceTvrx4~Ntibh&R@c-x&@JVkMYbYo000000NkvXX Hu0mjf0&$o4 literal 0 HcmV?d00001 diff --git a/mods/farmersdelight/textures/tomato_seeds.png b/mods/farmersdelight/textures/tomato_seeds.png new file mode 100644 index 0000000000000000000000000000000000000000..6691bffcd9d75be1ea1844d0bdc7e47d28ce314f GIT binary patch literal 288 zcmV+*0pI?KP)Px#+DSw~R5*=eU>Nk^$1(l?$4gBA^Y4H6DWX%6HWsrxCs3>H&A9U6#B)$ mQFReR9v!ft3lJU3)B*shQEnEFQT)3A0000Px$MM*?KR5*=&lf8<<{j1S{Vl#3rpp zNcyRSq_hgNh1?-AKT~DGJ@=e*?-|9!*&QMW5SoTEt0*qH`mE{w5MXE;Y8&vhPk=!% zfRbW>+wt!2WmZiBI|_D($VInq;cZah$WFpV2!^Qms}O( pK6sNkZ@-JNH!&Ln%NC}<0RMo2%a?enCmjF)002ovPDHLkV1kpbumu1B literal 0 HcmV?d00001 diff --git a/mods/farmersdelight/textures/tomatoes_stage1.png b/mods/farmersdelight/textures/tomatoes_stage1.png new file mode 100644 index 0000000000000000000000000000000000000000..bd27f0ba4b5ec096678e3cc181bab3d01dc7ac64 GIT binary patch literal 448 zcmV;x0YCnUP)Px$dPzh3>kWvaxy@euzLvKLnAav+0 zbP`I344rFr$yf(Xlx_hbU`B@$P6s(@;!pZb$>Dp?`;#{Y2~+Ph6hKx6IMxb#Fg3P! zb`CT!D+7Eth39$zd%*yPUIs9`5|24$>aT(0bnx)8VXYTEdVt8 zH3i^UD+<-zUbzP|X!dK$u~wmP03k)FDoRo=WMWp10DL!vJ(wE3c7>bEV*otYquH-1 zosA}WeR1*KRH*o%%wnsg01DL{zWe7rn$_rOXzWPTiu7`^RZ`m8zD}g0;Bp}Yz=U$3fO%2&1^yp5K_=XkNUhrRddVT?SYu6}0)nvl}0000Px$bxA})R5*==lRs<1Kp4hU?Gd?Qiq6xO9vMv(4kwM3U=w-p+iCN3v?F( zg)aRDb+w;BbcxbMM9g3*m@Yybr9*lh${k6J_MPsI_j#W`yeBwNjkYZT3TBAs1}u7W zk?h%dP{4v2vhg#l{WU-;7(l3IfPQDB@17eR1jZCJ+P1VWa!kFgW;INMwZG>2)&yYc zZRvML`z=KMZu|_7MW3_tBi>%N^ok`EL2^h|9fr<8t0|Zvv+*~x2|T>61grpCLMGh; zK(kwy0G=CQ)lO37?#-attxL}hv~K{zG_Luxcl4 z{0u{9AQXujUNA%Yosoz!Jl&j1b$*t|u_0+$4V{75kqBtO&>4twt0I-Pw4KOC!Br~{ zz?5xlk&Lz>6>D_qVj)J?HW^^KRngXx8Dy2@C}6={H!If5@uv=XHd)f6gjTSxqW@yi ln+p~4-*Rzyz<=SX`UOsA)vsaYAv6F0002ovPDHLkV1miD!JYsB literal 0 HcmV?d00001 diff --git a/mods/farmersdelight/textures/tomatoes_stage3.png b/mods/farmersdelight/textures/tomatoes_stage3.png new file mode 100644 index 0000000000000000000000000000000000000000..b1c1e6ce718b148748cd3367947998112d505884 GIT binary patch literal 509 zcmVPx$w@E}nR5*=&lQBypK^TUgb%SEAI96`8m?l+%a26?)!$>@PQ-~rKR+sX$2;^r3 zQfOl#9C(F@ViEs71xqFTFNMU4xr9xI^SH`*XI>yx% zF23|x-xdJec^xXn`o|H%c>`&aI{!zy-{p2}g63KbZ7|p*rax-ss+q-y26AA=}PgfS@5e#yrjPe?7lN-Plu9+%q zGMAi;L>U7Jq|NSioIjuE*}aYf;7gxeDWfzSZF2To5=h%jY#j25MV0P%`8wU=s3oW^ z1OOx#rU>L)_AskjxoSm5%qJEVKyxi-ic_1jN=F;E6A_3r$w>fSyiR11+=8pLYk27* z5W{Ob2r#udtHQ3XaB)PBO0jOmG{mr=$%84@uG9O9bid2qw^z2#{&Kwji3r4DC;ToB z9$#5r-Qe=#l>3)2>^$FCBO45Zry(CcT^ZefdZFm#@WjEl00000NkvXXu0mjfdavMj literal 0 HcmV?d00001 diff --git a/server/game/game_server.ts b/server/game/game_server.ts index 9ed8414..152247f 100644 --- a/server/game/game_server.ts +++ b/server/game/game_server.ts @@ -27,7 +27,7 @@ import { import type { ModListing, RecipeBook } from "$/common/mod_loader.ts"; import type { WorldgenSetup } from "$/common/generation.ts"; import { CYCLE_TICKS, format_clock, time_of_day, TIMES_OF_DAY } from "$/common/time.ts"; -import { can_stand_on } from "$/common/utils.ts"; +import { can_place, can_stand_on, placement_target } from "$/common/utils.ts"; import { EXHAUSTION, MAX_HEALTH } from "./vitals.ts"; import { ModRuntime, run_guarded } from "./mod_runtime.ts"; import type { GameLoop } from "./game_loop.ts"; @@ -705,15 +705,17 @@ export class GameServer { } } - // the held item's on_use handlers, returns whether it has any + // right click at nothing: eating, or the item's on_use #use_item(player: ServerPlayer): boolean { + return this.#eat(player) || this.#use_item_components(player); + } + + // the held item's on_use handlers, returns whether it has any + #use_item_components(player: ServerPlayer): boolean { const held = player.held_item; if (!held) { return false; } - if (this.#eat(player)) { - return true; - } const components = this.mods.item_components_of(held.type_id).filter(({ component }) => component.on_use); if (components.length === 0) { return false; @@ -727,10 +729,10 @@ export class GameServer { } #use_block(player: ServerPlayer, x: number, y: number, z: number, face: Faces) { - const offset = FACE_OFFSETS[face]; - const [tx, ty, tz] = [x + offset.x, y + offset.y, z + offset.z]; - const info = this.world.get_block_info(x, y, z); + const target = placement_target(x, y, z, FACE_OFFSETS[face], info); + const [tx, ty, tz] = [target.x, target.y, target.z]; + if (!info || !this.#in_reach(player, x, y, z)) { this.#correct(player, x, y, z); this.#correct(player, tx, ty, tz); @@ -763,21 +765,23 @@ export class GameServer { } // an item that does something when used does that instead of being placed - if (this.#use_item(player)) { + if (this.#use_item_components(player)) { this.#correct(player, tx, ty, tz); return; } - // place the held block against the face + // place the held block against the face, or into the clicked block if it's replaceable. food that can be planted, + // like a potato on farmland, is planted, and eaten when it can't be const held_slot = player.inventory.get_slot(player.selected_slot); const held = EverythingRegistry.get("items", held_slot.type_id ?? ""); - if ( - !held?.block_id || ty < 0 || ty >= CHUNK_HEIGHT || !this.#replaceable(tx, ty, tz) || - !can_stand_on( + const placeable = held?.block_id !== undefined && ty >= 0 && ty < CHUNK_HEIGHT && + can_place( EverythingRegistry.get("blocks", held.block_id), + this.world.get_block_info(tx, ty, tz), this.world.get_block_id(tx, ty - 1, tz), - ) - ) { + ); + if (!placeable || !held?.block_id) { + this.#eat(player); this.#correct(player, tx, ty, tz); return; } @@ -1282,11 +1286,6 @@ export class GameServer { this.#send(player, { type: "set_block", x, y, z, id: this.world.get_block_id(x, y, z) }); } - #replaceable(x: number, y: number, z: number) { - const nid = this.world.get_block_nid(x, y, z); - return nid === AIR || (EverythingRegistry.get_by_id("blocks", nid)?.replaceable ?? false); - } - #in_reach(player: ServerPlayer, x: number, y: number, z: number) { const dx = x + 0.5 - player.x; const dy = y + 0.5 - (player.y + PLAYER_EYE_HEIGHT); diff --git a/server/game/mod_runtime.ts b/server/game/mod_runtime.ts index f5826d9..f6b3db3 100644 --- a/server/game/mod_runtime.ts +++ b/server/game/mod_runtime.ts @@ -345,6 +345,11 @@ export class ModRuntime { game().set_block(x, y, z, id); return true; }, + break_block: (x, y, z) => { + if (game().world.get_block_id(x, y, z) === AIR_ID) return false; + game().destroy_block(x, y, z); + return true; + }, get_state: (x, y, z, name) => { const id = game().world.get_block_id(x, y, z); if (id === AIR_ID) return undefined; diff --git a/tests/bmod_test.ts b/tests/bmod_test.ts index 0f98f8b..e662e1b 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, 21); + assertEquals(bworld.data.blocks.length, 23); assertEquals(Object.keys(bworld.scripts), ["server"]); Deno.removeSync(sources, { recursive: true }); diff --git a/tests/farming_test.ts b/tests/farming_test.ts index 242b826..25021f0 100644 --- a/tests/farming_test.ts +++ b/tests/farming_test.ts @@ -141,3 +141,102 @@ Deno.test("crops grow far from every player, and mornings skipped by /time still // the world's day is the same one scripts see assertEquals(t.game.world.day, 4); }); + +// plants a crop on farmland at x, 100, 0 and waters it every day for days mornings, returning its age each morning +function grow(t: Awaited>, x: number, crop: string, days: number) { + t.game.set_block(x, 100, 0, "bworld:hoed_dirt"); + t.game.set_block(x, 101, 0, crop); + const ages: number[] = []; + for (let day = 0; day < days; day++) { + t.game.set_block_state(x, 100, 0, 1); + t.next_morning(); + ages.push(t.state(x, 101, 0, "age")!); + } + return ages; +} + +Deno.test("each crop takes its own number of watered days to grow", async () => { + const t = await setup(); + // the stage for each morning, spread over its days, fully grown on the last one + assertEquals(grow(t, 0, "bworld:carrots", 3), [1, 2, 3]); + assertEquals(grow(t, 1, "bworld:potatoes", 6), [0, 1, 1, 2, 2, 3]); + assertEquals(grow(t, 2, "bworld:wheat", 7), [1, 2, 3, 4, 5, 6, 7]); + assertEquals(grow(t, -1, "farmersdelight:onions", 4), [0, 1, 2, 3]); + const cabbage = grow(t, -2, "farmersdelight:cabbages", 12); + assertEquals(cabbage.at(-2), 6, "not grown a day early"); + assertEquals(cabbage.at(-1), 7); + + // grown crops stay grown + t.game.set_block_state(0, 100, 0, 1); + t.next_morning(); + assertEquals(t.state(0, 101, 0, "age"), 3); +}); + +Deno.test("potatoes and carrots are planted on farmland, and eaten anywhere else", async () => { + const t = await setup(["bworld:potato 3"]); + t.game.set_block(1, 100, 0, "bworld:hoed_dirt"); + t.game.players()[0].vitals.food = 10; + t.hold("bworld:potato"); + t.use(1, 100, 0); + assertEquals(t.game.world.get_block_id(1, 101, 0), "bworld:potatoes"); + assertEquals(t.game.players()[0].vitals.food, 10, "planted, not eaten"); + // on stone it can't be planted, so it's eaten + t.use(0, 99, 1); + assertEquals(t.game.world.get_block_id(0, 100, 1), "bworld:air"); + assertEquals(t.game.players()[0].vitals.food, 11); +}); + +Deno.test("tomatoes take 11 days, are picked by hand, and grow back in 4", async () => { + const t = await setup(); + const ages = grow(t, 1, "farmersdelight:tomatoes", 11); + assertEquals(ages.at(-1), 7); + assertEquals(ages.at(-2), 6); + + t.use(1, 101, 0); + const picked = t.game.item_entities().map((e) => e.item.to_data()); + assertEquals(picked.length, 1); + assertEquals(picked[0].id, "farmersdelight:tomato"); + assert(picked[0].count >= 1 && picked[0].count <= 2); + assertEquals(t.game.world.get_block_id(1, 101, 0), "farmersdelight:tomatoes", "the plant stays"); + assertEquals(t.state(1, 101, 0, "age"), 4, "back to a young vine"); + + // 3 watered mornings isn't enough, the 4th is + for (let day = 0; day < 4; day++) { + t.game.set_block_state(1, 100, 0, 1); + t.next_morning(); + assertEquals(t.state(1, 101, 0, "age"), day < 3 ? Math.floor((7 + day + 1) * 7 / 11) : 7); + } +}); + +Deno.test("rice is planted in water, grows panicles on top without watering, and leaves its water when harvested", async () => { + const t = await setup(["farmersdelight:rice 2"]); + t.game.set_block(1, 99, 0, "bworld:dirt"); + t.game.set_block(1, 100, 0, "bworld:water"); + t.game.set_block(2, 100, 0, "bworld:hoed_dirt"); + + // not on land + t.hold("farmersdelight:rice"); + t.use(2, 100, 0); + assertEquals(t.game.world.get_block_id(2, 101, 0), "bworld:air"); + // into the water, standing on the dirt under it + t.use(1, 100, 0); + assertEquals(t.game.world.get_block_id(1, 100, 0), "farmersdelight:rice"); + + for (let day = 0; day < 3; day++) t.next_morning(); + assertEquals(t.state(1, 100, 0, "age"), 3); + assertEquals(t.game.world.get_block_id(1, 101, 0), "bworld:air"); + for (let day = 0; day < 3; day++) t.next_morning(); + assertEquals(t.game.world.get_block_id(1, 101, 0), "farmersdelight:rice_panicles"); + assertEquals(t.state(1, 101, 0, "age"), 3, "fully grown after 6 days"); + assertEquals(t.state(1, 100, 0, "age"), 4, "the stalk holding them up"); + + // breaking the panicles harvests the whole plant + t.send(1, { type: "break_block", x: 1, y: 101, z: 0 }); + // the stalk goes the next tick, and its water comes back the one after + t.game.tick(); + t.game.tick(); + const dropped = t.game.item_entities().map((e) => e.item.type_id).sort(); + assertEquals(dropped, ["farmersdelight:rice", "farmersdelight:rice_panicle"]); + assertEquals(t.game.world.get_block_id(1, 100, 0), "bworld:water"); + assertEquals(t.game.world.get_block_id(1, 101, 0), "bworld:air"); +}); diff --git a/tests/handshake_test.ts b/tests/handshake_test.ts index 625b13c..399c76f 100644 --- a/tests/handshake_test.ts +++ b/tests/handshake_test.ts @@ -29,7 +29,7 @@ Deno.test("welcome lists what to download, and nothing happens until ready", asy send(2, { type: "hello", name: "bob", protocol: PROTOCOL_VERSION }); const [welcome] = take(2); assertEquals(welcome.type, "welcome"); - assertEquals(welcome.mods.map((m: { id: string }) => m.id), ["bworld"]); + assertEquals(welcome.mods.map((m: { id: string }) => m.id), ["bworld", "farmersdelight"]); assert(welcome.mods.every((m: { sha256: string; file: string }) => m.sha256 && m.file)); assert(!("players" in welcome) && !("changes" in welcome), "welcome shouldn't have world state"); diff --git a/tests/mod_loading_test.ts b/tests/mod_loading_test.ts index 22a8a22..87fd08b 100644 --- a/tests/mod_loading_test.ts +++ b/tests/mod_loading_test.ts @@ -23,9 +23,10 @@ const inventory_of = (messages: Msg[]) => Deno.test("the base game loads from mods/bworld", async () => { const { game } = await test_game("mods"); - assertEquals(EverythingRegistry.entries("blocks").length, 21); + const bworld = (entries: [string, unknown][]) => entries.filter(([id]) => id.startsWith("bworld:")).length; + assertEquals(bworld(EverythingRegistry.entries("blocks")), 23); // 17 items plus the item forms of the 18 blocks that have one - assertEquals(EverythingRegistry.entries("items").length, 35); + assertEquals(bworld(EverythingRegistry.entries("items")), 35); assertEquals(game.recipes.shaped.length, 5); assertEquals(game.recipes.furnace.size, 6); assertEquals(game.recipes.fuel.size, 2); @@ -77,6 +78,8 @@ Deno.test("a mod made from the template loads and runs", async () => { send(1, { type: "select_slot", slot: inventory.findIndex((i: Msg) => i?.id === "copper_tools:example_block") }); let y = CHUNK_HEIGHT - 1; while (game.world.get_block_nid(1, y, 1) === AIR) y--; + // solid ground to build on: placing into water would replace it + game.set_block(1, y, 1, "bworld:stone"); send(1, { type: "move", x: 2.5, y: y + 1, z: 2.5, yaw: 0, pitch: 0 }); send(1, { type: "use_block", x: 1, y, z: 1, face: "top" }); assertEquals(game.world.get_block_id(1, y + 1, 1), "copper_tools:example_block");