Glass bottle, buckets and juice !
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"format_version": 1,
|
||||
"fluid": {
|
||||
"id": "bworld:juice",
|
||||
"name": "Juice",
|
||||
"color": "#e8a33d"
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,8 @@
|
||||
"id": "bworld:bucket",
|
||||
"texture": "bworld:bucket",
|
||||
"targets_fluids": true,
|
||||
"max_stack": 16,
|
||||
"base_sell_value": 180
|
||||
"base_sell_value": 180,
|
||||
"fluid_container": { "capacity": 1000, "full_max_stack": 1 },
|
||||
"layers": [{ "texture": "bworld:bucket_fluid", "tint": "fluid" }]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"format_version": 1,
|
||||
"item": {
|
||||
"id": "bworld:glass_bottle",
|
||||
"texture": "bworld:glass_bottle",
|
||||
"fluid_container": { "capacity": 250 },
|
||||
"layers": [{ "texture": "bworld:bottle_fluid", "tint": "fluid" }]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"format_version": 1,
|
||||
"recipe": {
|
||||
"type": "shaped",
|
||||
"pattern": [
|
||||
"G G",
|
||||
" G "
|
||||
],
|
||||
"key": {
|
||||
"G": "bworld:glass"
|
||||
},
|
||||
"result": {
|
||||
"id": "bworld:glass_bottle",
|
||||
"count": 3
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +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 } from "./shared.ts";
|
||||
|
||||
export function setup(ctx: ServerContext) {
|
||||
register_hoeable(ctx);
|
||||
@@ -24,6 +25,9 @@ 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_curios(ctx);
|
||||
register_effects(ctx);
|
||||
register_growable_block(ctx);
|
||||
@@ -793,8 +797,8 @@ function register_farming(ctx: ServerContext) {
|
||||
});
|
||||
}
|
||||
|
||||
// buckets, like minecraft's: right clicking water with a bucket picks it up into a water bucket, which places it back
|
||||
// and is a bucket again
|
||||
// buckets, like minecraft's: right clicking water with an empty bucket picks it up into a water bucket, which places it
|
||||
// back and is a bucket again. a bucket is also a fluid container, so it can be full of juice, which it can't place
|
||||
|
||||
// right clicking it with a bucket takes it away, giving the filled bucket
|
||||
interface BucketableParams {
|
||||
@@ -812,7 +816,9 @@ function register_buckets(ctx: ServerContext) {
|
||||
ctx.components.register_block<BucketableParams>("bworld:bucketable", {
|
||||
on_interact(block, params, player) {
|
||||
const bucket = player.held_item;
|
||||
if (bucket?.id !== BUCKET) return false;
|
||||
if (bucket?.id !== BUCKET || (bucket.data as { fluid?: unknown } | undefined)?.fluid !== undefined) {
|
||||
return false;
|
||||
}
|
||||
const { x, y, z } = block;
|
||||
if (ctx.world.get_block(x, y, z) === block.id) {
|
||||
// only a fluid's source fills it, not where it's flowing
|
||||
@@ -822,10 +828,7 @@ function register_buckets(ctx: ServerContext) {
|
||||
// the fluid in a waterlogged block, like a fence in water, which stays
|
||||
ctx.world.set_state(x, y, z, "waterlogged", 0);
|
||||
}
|
||||
bucket.count -= 1;
|
||||
// the last one becomes the filled bucket in the hand, from a stack it goes in the inventory
|
||||
if (bucket.count <= 0) player.inventory.set(player.selected_slot, { id: params.into, count: 1 });
|
||||
else player.give_item(params.into);
|
||||
player.exchange_held({ id: params.into, count: 1 });
|
||||
return true;
|
||||
},
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
// the base game's block rules: how blocks are placed and how they change with the blocks beside them. they run on the
|
||||
// server and on every client, so players see a fence join or a trapdoor turn the moment they place it, and a trapdoor
|
||||
// or a door open the moment they click it
|
||||
// or a door open the moment they click it. and the juice's rules, which name and color it by the item it's from
|
||||
import type { SharedBlock, SharedContext } from "bworld/shared";
|
||||
import { register_verdigris_rules } from "./verdigris/shared.ts";
|
||||
|
||||
@@ -12,6 +12,7 @@ export function setup(ctx: SharedContext) {
|
||||
register_trapdoor(ctx);
|
||||
register_door(ctx);
|
||||
register_verdigris_rules(ctx);
|
||||
register_juice(ctx);
|
||||
}
|
||||
|
||||
// the sides a fence connects on, and the face of the block there it connects to
|
||||
@@ -136,3 +137,28 @@ function register_door(ctx: SharedContext) {
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// a juiceable item's component, like a strawberry's: juice is the mB one of it makes
|
||||
export interface JuiceableParams {
|
||||
juice: number;
|
||||
color: string;
|
||||
}
|
||||
|
||||
// juice is one fluid for every fruit, like create's potion fluid: which fruit sits in its data, { item }. it's named
|
||||
// after that item, "Strawberry Juice", in the color its bworld:juiceable says
|
||||
function register_juice(ctx: SharedContext) {
|
||||
const item_of = (data: unknown) => {
|
||||
const item = (data as { item?: unknown } | undefined)?.item;
|
||||
return typeof item === "string" && ctx.items.exists(item) ? item : undefined;
|
||||
};
|
||||
ctx.fluids.register("bworld:juice", {
|
||||
name(data) {
|
||||
const item = item_of(data);
|
||||
return item && `${ctx.items.name(item)} Juice`;
|
||||
},
|
||||
color(data) {
|
||||
const item = item_of(data);
|
||||
return item && (ctx.items.components(item)["bworld:juiceable"] as JuiceableParams | undefined)?.color;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user