Change how targetting liquids work

This commit is contained in:
2026-10-07 17:48:50 -03:00
parent ff53d30a7e
commit b128da0631
13 changed files with 42 additions and 18 deletions
+3
View File
@@ -248,6 +248,9 @@ export interface ItemRegistry<T = unknown | undefined> {
lore?: string;
food?: FoodProperties;
worn?: WornProperties;
// whether players holding it aim at liquids, like buckets and fishing rods. others look through them, so they can
// break and place blocks under water
targets_liquids?: boolean;
components?: Record<string, unknown>;
on_create?(item: ItemStack<T>): void;
+7
View File
@@ -119,6 +119,8 @@ export interface ItemJson {
food?: FoodProperties;
// how it looks worn on a player
worn?: WornProperties;
// see ItemRegistry.targets_liquids
targets_liquids?: boolean;
name?: string;
lore?: string;
components?: Record<string, unknown>;
@@ -370,6 +372,7 @@ export function item_to_json(id: string, item: ItemRegistry): ItemJson {
if (item.base_sell_value !== undefined) json.base_sell_value = item.base_sell_value;
if (item.food !== undefined) json.food = item.food;
if (item.worn !== undefined) json.worn = item.worn;
if (item.targets_liquids !== undefined) json.targets_liquids = item.targets_liquids;
if (item.name !== undefined) json.name = item.name;
if (item.lore !== undefined) json.lore = item.lore;
if (item.components) json.components = item.components;
@@ -396,6 +399,7 @@ function item_fields(json: ItemJson): Partial<ItemRegistry> {
if (json.base_sell_value !== undefined) item.base_sell_value = json.base_sell_value;
if (json.food !== undefined) item.food = json.food;
if (json.worn !== undefined) item.worn = json.worn;
if (json.targets_liquids !== undefined) item.targets_liquids = json.targets_liquids;
if (json.name !== undefined) item.name = json.name;
if (json.lore !== undefined) item.lore = json.lore;
if (json.components) item.components = json.components;
@@ -815,6 +819,9 @@ export function validate_item(json: unknown): Problems {
if (json.base_sell_value !== undefined && !is_whole(json.base_sell_value)) {
problems.push("base_sell_value must be a whole number of 0 or more");
}
if (json.targets_liquids !== undefined && typeof json.targets_liquids !== "boolean") {
problems.push("targets_liquids must be true or false");
}
if (json.tool !== undefined) {
const tool = json.tool;
if (!is_object(tool) || typeof tool.type !== "string") {