Last active
April 9, 2017 07:08
-
-
Save 4xDMG/c9bd662941bf0c774e47523b31df1177 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const magik = magikcraft.io; | |
function floodBoom(power = 1) { | |
if (power > 5) { | |
power = 5; | |
} | |
var target = magik.getSender().getTargetBlock(null, 100); | |
var blockType = target.getType(); | |
var blockLoc = target.getLocation(); | |
recursiveBoom(blockLoc, blockType, 0, checkPower(power)); | |
} | |
function checkPower(power) { | |
if (power > 5) return 5; | |
return power; | |
} | |
function recursiveBoom(blockLoc, blockType, count, power) { | |
var target = blockLoc; | |
var x = target.getX(); | |
var y = target.getY(); | |
var z = target.getZ(); | |
if (count > 100) { | |
return; | |
} | |
if (blockLoc.getBlock().getType() === blockType) { | |
magik.getSender().getWorld().createExplosion(x, y, z, power, true, true); | |
var newBlockLoc = blockLoc; | |
var Location = org.bukkit.Location; | |
recursiveBoom(new Location(magik.getSender().getWorld(), x + 1, y, z), blockType, count + 1, power); | |
recursiveBoom(new Location(magik.getSender().getWorld(), x - 1, y, z), blockType, count + 1, power); | |
recursiveBoom(new Location(magik.getSender().getWorld(), x, y+1, z), blockType, count + 1, power); | |
recursiveBoom(new Location(magik.getSender().getWorld(), x, y-1, z), blockType, count + 1, power); | |
recursiveBoom(new Location(magik.getSender().getWorld(), x, y, z+1), blockType, count + 1, power); | |
recursiveBoom(new Location(magik.getSender().getWorld(), x, y, z-1), blockType, count + 1, power); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment