跳至主要內容

使用特定物品右鍵召喚實體

芒果凍布丁2025年6月24日小於 1 分鐘KubeJS 7KubeJS 6

在這個範例中,我們將使用特定物品右鍵點擊方塊時召喚一個實體。

BlockEvents.rightClicked("minecraft:target", (event) => {
  const { item, block, facing, level } = event;

  if (Ingredient.of("minecraft:bone").test(item)) {
    /** @type {$BlockContainerJS_} */
    let clickBlock = block[facing.name().toLowerCase()];

    let armorStand = level.createEntity("minecraft:skeleton");
    armorStand.pos = new Vec3d(clickBlock.x + 0.5, clickBlock.y + 0.5, clickBlock.z + 0.5);
    armorStand.spawn();
  }
});
上次編輯於: 2025/6/24 下午11:18:52
貢獻者: EvanHsieh0415