Blocks interacting on the world api
This commit is contained in:
@@ -199,6 +199,19 @@ ctx.components.register_item("copper_tools:sling", {
|
||||
});
|
||||
```
|
||||
|
||||
## Machines Using Items
|
||||
|
||||
`ctx.world.use_item_on(item, x, y, z, face)` uses an item on the face of a block the way a player holding it would, like
|
||||
Create's deployer: the block's `on_interact`, or the item's `on_use` with the block as its target, or placing it. A
|
||||
player that isn't anyone, named `[machine]`, does it, standing in the block in front of that face and looking at it,
|
||||
like NeoForge's `FakePlayer`. It's never online, so nothing sent to it goes anywhere.
|
||||
|
||||
```ts
|
||||
const { item, given } = ctx.world.use_item_on({ id: "bworld:cobblestone", count: 5 }, x, y, z, "top");
|
||||
// item is what it holds after, { id: "bworld:cobblestone", count: 4 } once one is placed, undefined when used up.
|
||||
// given is anything else it was given, like a stick from a wand's on_use
|
||||
```
|
||||
|
||||
## Server Script Helpers
|
||||
|
||||
```ts
|
||||
|
||||
Reference in New Issue
Block a user