#how to make item can interact?

1 messages · Page 1 of 1 (latest)

glass gyro
#

I wanna make item can interact like if I right click and the item can running the command. for example command say

cold imp
#

You're best bet would be scripts

glass gyro
cold imp
#

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
glass gyro
#

like this??