Curios and artifacts !

This commit is contained in:
2026-09-30 15:22:32 -03:00
parent 342b45d593
commit 3af5f6e54b
45 changed files with 729 additions and 43 deletions
+20
View File
@@ -227,6 +227,21 @@ export interface Player {
feed(nutrition: number, saturation_modifier: number): void;
// tires them out: 4 costs a point of saturation, or of hunger once it's gone
add_exhaustion(amount: number): void;
// their stats, like minecraft's attributes: "bworld:attack_damage", "bworld:attack_speed", "bworld:max_health"...
// see docs/modding/entities/players.md. modifiers aren't saved, they're gone when the player leaves
attribute(id: Id): number;
// replaces one with the same id on that attribute
add_modifier(attribute: Id, modifier: AttributeModifier): void;
// whether it had it
remove_modifier(attribute: Id, id: string): boolean;
}
// like minecraft's: the base, plus every add_value, plus that times each add_multiplied_base, then times 1 + each
// add_multiplied_total
export interface AttributeModifier {
id: string;
amount: number;
operation: "add_value" | "add_multiplied_base" | "add_multiplied_total";
}
export interface PlayerList {
@@ -272,6 +287,9 @@ export interface ItemApi {
max_stack(id: Id): number;
// the tool type it is, like "pickaxe" or "shovel", from the item's "tool"
tool(id: Id): string | undefined;
// the components its json lists and their params, a copy. a mod can read params of its components this way
// without a stack, like curios does for curios:attribute_modifiers
components(id: Id): Record<Id, unknown>;
}
export interface RecipeApi {
@@ -328,6 +346,8 @@ export interface ContainerScreenOptions {
output_only?: boolean;
// runs when a player takes from an output_only slot, before they get it. false stops them taking it
on_take?: (item: ItemStack) => boolean;
// a texture drawn in the slot while it's empty, like minecraft's armor slots
icon?: Id;
}[];
// height of the screen's area in slots, fits the layout and bars when not set
rows?: number;
+9 -5
View File
@@ -7,7 +7,7 @@ export const AIR_ID = "bworld:air";
// bump when a client and server of different versions can't play together.
// the server rejects a different version before the client downloads anything
export const PROTOCOL_VERSION = 9;
export const PROTOCOL_VERSION = 10;
export interface PlayerInfo {
id: string;
@@ -59,8 +59,8 @@ export interface ScreenLayout {
// height of the screen's own area, in slots
rows: number;
// x and y in slots, can be fractional
// output slots can only be taken from, like the furnace result
slots: { index: number; x: number; y: number; output?: boolean }[];
// output slots can only be taken from, like the furnace result. icon is a texture drawn in the slot while it's empty
slots: { index: number; x: number; y: number; output?: boolean; icon?: string }[];
// progress bars filled from properties[value] / properties[max]
bars: {
x: number;
@@ -103,7 +103,9 @@ export type ClientMessage =
| { type: "close_screen" }
| { type: "chat"; text: string }
// what could come next in a command being typed, answered with suggestions. id matches them up
| { type: "suggest"; id: number; text: string };
| { type: "suggest"; id: number; text: string }
// a mod's client script talking to its server script, see ctx.net
| { type: "mod"; channel: string; data: unknown };
export type ServerMessage =
// what to download before joining, see docs/modding/networking/index.md
@@ -187,7 +189,9 @@ export type ServerMessage =
// answers suggest: start is where in the text the suggestions replace from, up to the caret
| { type: "suggestions"; id: number; start: number; suggestions: { text: string; tooltip?: string }[] }
// the player's own health, hunger and saturation, when they change
| { type: "vitals"; health: number; food: number; saturation: number };
| { type: "vitals"; health: number; food: number; saturation: number }
// a mod's server script talking to its client script, see ctx.net
| { type: "mod"; channel: string; data: unknown };
export const MAX_NAME_LENGTH = 16;
export const MAX_CHAT_LENGTH = 256;