#how to make item can interact?
1 messages · Page 1 of 1 (latest)
You're best bet would be scripts
Using world.afterevents.itemUse( see the docs on it here: https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server/itemuseaftereventsignal?view=minecraft-bedrock-stable)
I don't understand, i'm still newbie.. is there example file or full code?
For scripting, I'd recommend starting here: https://learn.microsoft.com/en-us/minecraft/creator/documents/scriptingintroduction?view=minecraft-bedrock-stable
I'll send an example file, but you'll want to look at that page still for how to set to scripting
import {
world,
system
} from "@minecraft/server";
world.afterEvents.itemUse.subscribe(async (event) => {
const player = event.source; // Player that used the item
const item = event.itemStack;
switch(item.type.id){
case "minecraft:arrow":
player.runCommand("say arrow");
break;
case "minecraft:diamond":
player.runCommand("say diamond");
break;
}
});```
This can be expanded for any amount of items by adding more cases
like this??
this the item code