Skip to content

Commit

Permalink
✨ bigger explosion on kill
Browse files Browse the repository at this point in the history
  • Loading branch information
b8daniel committed Apr 26, 2022
1 parent abe1dd2 commit 9bc23cf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class SnowballHitPlayer : Listener {
firework.teamEffect(team)
firework.detonate()

ColorReplace.replaceRadius(hitPlayer.location, shooter, team)
ColorReplace.replaceRadius(hitPlayer.location, shooter, team, 2.0)

hitPlayer.playSound(hitPlayer.location, Sound.ENTITY_TURTLE_EGG_BREAK, SoundCategory.MASTER, 100F, .8F)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import org.bukkit.block.Block
import org.bukkit.block.Container
import org.bukkit.block.data.BlockData
import org.bukkit.entity.Player
import kotlin.math.round
import kotlin.random.Random

object ColorReplace {
Expand Down Expand Up @@ -61,11 +62,13 @@ object ColorReplace {
}
}

fun replaceRadius(location: Location, player: Player, team: ConfigTeam? = player.team, radius: Int = Paintball.gameConfig.colorRadius) {
fun replaceRadius(location: Location, player: Player, team: ConfigTeam? = player.team, multiplier: Double = 1.0) {
if (team == null) return

val blocksAround = VectorUtils.vectorsInRadius(Paintball.gameConfig.colorRadius)
.filter { Random.Default.nextDouble() < ((Paintball.gameConfig.colorRadius.toDouble() * .6) / it.length()) }
val radius = round(Paintball.gameConfig.colorRadius * multiplier).toInt()

val blocksAround = VectorUtils.vectorsInRadius(radius)
.filter { Random.Default.nextDouble() < ((radius.toDouble() * .6) / it.length()) }
.map { location.clone().add(it).block }

val replacedColors = blocksAround.map(replaceWithColor(team.material)).filter { it.first }.map { it.second }
Expand Down

0 comments on commit 9bc23cf

Please sign in to comment.