Single module modding
This commit is contained in:
@@ -12,7 +12,7 @@ Like blocks, each kind of item is defined once. What players hold are **item sta
|
||||
interface ItemStack {
|
||||
readonly id: string;
|
||||
count: number;
|
||||
data?: unknown; // any JSON value, set by server scripts
|
||||
data?: unknown; // any JSON value, set by server phases
|
||||
}
|
||||
```
|
||||
|
||||
@@ -22,7 +22,7 @@ tool. It's saved, and synced to clients as part of the container the stack is in
|
||||
Two stacks of one item only merge into one when their `data` is the same, whatever order its keys are in, in an
|
||||
inventory or on the ground. No data is the same as `{}`.
|
||||
|
||||
Stacks handed to server scripts are live: setting `count` or `data` on one changes the real stack, and a stack counted
|
||||
Stacks handed to server phases are live: setting `count` or `data` on one changes the real stack, and a stack counted
|
||||
down to 0 is gone.
|
||||
|
||||
## A Basic Item
|
||||
@@ -97,7 +97,7 @@ they should stay inside the item's own shape, and an item drawn with a `model` c
|
||||
|
||||
### Worn Models
|
||||
|
||||
`worn` says how an item looks on a player who wears it, like Bedrock's attachables. A server script says what a player
|
||||
`worn` says how an item looks on a player who wears it, like Bedrock's attachables. The server phase says what a player
|
||||
wears with [`set_worn`](../entities/players.md#worn-items), and every client draws it on them. There's no third person
|
||||
view, so players see what others wear, and what's on their own right arm in first person. Artifacts' power glove and
|
||||
feral claws (`mods/artifacts`) and the base game's giant chestplate are examples.
|
||||
@@ -154,7 +154,7 @@ load the mod.
|
||||
|
||||
## Item Components
|
||||
|
||||
Like [block components](../blocks/components.md), item components give items behavior. The server script registers them:
|
||||
Like [block components](../blocks/components.md), item components give items behavior. The server phase registers them:
|
||||
|
||||
```ts
|
||||
ctx.components.register_item<{ max_water: number }>("bworld:watering_can", {
|
||||
@@ -257,6 +257,6 @@ player.give_item("bworld:carrot", 3); // what doesn't fit drops at their feet
|
||||
player.exchange_held({ id: "bworld:bucket", count: 1, data }); // one of the held item becomes this
|
||||
```
|
||||
|
||||
Client and shared scripts have `ctx.items.sell_value(id, data)` too, worked out the same way with that side's
|
||||
Client and shared phases have `ctx.items.sell_value(id, data)` too, worked out the same way with that side's
|
||||
[fluid rules](../resources/fluids.md#rules), so a client can show what a full bottle of juice is worth, like the base
|
||||
game's [tooltip line](../gui/index.md#item-tooltips) does.
|
||||
|
||||
Reference in New Issue
Block a user