#how to run a command if an item is eaten

1 messages · Page 1 of 1 (latest)

spark river
#

like a function if you eat something

#

how to run a command if an item is eaten

spark river
#

anybody

green tulip
# spark river anybody

Item:

  "format_version": "1.21.60",
  "minecraft:item": {
    "description": {
      "identifier": "realm:adminkey",
      "menu_category": {
        "category": "items"
      }
    },
    "components": {
      "minecraft:max_stack_size": 1,
      "minecraft:icon": {
        "textures": {
          "default": "realm:adminkey"
        }
      }
    }
  }
}

main.js


world.afterEvents.itemUse.subscribe((event) => {
  const player = event.source;
  const item = event.itemStack;

  if (!player || !item) return;

  if (item.typeId === "realm:adminkey") {
    const overworld = world.getDimension("overworld");

    player.runCommand("tp @s -1 39 5013 facing ~ ~0 ~-180");
  }
});
crude cedar
warm spoke
#

maybe they mean after the item is eaten, like food item