Add a bunch of crops and farmer's delight crops

This commit is contained in:
2026-09-26 21:35:17 -03:00
parent 8d9c85d379
commit 7e5bcaa239
77 changed files with 980 additions and 81 deletions
+60
View File
@@ -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"
}
}
}
}
}
+60
View File
@@ -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"
}
}
}
}
}
+12 -9
View File
@@ -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"
]
}
}
}
+2 -1
View File
@@ -6,6 +6,7 @@
"food": {
"nutrition": 3,
"saturation_modifier": 0.6
}
},
"places": "bworld:carrots"
}
}
+2 -1
View File
@@ -6,6 +6,7 @@
"food": {
"nutrition": 1,
"saturation_modifier": 0.3
}
},
"places": "bworld:potatoes"
}
}
+129 -29
View File
@@ -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<CropParams>("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<CropTopParams>("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);
},
});
Binary file not shown.

After

Width:  |  Height:  |  Size: 192 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 185 B

+28
View File
@@ -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.
```
+80
View File
@@ -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"
}
}
}
}
}
+60
View File
@@ -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"
}
}
}
}
}
+76
View File
@@ -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"
}
}
}
}
}
@@ -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"
}
}
}
}
}
+90
View File
@@ -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"
]
}
}
}
}
}
+11
View File
@@ -0,0 +1,11 @@
{
"format_version": 1,
"item": {
"id": "farmersdelight:cabbage",
"texture": "farmersdelight:cabbage",
"food": {
"nutrition": 2,
"saturation_modifier": 0.4
}
}
}
@@ -0,0 +1,8 @@
{
"format_version": 1,
"item": {
"id": "farmersdelight:cabbage_seeds",
"texture": "farmersdelight:cabbage_seeds",
"places": "farmersdelight:cabbages"
}
}
+12
View File
@@ -0,0 +1,12 @@
{
"format_version": 1,
"item": {
"id": "farmersdelight:onion",
"texture": "farmersdelight:onion",
"places": "farmersdelight:onions",
"food": {
"nutrition": 2,
"saturation_modifier": 0.4
}
}
}
+8
View File
@@ -0,0 +1,8 @@
{
"format_version": 1,
"item": {
"id": "farmersdelight:rice",
"texture": "farmersdelight:rice",
"places": "farmersdelight:rice"
}
}
@@ -0,0 +1,7 @@
{
"format_version": 1,
"item": {
"id": "farmersdelight:rice_panicle",
"texture": "farmersdelight:rice_panicle"
}
}
+11
View File
@@ -0,0 +1,11 @@
{
"format_version": 1,
"item": {
"id": "farmersdelight:tomato",
"texture": "farmersdelight:tomato",
"food": {
"nutrition": 1,
"saturation_modifier": 0.3
}
}
}
@@ -0,0 +1,8 @@
{
"format_version": 1,
"item": {
"id": "farmersdelight:tomato_seeds",
"texture": "farmersdelight:tomato_seeds",
"places": "farmersdelight:tomatoes"
}
}
+19
View File
@@ -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"
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 151 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 290 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 342 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 417 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 286 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 297 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 399 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 383 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 325 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 411 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 394 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 174 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 296 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 433 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 568 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 324 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 362 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 473 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 288 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 395 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 448 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 443 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 509 B