filler

Fire Bow

Traps enemies in Lava!

← Back to main

Code Block:


api.giveItem(myId, "Diamond Bow", 1,{customDisplayName: "Firebow", customDescription: "Trap enemies in Lava"});

function onPlayerDamagingOtherPlayerFire(attackerId, victimId, damage, withItem, bodyPartHit, damagerDbId) {
  if (withItem !== "Arrow") return

  const held = api.getHeldItem(attackerId)
  if (!held || held.name !== "Diamond Bow" || held.attributes?.customDisplayName !== "Firebow") return

  const pos = api.getPosition(victimId)
  if (!pos) return

  const [x, y, z] = pos

  for (let dx = -1; dx <= 1; dx++) {
    for (let dz = -1; dz <= 1; dz++) {
      const bx = Math.floor(x + dx)
      const by = Math.floor(y)
      const bz = Math.floor(z + dz)

      api.setBlock(bx, by, bz, "Net")
      api.setBlock(bx, by + 1, bz, "Lava")

      // 🔥 Remove the lava block after 10 seconds (200 ticks)
      setTimeOut(() => {
        api.setBlock(bx, by + 1, bz, "Air")
	api.setBlock(bx, by, bz, "Air")
      }, 10*1000)
    }
  }
}

      

World Code:


//Timeout Code by Sulfrox
let ordinary_tick_function,do_next_tick_queue=new Set,timed_functions_queue=[];function tick(t){if("function"==typeof ordinary_tick_function&&ordinary_tick_function(t),do_next_tick_queue.forEach((t=>{"function"==typeof t&&t(),do_next_tick_queue.delete(t)})),timed_functions_queue.length&&timed_functions_queue[0][0]{"function"==typeof t&&do_next_tick_queue.add(t)},setTimeOut=(t,e)=>{let n=Date.now()+e;"function"==typeof t&&(timed_functions_queue.push([n,t]),timed_functions_queue.sort((([t],[e])=>t-e)))};

// Handle attack logic
onPlayerDamagingOtherPlayer = function(attackerId, victimId, baseDamage, withItem, bodyPartHit, damagerDbId) {
  const held = api.getHeldItem(attackerId);

  if (held && held.name === "Diamond Bow" && held.attributes?.customDisplayName === "Firebow") {
    onPlayerDamagingOtherPlayerFire(attackerId, victimId, baseDamage, withItem, bodyPartHit, damagerDbId)
  }
}