diff --git a/src/main/kotlin/world/cepi/momentum/ability/DoubleJump.kt b/src/main/kotlin/world/cepi/momentum/ability/DoubleJump.kt index 17ecafc..cd8047e 100644 --- a/src/main/kotlin/world/cepi/momentum/ability/DoubleJump.kt +++ b/src/main/kotlin/world/cepi/momentum/ability/DoubleJump.kt @@ -7,13 +7,18 @@ import net.minestom.server.event.EventCallback import net.minestom.server.event.player.PlayerMoveEvent import net.minestom.server.event.player.PlayerStartFlyingEvent import net.minestom.server.sound.SoundEvent +import world.cepi.energy.energy import world.cepi.kstom.event.listenOnly +import world.cepi.kstom.util.playSound +import world.cepi.kstom.util.playSoundToViewersAndSelf import world.cepi.kstom.util.viewersAndSelfAsAudience import world.cepi.momentum.cooldown.Cooldown import world.cepi.momentum.cooldown.PredicateCooldown import world.cepi.particle.Particle import world.cepi.particle.ParticleType +import world.cepi.particle.data.Color import world.cepi.particle.data.OffsetAndSpeed +import world.cepi.particle.extra.Dust import world.cepi.particle.renderer.Renderer import world.cepi.particle.renderer.render import world.cepi.particle.renderer.translate @@ -35,9 +40,6 @@ object DoubleJump : MovementAbility(), EventCallback { override fun initialise() { node.listenOnly(::run) - node.listenOnly { - if (player.isOnGround) player.isAllowFlying = true - } } override fun apply(player: Player) { @@ -51,12 +53,21 @@ object DoubleJump : MovementAbility(), EventCallback { override fun run(event: PlayerStartFlyingEvent) = with(event) { // cancel the flying first player.isFlying = false - player.isAllowFlying = false - player.viewersAndSelfAsAudience.playSound(Sound.sound(SoundEvent.ENTITY_BAT_TAKEOFF, Sound.Source.MASTER, 1f, 2f)) val circle = Renderer.circle(1.0).translate(player.position.asVec()) + + if (player.energy < 8) { + val failParticle = Particle.particle(ParticleType.DUST, 1, OffsetAndSpeed(), Dust(1f, 0f, 0f, 1f)) + player.playSoundToViewersAndSelf(Sound.sound(SoundEvent.BLOCK_NOTE_BLOCK_DIDGERIDOO, Sound.Source.MASTER, 1f, 0.5f), player.position) + circle.render(failParticle, player.viewersAndSelfAsAudience) + return + } + + player.energy -= 8 + val particle = Particle.particle(ParticleType.CLOUD, 1, OffsetAndSpeed()) + player.playSoundToViewersAndSelf(Sound.sound(SoundEvent.ENTITY_BAT_TAKEOFF, Sound.Source.MASTER, 1f, 2f), player.position) circle.render(particle, player.viewersAndSelfAsAudience) player.velocity = player.position.direction().mul(12.0).withY(10.0) diff --git a/src/main/kotlin/world/cepi/momentum/ability/JumpSmash.kt b/src/main/kotlin/world/cepi/momentum/ability/JumpSmash.kt index aa7e6f0..6b2410a 100644 --- a/src/main/kotlin/world/cepi/momentum/ability/JumpSmash.kt +++ b/src/main/kotlin/world/cepi/momentum/ability/JumpSmash.kt @@ -11,6 +11,7 @@ import net.minestom.server.sound.SoundEvent import net.minestom.server.utils.time.TimeUnit import world.cepi.kstom.Manager import world.cepi.kstom.event.listenOnly +import world.cepi.kstom.util.playSoundToViewersAndSelf import world.cepi.kstom.util.viewersAndSelfAsAudience import world.cepi.momentum.cooldown.PredicateCooldown @@ -40,7 +41,7 @@ object JumpSmash : MovementAbility(), EventCallback { player.isAllowFlying = false player.velocity = player.position.direction().mul(5.0).withY(15.0) - player.viewersAndSelfAsAudience.playSound(Sound.sound(SoundEvent.ENTITY_ENDER_DRAGON_SHOOT, Sound.Source.MASTER, 1f, 2f)) + player.playSoundToViewersAndSelf(Sound.sound(SoundEvent.ENTITY_ENDER_DRAGON_SHOOT, Sound.Source.MASTER, 1f, 2f)) Manager.scheduler.buildTask { player.velocity = player.position.direction().mul(5.0).withY(-15.0) diff --git a/src/main/kotlin/world/cepi/momentum/ability/RockPillar.kt b/src/main/kotlin/world/cepi/momentum/ability/RockPillar.kt index c2f917b..2338b95 100644 --- a/src/main/kotlin/world/cepi/momentum/ability/RockPillar.kt +++ b/src/main/kotlin/world/cepi/momentum/ability/RockPillar.kt @@ -12,9 +12,7 @@ import net.minestom.server.tag.Tag import net.minestom.server.utils.time.TimeUnit import world.cepi.energy.energy import world.cepi.kstom.event.listenOnly -import world.cepi.kstom.util.toBlockPosition -import world.cepi.kstom.util.toExactBlockPosition -import world.cepi.kstom.util.viewersAndSelfAsAudience +import world.cepi.kstom.util.* import world.cepi.particle.Particle import world.cepi.particle.ParticleType import world.cepi.particle.data.Color @@ -69,7 +67,7 @@ object RockPillar : MovementAbility() { Dust(1f, 0f, 0f, 1f) ), player.viewersAndSelfAsAudience) - player.viewersAndSelfAsAudience.playSound(Sound.sound(SoundEvent.BLOCK_NOTE_BLOCK_DIDGERIDOO, Sound.Source.MASTER, 1f, 0.5f)) + player.playSoundToViewersAndSelf(Sound.sound(SoundEvent.BLOCK_NOTE_BLOCK_DIDGERIDOO, Sound.Source.MASTER, 1f, 0.5f)) return } @@ -77,7 +75,7 @@ object RockPillar : MovementAbility() { // start off by throwing the player up in the air player.velocity = Vec(0.0, 16.0, 0.0) - player.viewersAndSelfAsAudience.playSound(Sound.sound(SoundEvent.ENTITY_IRON_GOLEM_ATTACK, Sound.Source.MASTER, 2f, 0.5f)) + player.playSoundToViewersAndSelf(Sound.sound(SoundEvent.ENTITY_IRON_GOLEM_ATTACK, Sound.Source.MASTER, 2f, 0.5f), player.position) rectangle.render(Particle.particle( ParticleType.BLOCK, @@ -104,7 +102,7 @@ object RockPillar : MovementAbility() { player.energy -= 14 - player.viewersAndSelfAsAudience.playSound(Sound.sound(SoundEvent.ENTITY_IRON_GOLEM_DAMAGE, Sound.Source.MASTER, 1f, 0.5f)) + player.playSoundToViewersAndSelf(Sound.sound(SoundEvent.ENTITY_IRON_GOLEM_DAMAGE, Sound.Source.MASTER, 1f, 0.5f) ) // schedule a task to remove the pillar later MinecraftServer.getSchedulerManager().buildTask { @@ -115,7 +113,7 @@ object RockPillar : MovementAbility() { player.instance!!.setBlock(it, Block.AIR) } - player.viewersAndSelfAsAudience.playSound(Sound.sound(SoundEvent.ENTITY_IRON_GOLEM_REPAIR, Sound.Source.MASTER, 1f, 0.5f)) + player.playSoundToViewersAndSelf(Sound.sound(SoundEvent.ENTITY_IRON_GOLEM_REPAIR, Sound.Source.MASTER, 1f, 0.5f)) rectangle.render(Particle.particle( ParticleType.BLOCK,