Juicer press wow

This commit is contained in:
2026-10-25 19:14:29 -03:00
parent a28e0b9abb
commit c955d8d143
8 changed files with 235 additions and 49 deletions
+11 -1
View File
@@ -5,8 +5,18 @@
"name": "Juicer",
"textures": {},
"model": "bworld:juicer",
"item_model": "bworld:juicer",
"item_model": "bworld:juicer_item",
"render_layer": "cutout",
"shape": [
[0, 0, 0, 16, 2, 16],
[0, 2, 0, 2, 14, 2],
[14, 2, 0, 16, 14, 2],
[14, 2, 14, 16, 14, 16],
[0, 2, 14, 2, 14, 16],
[0, 14, 0, 16, 16, 16],
[5, 8, 5, 11, 10, 11],
[7, 10, 7, 9, 14, 9]
],
"mining": {
"toughness": 2,
"tool": "pickaxe"
-36
View File
@@ -68,42 +68,6 @@
"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] }
}
}
]
}
+110
View File
@@ -0,0 +1,110 @@
{
"format_version": 1,
"model": {
"id": "bworld:juicer_item",
"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] }
}
}
]
}
}
+50
View File
@@ -0,0 +1,50 @@
{
"format_version": 1,
"model": {
"id": "bworld:juicer_press",
"textures": {
"0": "bworld:juicer_side",
"1": "bworld:juicer_bottom",
"2": "bworld:juicer_top",
"particle": "bworld:juicer_side"
},
"elements": [
{
"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] }
}
}
]
}
}
+26 -4
View File
@@ -17,7 +17,7 @@ import type {
VisualBlock,
} from "bworld/client";
import { MINIGAMES } from "./minigames/mod.ts";
import { JUICER_CAPACITY, type JuicerTank } from "./shared.ts";
import { JUICER_CAPACITY, JUICER_PRESSES, type JuicerTank } from "./shared.ts";
import { stonecutting_options, stonecutting_recipes } from "./stonecutting.ts";
const WIDTH = 176;
@@ -44,13 +44,25 @@ const JUICER_ITEMS_A_COPY = 16;
// it's full
const JUICER_INSIDE = [2, 14];
const JUICER_DEPTH = 12;
// how far its press goes down, from where it rests to the floor, where the press that makes the juice would take it. it
// goes a share of the way for each press toward the next juice, and back up once that's made
const JUICER_PRESS_TRAVEL = 6 / 16;
// what's in the juicer and its juice, its "stack" and "tank" client data (see register_juicer in scripts/server.ts).
// the items are drawn like create's basin draws its ingredients: tipped over and turned, with a copy more for every
// the juicer's press, what's in it and its juice, by its "presses", "stack" and "tank" client data (see register_juicer
// in scripts/server.ts). the press is its own model, not part of the block's, so it can go down as it's pressed. the
// items are drawn like create's basin draws its ingredients: tipped over and turned, with a copy more for every
// JUICER_ITEMS_A_COPY. each copy is turned further and a bit higher than the one under it, so they pile up
function juicer_visual(block: VisualBlock, instances: Instances): Visual {
const press = instances.transformed("bworld:juicer_press");
const press_target = () => JUICER_PRESS_TRAVEL * (block.get_client_data<number>("presses") ?? 0) / JUICER_PRESSES;
// how far down the press is, and where the presses say it goes, which it catches up with a quarter of the way each
// tick. one made mid way starts there
let target = press_target();
let down: number | undefined;
let last: number | undefined;
let shown: Instance[] = [];
const update = () => {
target = press_target();
for (const instance of shown) instance.delete();
shown = [];
const tank = block.get_client_data<JuicerTank>("tank");
@@ -74,7 +86,17 @@ function juicer_visual(block: VisualBlock, instances: Instances): Visual {
}));
};
update();
return { update };
return {
update,
on_frame(time) {
const ticks = last === undefined ? 0 : time - last;
last = time;
if (down === target) return;
down = down === undefined ? target : down + (target - down) * Math.min(1, ticks / 4);
if (Math.abs(target - down) < 1 / 256) down = target;
press.set_transform([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, -down, 0, 1]);
},
};
}
// a panel with the menu's title and the inventory's label over its rows, drawing anything else over it
+5 -4
View File
@@ -8,7 +8,7 @@ import { register_effects } from "./effects.ts";
import { register_fishing } from "./fishing.ts";
import { stonecutting_options, stonecutting_recipes } from "./stonecutting.ts";
import { register_verdigris } from "./verdigris/server.ts";
import { type JuiceableParams, JUICER_CAPACITY, type JuicerTank } from "./shared.ts";
import { type JuiceableParams, JUICER_CAPACITY, JUICER_PRESSES, type JuicerTank } from "./shared.ts";
export function setup(ctx: ServerContext) {
register_hoeable(ctx);
@@ -851,10 +851,9 @@ 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. clients see what's in it and its juice as its "stack" and "tank" client data, which its visual draws
// (see scripts/client.ts)
// juice is lost. clients see what's in it, its juice and how many times it's been pressed toward the next as its
// "stack", "tank" and "presses" client data, which its visual draws (see scripts/client.ts)
const JUICE = "bworld:juice";
const JUICER_PRESSES = 4;
interface JuicerData {
container?: string;
@@ -910,6 +909,7 @@ function register_juicer(ctx: ServerContext) {
const presses = (data.presses ?? 0) + 1;
if (presses < JUICER_PRESSES) {
block.data = { ...data, presses } satisfies JuicerData;
block.set_client_data("presses", presses);
return true;
}
item.count -= 1;
@@ -917,6 +917,7 @@ function register_juicer(ctx: ServerContext) {
const filled = { fluid: juice, amount: (tank?.amount ?? 0) + params.juice };
block.data = { ...data, presses: 0, tank: filled } satisfies JuicerData;
block.set_client_data("tank", filled);
block.set_client_data("presses", undefined);
return true;
},
on_break(block) {
+2
View File
@@ -147,6 +147,8 @@ export interface JuiceableParams {
// how much juice the juicer holds, in mB, and the juice in it: in its tile data, and in its "tank" client data for its
// visual to draw (see register_juicer in server.ts and juicer_visual in client.ts)
export const JUICER_CAPACITY = 1000;
// how many presses make one of what's in it into juice. its visual lowers its press for each one toward the next
export const JUICER_PRESSES = 4;
export interface JuicerTank {
fluid: FluidVariant;
amount: number;