filler

Lance

Dash through the air with a shield

← Back to main

Code Block:


function check_item(item, item_name, custom_name, customId){
  return (
    item &&
    item.name === item_name &&
    item.attributes.customDisplayName === custom_name &&
    item.attributes.customAttributes.weaponId === customId
  );
}

api.giveItem(myId, "Diamond Sword", 1, {customDisplayName: "Lance",customDescription: "Right click to dash into the air", customAttributes: {weaponId: 1, "enchantmentTier":"Tier 5", enchantments: {"Attack Speed":1, "Damage":1, "Critical Damage": 1}}})

function onPlayerAltLance(aId){
  held = api.getHeldItem(aId)
  if(check_item(held,"Diamond Sword","Lance",1) && !api.getEffects(aId).includes("Lance Cooldown")){
    api.applyEffect(aId, "Lance Cooldown", 20000, {icon: "Yellow Wool"})
    const facingInfo = api.getPlayerFacingInfo(aId)
    const dir = facingInfo.dir
    const dashStrength = 50
    const dashX = dir[0] * dashStrength
    const dashY = dir[1] * (dashStrength / 2)
    const dashZ = dir[2] * dashStrength
    api.setVelocity(aId, dashX, dashY, dashZ)
    api.setShieldAmount(aId, 40)
  }else{
    return
  }
}
      

World Code:


onPlayerAltAction = (playerId, x, y, z, block, targetEId) => {
  onPlayerAltLance(playerId)
}