This commit is contained in:
2026-10-25 16:57:38 -03:00
parent feb1ddd1f7
commit 08df7f1b6b
16 changed files with 306 additions and 19 deletions
+20
View File
@@ -0,0 +1,20 @@
{
"format_version": 1,
"block": {
"id": "bworld:juicer",
"name": "Juicer",
"textures": {},
"model": "bworld:juicer",
"item_model": "bworld:juicer",
"render_layer": "cutout",
"mining": {
"toughness": 2,
"tool": "pickaxe"
},
"drops": "bworld:juicer",
"interactive": true,
"components": {
"bworld:juicer": {}
}
}
}
+1 -1
View File
@@ -11,6 +11,6 @@
"toughness": 1.5,
"tool": "axe"
},
"loot_table": "bworld:blocks/melon"
"drops": "bworld:melon"
}
}
+4 -1
View File
@@ -8,6 +8,9 @@
"saturation_modifier": 0.6
},
"places": "bworld:beetroots",
"base_sell_value": 25
"base_sell_value": 25,
"components": {
"bworld:juiceable": { "juice": 200, "color": "#e84c6e" }
}
}
}
+4 -1
View File
@@ -8,6 +8,9 @@
"saturation_modifier": 0.6
},
"places": "bworld:carrots",
"base_sell_value": 12
"base_sell_value": 12,
"components": {
"bworld:juiceable": { "juice": 200, "color": "#c87f4b" }
}
}
}
+4 -1
View File
@@ -2,6 +2,9 @@
"format_version": 1,
"item": {
"id": "bworld:melon",
"base_sell_value": 60
"base_sell_value": 60,
"components": {
"bworld:juiceable": { "juice": 1000, "color": "#aa3d33" }
}
}
}
+4 -1
View File
@@ -8,6 +8,9 @@
"saturation_modifier": 0.3
},
"places": "bworld:potatoes",
"base_sell_value": 20
"base_sell_value": 20,
"components": {
"bworld:juiceable": { "juice": 200, "color": "#c48a3f" }
}
}
}
+4 -1
View File
@@ -2,6 +2,9 @@
"format_version": 1,
"item": {
"id": "bworld:pumpkin",
"base_sell_value": 80
"base_sell_value": 80,
"components": {
"bworld:juiceable": { "juice": 1000, "color": "#ea8734" }
}
}
}
+4 -1
View File
@@ -7,6 +7,9 @@
"nutrition": 2,
"saturation_modifier": 0.3
},
"base_sell_value": 30
"base_sell_value": 30,
"components": {
"bworld:juiceable": { "juice": 200, "color": "#ff2840" }
}
}
}
+110
View File
@@ -0,0 +1,110 @@
{
"format_version": 1,
"model": {
"id": "bworld:juicer",
"textures": {
"0": "bworld:juicer_side",
"1": "bworld:juicer_bottom",
"2": "bworld:juicer_top",
"particle": "bworld:juicer_side"
},
"elements": [
{
"from": [0, 0, 0],
"to": [16, 2, 16],
"faces": {
"north": { "texture": "#0", "uv": [0, 0, 16, 2] },
"east": { "texture": "#0", "uv": [0, 0, 16, 2] },
"south": { "texture": "#0", "uv": [0, 0, 16, 2] },
"west": { "texture": "#0", "uv": [0, 0, 16, 2] },
"top": { "texture": "#1", "uv": [0, 0, 16, 16] },
"bottom": { "texture": "#1", "uv": [0, 0, 16, 16] }
}
},
{
"from": [0, 2, 0],
"to": [2, 14, 2],
"faces": {
"north": { "texture": "#0", "uv": [0, 0, 2, 12] },
"east": { "texture": "#0", "uv": [0, 0, 2, 12] },
"south": { "texture": "#0", "uv": [0, 0, 2, 12] },
"west": { "texture": "#0", "uv": [0, 0, 2, 12] },
"top": { "texture": "#0", "uv": [0, 0, 2, 2] },
"bottom": { "texture": "#0", "uv": [0, 0, 2, 2] }
}
},
{
"from": [14, 2, 0],
"to": [16, 14, 2],
"faces": {
"north": { "texture": "#0", "uv": [0, 0, 2, 12] },
"east": { "texture": "#0", "uv": [0, 0, 2, 12] },
"south": { "texture": "#0", "uv": [0, 0, 2, 12] },
"west": { "texture": "#0", "uv": [0, 0, 2, 12] },
"top": { "texture": "#0", "uv": [0, 0, 2, 2] },
"bottom": { "texture": "#0", "uv": [0, 0, 2, 2] }
}
},
{
"from": [14, 2, 14],
"to": [16, 14, 16],
"faces": {
"north": { "texture": "#0", "uv": [0, 0, 2, 12] },
"east": { "texture": "#0", "uv": [0, 0, 2, 12] },
"south": { "texture": "#0", "uv": [0, 0, 2, 12] },
"west": { "texture": "#0", "uv": [0, 0, 2, 12] },
"top": { "texture": "#0", "uv": [0, 0, 2, 2] },
"bottom": { "texture": "#0", "uv": [0, 0, 2, 2] }
}
},
{
"from": [0, 2, 14],
"to": [2, 14, 16],
"faces": {
"north": { "texture": "#0", "uv": [0, 0, 2, 12] },
"east": { "texture": "#0", "uv": [0, 0, 2, 12] },
"south": { "texture": "#0", "uv": [0, 0, 2, 12] },
"west": { "texture": "#0", "uv": [0, 0, 2, 12] },
"top": { "texture": "#0", "uv": [0, 0, 2, 2] },
"bottom": { "texture": "#0", "uv": [0, 0, 2, 2] }
}
},
{
"from": [0, 14, 0],
"to": [16, 16, 16],
"faces": {
"north": { "texture": "#0", "uv": [0, 0, 16, 2] },
"east": { "texture": "#0", "uv": [0, 0, 16, 2] },
"south": { "texture": "#0", "uv": [0, 0, 16, 2] },
"west": { "texture": "#0", "uv": [0, 0, 16, 2] },
"top": { "texture": "#2", "uv": [0, 0, 16, 16] },
"bottom": { "texture": "#1", "uv": [0, 0, 16, 16] }
}
},
{
"from": [5, 8, 5],
"to": [11, 10, 11],
"faces": {
"north": { "texture": "#0", "uv": [5, 0, 11, 2] },
"east": { "texture": "#0", "uv": [5, 0, 11, 2] },
"south": { "texture": "#0", "uv": [5, 0, 11, 2] },
"west": { "texture": "#0", "uv": [5, 0, 11, 2] },
"top": { "texture": "#2", "uv": [5, 5, 11, 11] },
"bottom": { "texture": "#1", "uv": [5, 5, 11, 11] }
}
},
{
"from": [7, 10, 7],
"to": [9, 14, 9],
"faces": {
"north": { "texture": "#0", "uv": [0, 0, 2, 4] },
"east": { "texture": "#0", "uv": [0, 0, 2, 4] },
"south": { "texture": "#0", "uv": [0, 0, 2, 4] },
"west": { "texture": "#0", "uv": [0, 0, 2, 4] },
"top": { "texture": "#0", "uv": [0, 0, 2, 2] },
"bottom": { "texture": "#0", "uv": [0, 0, 2, 2] }
}
}
]
}
}
+72 -4
View File
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
// the base game's block and item behavior, written against the same api as any other mod
import type { BlockRef, Container, Player, Season, ServerContext } from "bworld/server";
import type { BlockRef, Container, FluidVariant, Player, Season, ServerContext } from "bworld/server";
import { register_curios } from "./curios.ts";
import { register_effects } from "./effects.ts";
import { register_fishing } from "./fishing.ts";
@@ -25,9 +25,7 @@ export function setup(ctx: ServerContext) {
register_door(ctx);
register_trapdoor(ctx);
register_buckets(ctx);
// what juice is made from, read by whatever makes it, like create's press. the juice's name and color are in
// shared.ts
ctx.components.register_item<JuiceableParams>("bworld:juiceable", {});
register_juicer(ctx);
register_curios(ctx);
register_effects(ctx);
register_growable_block(ctx);
@@ -850,6 +848,76 @@ function register_buckets(ctx: ServerContext) {
});
}
// the juicer has no screen. right clicking it with something juiceable puts that in, one kind at a time, and
// pressing it (sneaking with an empty hand) JUICER_PRESSES times turns one of it into its juice, while that fits in the
// tank. right clicking it with an empty fluid container fills it from the tank. breaking it drops what's in it, and the
// juice is lost
const JUICE = "bworld:juice";
const JUICER_PRESSES = 4;
const JUICER_CAPACITY = 1000;
interface JuicerData {
container?: string;
// how many times it's been pressed toward the next juice
presses?: number;
tank?: { fluid: FluidVariant; amount: number };
}
function register_juicer(ctx: ServerContext) {
// what juice is made from, read by whatever makes it, like the juicer. the juice's name and color are in shared.ts
ctx.components.register_item<JuiceableParams>("bworld:juiceable", {});
const juiceable = (id: string) => ctx.items.components(id)["bworld:juiceable"] as JuiceableParams | undefined;
ctx.components.register_block("bworld:juicer", {
on_interact(block, _params, player) {
const held = player.held_item;
const container = block_container(ctx, block, 1);
const data = block.data as JuicerData;
if (held && juiceable(held.id)) {
held.count = container.add(held)?.count ?? 0;
// true even when none fit, so the fruit isn't eaten instead
return true;
}
const capacity = held && ctx.items.fluid_capacity(held.id);
if (held && capacity !== undefined) {
if ((held.data as { fluid?: unknown } | undefined)?.fluid !== undefined) return false;
const tank = data.tank;
if (!tank || tank.amount < capacity) return false;
const amount = tank.amount - capacity;
block.data = { ...data, tank: amount > 0 ? { ...tank, amount } : undefined } satisfies JuicerData;
player.exchange_held({ id: held.id, count: 1, data: { fluid: tank.fluid } });
return true;
}
if (held || !player.is_sneaking()) return false;
const item = container.get(0);
const params = item && juiceable(item.id);
if (!item || !params) return false;
const juice: FluidVariant = { id: JUICE, data: { item: item.id } };
const tank = data.tank;
const fits = (tank ? tank.amount : 0) + params.juice <= JUICER_CAPACITY &&
(!tank || ctx.fluids.same(tank.fluid, juice));
if (!fits) return false;
const presses = (data.presses ?? 0) + 1;
if (presses < JUICER_PRESSES) {
block.data = { ...data, presses } satisfies JuicerData;
return true;
}
item.count -= 1;
block.data = {
...data,
presses: 0,
tank: { fluid: juice, amount: (tank?.amount ?? 0) + params.juice },
} satisfies JuicerData;
return true;
},
on_break(block) {
drop_contents(ctx, block);
},
});
}
interface GrowableBlockParams {
// what grows on top of it
block_id: string;
Binary file not shown.

After

Width:  |  Height:  |  Size: 304 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 217 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 344 B

+4 -1
View File
@@ -7,6 +7,9 @@
"nutrition": 2,
"saturation_modifier": 0.4
},
"base_sell_value": 35
"base_sell_value": 35,
"components": {
"bworld:juiceable": { "juice": 500, "color": "#7ab244" }
}
}
}
+4 -1
View File
@@ -7,6 +7,9 @@
"nutrition": 1,
"saturation_modifier": 0.3
},
"base_sell_value": 15
"base_sell_value": 15,
"components": {
"bworld:juiceable": { "juice": 250, "color": "#c0341f" }
}
}
}