Blocks interacting on the world api

This commit is contained in:
2026-10-15 12:49:44 -03:00
parent 7faa070d83
commit b43e8fe8b8
15 changed files with 493 additions and 28 deletions
+13
View File
@@ -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