#Item cooldown?

2 messages · Page 1 of 1 (latest)

wheat flint
#

I have am making a custom damage system, and I use event.cancle on the attack event. Now the problem is that you can just spam to attack enemys. I know there is cooldown for items in vanilla, is there some way to add a cooldown for this? Also is it possible to change the attack speed attribute of mobs like zombies?
My code if you need it: js EntityEvents.hurt( e => { let attacker = e.source.actual let attacked = e.entity if(attacked.isPlayer()) { if(attacked.persistentData.inMysteryLands == 2 && attacker.persistentData.maxHp>0) { let damage = attacker.persistentData.damage/*-attacked.persistentData.MysteryLandsArmor*/ if(damage < 0) { damage = 0 } attacked.persistentData.MysteryLandsHp -= damage e.server.runCommandSilent(`photon fx sky_tech:damageparticle entity ${attacked.username}`) e.cancel() } } else { if(attacker.persistentData.inMysteryLands == 2 && attacked.persistentData.maxHp>0) { if(attacker.mainHandItem.hasTag("sky_technology:mystery_lands_swords")) { let weaponNbt = attacker.mainHandItem.getNbt() console.log(weaponNbt) let damage = weaponNbt.customData.damage - attacked.persistentData.armor if(damage < 0) { damage = 0 } e.server.runCommandSilent(`photon fx sky_tech:damageparticle entity ${attacked.id}`) damageEnemy(e,attacked,attacker,damage) e.cancel() } }} })

sullen rapidsBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!