#Custom Enchantment Help with creation [RESOLVED]

1 messages · Page 1 of 1 (latest)

zealous hound
#

1 set enchantment to item lore
2 if player has the enchantment on boots change its speed

#
itemStack.setLore(["myEnchantment"])

const eq = player.getComponent("equippable")
if (eq.getSlot("Feet").getLore()[0] == "myEnchantment") {
    player.addEffect("speed", 2, { amplifier: 2 })
}
rose yew
#

Thanks!

rose yew
#

I've tried testing it, and it works. How do I get it to only work on sand?

half cliff
#

player.dimension.getBlock({ x: player.location.x, y: player.location.y - 1, z: player.location.z })

rose yew
#

Thanks.

#

Custom Enchantment Help with creation [RESOLVED]

#

So, would this all work:


world.beforeEvents.playerTick.subscribe(({ player }) => {
  try {
    // 1. Get the player's equipped item in the Feet slot
    const eq = player.getComponent("equippable");
    const feetItem = eq?.getEquipment("feet");

    if (!feetItem) return;

    const lore = feetItem.getLore();

    // 2. Check if the boots have the custom "myEnchantment" tag
    if (lore.length === 0 || lore[0] !== "myEnchantment") return;

    // 3. Check the block under the player
    const blockBelow = player.dimension.getBlock({
      x: Math.floor(player.location.x),
      y: Math.floor(player.location.y - 1),
      z: Math.floor(player.location.z),
    });

    if (
      blockBelow?.typeId === "minecraft:sand" ||
      blockBelow?.typeId === "minecraft:red_sand"
    ) {
      // 4. Apply Speed effect (amplifier 2 = Speed III)
      player.addEffect(MinecraftEffectTypes.speed, 2, {
        amplifier: 2,
        showParticles: false,
      });
    }
  } catch (err) {
    console.warn("Sand Strider enchantment error:", err);
  }
});```
summer flame
#

please stop using AI like that

#

playerTick event is not even a thing 😭

wise leaf
#

what in the ai 😭