Melon and pumpkin

This commit is contained in:
2026-10-10 15:34:59 -03:00
parent 6dc85ff17e
commit ceb1b1f0f0
15 changed files with 319 additions and 1 deletions
+1
View File
@@ -108,6 +108,7 @@ and 1 to 4 seeds, like Minecraft's wheat:
| `upper` | `{ block, stages, supporting_age }`: its last stages grow a second block on top, see below. |
| `leaves` | What the spot becomes when it's broken, like the water rice was planted in. |
| `seasons` | The [seasons](../worldgen/biomes.md#seasons) it grows in, like `["spring", "summer"]`. A morning in any other season turns it into a dead bush. Every season when not set. |
| `ripe` | The block it turns into the morning it's fully grown, like `bworld:pumpkin`. Its stages spread over the days before, the last one the day before it ripens. |
## Harvesting By Hand
+16
View File
@@ -0,0 +1,16 @@
{
"format_version": 1,
"block": {
"id": "bworld:melon",
"textures": {
"top": "bworld:melon_top",
"bottom": "bworld:melon_bottom",
"side": "bworld:melon_side"
},
"mining": {
"toughness": 1.5,
"tool": "axe"
},
"loot_table": "bworld:blocks/melon"
}
}
+80
View File
@@ -0,0 +1,80 @@
{
"format_version": 1,
"block": {
"id": "bworld:melon_plant",
"textures": {
"crop": "bworld:melon_stage_0"
},
"model": "engine:crop",
"variants": {
"age=0": {
"textures": {
"crop": "bworld:melon_stage_0"
}
},
"age=1": {
"textures": {
"crop": "bworld:melon_stage_1"
}
},
"age=2": {
"textures": {
"crop": "bworld:melon_stage_2"
}
},
"age=3": {
"textures": {
"crop": "bworld:melon_stage_3"
}
},
"age=4": {
"textures": {
"crop": "bworld:melon_stage_4"
}
},
"age=5": {
"textures": {
"crop": "bworld:melon_stage_5"
}
},
"age=6": {
"textures": {
"crop": "bworld:melon_stage_6"
}
},
"age=7": {
"textures": {
"crop": "bworld:melon_stage_7"
}
}
},
"render_layer": "cutout",
"collision": false,
"mining": {
"toughness": 0
},
"drops": "bworld:melon_seeds",
"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",
"ripe": "bworld:melon",
"seasons": [
"summer"
]
}
}
}
}
+16
View File
@@ -0,0 +1,16 @@
{
"format_version": 1,
"block": {
"id": "bworld:pumpkin",
"textures": {
"top": "bworld:pumpkin_top",
"bottom": "bworld:pumpkin_bottom",
"side": "bworld:pumpkin_side"
},
"mining": {
"toughness": 1.5,
"tool": "axe"
},
"drops": "bworld:pumpkin"
}
}
+80
View File
@@ -0,0 +1,80 @@
{
"format_version": 1,
"block": {
"id": "bworld:pumpkin_plant",
"textures": {
"crop": "bworld:pumpkin_stage_0"
},
"model": "engine:crop",
"variants": {
"age=0": {
"textures": {
"crop": "bworld:pumpkin_stage_0"
}
},
"age=1": {
"textures": {
"crop": "bworld:pumpkin_stage_1"
}
},
"age=2": {
"textures": {
"crop": "bworld:pumpkin_stage_2"
}
},
"age=3": {
"textures": {
"crop": "bworld:pumpkin_stage_3"
}
},
"age=4": {
"textures": {
"crop": "bworld:pumpkin_stage_4"
}
},
"age=5": {
"textures": {
"crop": "bworld:pumpkin_stage_5"
}
},
"age=6": {
"textures": {
"crop": "bworld:pumpkin_stage_6"
}
},
"age=7": {
"textures": {
"crop": "bworld:pumpkin_stage_7"
}
}
},
"render_layer": "cutout",
"collision": false,
"mining": {
"toughness": 0
},
"drops": "bworld:pumpkin_seeds",
"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",
"ripe": "bworld:pumpkin",
"seasons": [
"autumn"
]
}
}
}
}
+7
View File
@@ -0,0 +1,7 @@
{
"format_version": 1,
"item": {
"id": "bworld:melon",
"base_sell_value": 60
}
}
+8
View File
@@ -0,0 +1,8 @@
{
"format_version": 1,
"item": {
"id": "bworld:melon_seeds",
"texture": "bworld:melon_seed",
"places": "bworld:melon_plant"
}
}
+12
View File
@@ -0,0 +1,12 @@
{
"format_version": 1,
"item": {
"id": "bworld:melon_slice",
"texture": "bworld:melon",
"food": {
"nutrition": 2,
"saturation_modifier": 0.3
},
"base_sell_value": 10
}
}
+7
View File
@@ -0,0 +1,7 @@
{
"format_version": 1,
"item": {
"id": "bworld:pumpkin",
"base_sell_value": 80
}
}
+8
View File
@@ -0,0 +1,8 @@
{
"format_version": 1,
"item": {
"id": "bworld:pumpkin_seeds",
"texture": "bworld:melon_seed",
"places": "bworld:pumpkin_plant"
}
}
+18
View File
@@ -0,0 +1,18 @@
{
"format_version": 1,
"loot_table": {
"pools": [
{
"entries": [
{
"item": "bworld:melon_slice",
"count": {
"min": 3,
"max": 7
}
}
]
}
]
}
}
@@ -0,0 +1,16 @@
{
"format_version": 1,
"recipe": {
"type": "shaped",
"pattern": [
"I"
],
"key": {
"I": "bworld:melon_slice"
},
"result": {
"id": "bworld:melon_seeds",
"count": 1
}
}
}
@@ -0,0 +1,16 @@
{
"format_version": 1,
"recipe": {
"type": "shaped",
"pattern": [
"I"
],
"key": {
"I": "bworld:pumpkin"
},
"result": {
"id": "bworld:pumpkin_seeds",
"count": 4
}
}
}
+9 -1
View File
@@ -360,6 +360,9 @@ interface CropParams {
upper?: { block: string; stages: number; supporting_age: number };
// what the spot becomes when it's broken, like water where rice was
leaves?: string;
// the block it turns into the morning it's fully grown, like a pumpkin. its stages come before that, the last one
// the day before
ripe?: string;
// the seasons it grows in. a morning in any other season turns it into a dead bush. every season when not set
seasons?: Season[];
}
@@ -428,7 +431,8 @@ function register_farming(ctx: ServerContext) {
// 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);
// becoming the ripe block is a stage too, the last
const stages = params.stages + (params.upper?.stages ?? 0) + (params.ripe ? 1 : 0);
return Math.min(stages - 1, Math.floor(days * (stages - 1) / params.days));
};
@@ -443,6 +447,10 @@ function register_farming(ctx: ServerContext) {
// 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) => {
if (params.ripe && days >= params.days) {
ctx.world.set_block(block.x, block.y, block.z, params.ripe);
return;
}
block.data = { ...block.data, days };
const stage = stage_for(params, days);
const upper = params.upper;
+25
View File
@@ -306,3 +306,28 @@ Deno.test("beetroots, cotton and strawberries grow, and strawberries and cotton
}
assertEquals(t.state(2, 101, 0, "age"), 7);
});
Deno.test("a pumpkin plant becomes a pumpkin the morning it's grown, and a melon breaks into slices", async () => {
const t = await setup(["bworld:bone_meal 64"]);
// pumpkins grow in autumn, from day 99
t.game.set_time(98 * CYCLE_TICKS);
t.game.tick();
// every stage shows, the last the day before
const ages = grow(t, 0, "bworld:pumpkin_plant", 11);
assertEquals(ages, [0, 1, 2, 2, 3, 4, 4, 5, 6, 6, 7]);
t.game.set_block_state(0, 100, 0, 1);
t.next_morning();
assertEquals(t.game.world.get_block_id(0, 101, 0), "bworld:pumpkin");
assertEquals(t.game.world.get_tile(0, 101, 0), undefined, "no crop data left behind");
// bone meal ripens it too
t.game.set_block(1, 100, 0, "bworld:hoed_dirt");
t.game.set_block(1, 101, 0, "bworld:melon_plant");
t.hold("bworld:bone_meal");
for (let i = 0; i < 12; i++) t.use(1, 101, 0);
assertEquals(t.game.world.get_block_id(1, 101, 0), "bworld:melon");
t.send(1, { type: "break_block", x: 1, y: 101, z: 0 });
const slices = t.game.item_entities().map((e) => e.item.to_data());
assertEquals(slices.map((item) => item.id), ["bworld:melon_slice"]);
assert(slices[0].count >= 3 && slices[0].count <= 7);
});