diff --git a/src/com/projectkorra/projectkorra/configuration/ConfigManager.java b/src/com/projectkorra/projectkorra/configuration/ConfigManager.java index 4fc6c4f7..5b6a7f10 100644 --- a/src/com/projectkorra/projectkorra/configuration/ConfigManager.java +++ b/src/com/projectkorra/projectkorra/configuration/ConfigManager.java @@ -257,7 +257,7 @@ public class ConfigManager { config.addDefault("Abilities.Water.IceSpike.DeathMessage", "{victim} was impaled by {attacker}'s {ability}"); config.addDefault("Abilities.Water.OctopusForm.Description", "This ability allows the waterbender to manipulate a large quantity of water into a form resembling that of an octopus. " + "To use, left click to select a water source. Then, hold sneak to channel this ability. " + "While channeling, the water will form itself around you and has a chance to block incoming attacks. " + "Additionally, you can left click while channeling to attack things near you, dealing damage and knocking them back. " + "Releasing sneak at any time will dissipate the form."); config.addDefault("Abilities.Water.OctopusForm.DeathMessage", "{victim} was slapped by {attacker}'s {ability}"); - config.addDefault("Abilities.Water.PhaseChange.Description", "To use, simply left-click. " + "Any water you are looking at within range will instantly freeze over into solid ice. " + "Provided you stay within range of the ice, " + "that ice will not thaw. If, however, you do either of those the ice will instantly thaw. " + "If you sneak (default: shift), anything around where you are looking at will instantly melt. " + "Since this is a more favorable state for these things, they will never re-freeze unless they " + "would otherwise by nature or some other bending ability." + " Sneaking while running will cause you to skate forwards on ice, and create ice from water under you." + " Having PhaseChange bound while moving removes ice from where you are standing and directly in front of you."/* Additionally, if you tap sneak while " + "targeting water with PhaseChange, it will evaporate water around that block that is above " + "sea level. "*/); + config.addDefault("Abilities.Water.PhaseChange.Description", "This ability has 2 functions, Freeze and Melt. \n- Freeze: This function is activated by left clicking. It will freeze any water in a certain radius of where you are looking. \n- Melt: This function is activated by sneaking. It will melt ice in a radius of where you are looking. The melting isn't instant!"/*\n- Skate*/); config.addDefault("Abilities.Water.PlantArmor.Description", "PlantArmor is a defensive ability in the arsenal of the plantbender. Clicking on leaves with this ability will temporarily clad you in strong armor made out of plants! You can use this defensively, but you can also use the armor as a source for other plantbending skills."); config.addDefault("Abilities.Water.Surge.Description", "This ability has two distinct features. If you sneak to select a source block, you can then click in a direction and a large wave will be launched in that direction. If you sneak again while the wave is en route, the wave will freeze the next target it hits. If, instead, you click to select a source block, you can hold sneak to form a wall of water at your cursor location. Click to shift between a water wall and an ice wall. Release sneak to dissipate it."); config.addDefault("Abilities.Water.Torrent.Description", "Torrent is one of the strongest moves in a waterbender's arsenal. To use, first click a source block to select it; then hold shift to begin streaming the water around you. Water flowing around you this way will damage and knock back nearby enemies and projectiles. If you release shift during this, you will create a large wave that expands outwards from you, launching anything in its path back. Instead, if you click you release the water and channel it to flow towards your cursor. Anything caught in the blast will be tossed about violently and take damage. Finally, if you click again when the water is torrenting, it will freeze the area around it when it is obstructed."); @@ -679,10 +679,10 @@ public class ConfigManager { config.addDefault("Abilities.Water.PhaseChange.Melt.Delay", 50); config.addDefault("Abilities.Water.PhaseChange.Melt.Radius", 7); config.addDefault("Abilities.Water.PhaseChange.Melt.AllowFlow", true); - config.addDefault("Abilities.Water.PhaseChange.Skate.Cooldown", 7000); + /*config.addDefault("Abilities.Water.PhaseChange.Skate.Cooldown", 7000); config.addDefault("Abilities.Water.PhaseChange.Skate.Duration", 7000); config.addDefault("Abilities.Water.PhaseChange.Skate.Radius", 1); - config.addDefault("Abilities.Water.PhaseChange.Skate.Speed", 0.335); + config.addDefault("Abilities.Water.PhaseChange.Skate.Speed", 0.335);*/ config.addDefault("Abilities.Water.PlantArmor.Enabled", true); config.addDefault("Abilities.Water.PlantArmor.Duration", 7500); diff --git a/src/com/projectkorra/projectkorra/firebending/HeatControl.java b/src/com/projectkorra/projectkorra/firebending/HeatControl.java index fa085a11..483c9fa5 100644 --- a/src/com/projectkorra/projectkorra/firebending/HeatControl.java +++ b/src/com/projectkorra/projectkorra/firebending/HeatControl.java @@ -310,6 +310,13 @@ public class HeatControl extends FireAbility { return; } + if (TempBlock.isTempBlock(block)) { + TempBlock tb = TempBlock.get(block); + if (PhaseChange.getFrozenBlocksAsTempBlock().contains(tb)) { + PhaseChange.thaw(tb); + } + } + WaterSpoutWave.thaw(block); WaterCombo.thaw(block); @@ -317,8 +324,6 @@ public class HeatControl extends FireAbility { if (block.getType() == Material.SNOW) { block.setType(Material.AIR); return; - } else if (PhaseChange.getFrozenBlocksAsBlock().contains(block)) { - PhaseChange.thaw(block); } else { TempBlock tb = new TempBlock(block, Material.WATER, (byte)0); MELTED_BLOCKS.put(block, tb); diff --git a/src/com/projectkorra/projectkorra/waterbending/PhaseChange.java b/src/com/projectkorra/projectkorra/waterbending/PhaseChange.java index 343ae40d..e0c63730 100644 --- a/src/com/projectkorra/projectkorra/waterbending/PhaseChange.java +++ b/src/com/projectkorra/projectkorra/waterbending/PhaseChange.java @@ -5,13 +5,14 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Random; -import java.util.Set; import java.util.concurrent.CopyOnWriteArrayList; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; +import org.bukkit.util.Vector; import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ability.IceAbility; @@ -164,7 +165,7 @@ public class PhaseChange extends IceAbility { freezeCooldown = getConfig().getLong("Abilities.Water.PhaseChange.Freeze.Cooldown"); freezeRadius = night*getConfig().getInt("Abilities.Water.PhaseChange.Freeze.Radius"); - freezeArea(player.getTargetBlock((Set)null, sourceRange).getLocation()); + freezeArea(GeneralMethods.getTargetedLocation(player, sourceRange)); } else if (type == PhaseChangeType.MELT) { meltRadius = 1; meltCooldown = getConfig().getLong("Abilities.Water.PhaseChange.Melt.Cooldown"); @@ -208,6 +209,59 @@ public class PhaseChange extends IceAbility { } } + public ArrayList getBlockFacesTowardsPlayer(Location center) { + ArrayList faces = new ArrayList<>(); + Vector toPlayer = GeneralMethods.getDirection(center, player.getEyeLocation()); + double[] vars = {toPlayer.getX(), toPlayer.getY(), toPlayer.getZ()}; + for (int i = 0; i < 3; i++) { + if (vars[i] != 0) { + faces.add(getBlockFaceFromValue(i, vars[i])); + } else { + continue; + } + } + return faces; + } + + private BlockFace getBlockFaceFromValue(int xyz, double value) { + switch (xyz) { + case 0: + if (value > 0) { + return BlockFace.EAST; + } else if (value < 0) { + return BlockFace.WEST; + } + case 1: + if (value > 0) { + return BlockFace.UP; + } else if (value < 0) { + return BlockFace.DOWN; + } + case 2: + if (value > 0) { + return BlockFace.SOUTH; + } else if (value < 0) { + return BlockFace.NORTH; + } + default: return null; + } + } + + public ArrayList getBlocksToFreeze(Location center, int radius) { + ArrayList blocks = new ArrayList<>(); + for (Location l : GeneralMethods.getCircle(center, radius, depth, false, true, 0)) { + Block b = l.getBlock(); + loop: for (int i = 1; i <= depth; i++) { + for (BlockFace face : getBlockFacesTowardsPlayer(center)) { + if (b.getRelative(face, i).getType() == Material.AIR) { + blocks.add(b); + break loop; + } + } + } + } + return blocks; + } public void freezeArea(Location center, int radius, PhaseChangeType type) { if (type == PhaseChangeType.FREEZE) { if (bPlayer.isOnCooldown("PhaseChangeFreeze")) { @@ -219,8 +273,9 @@ public class PhaseChange extends IceAbility { center.subtract(0, depth-1, 0); } - for (Location l : GeneralMethods.getCircle(center, radius, depth, false, false, 0)) { - freeze(l.getBlock()); + ArrayList toFreeze = getBlocksToFreeze(center, radius); + for (Block b : toFreeze) { + freeze(b); } if (!blocks.isEmpty()) { @@ -265,13 +320,12 @@ public class PhaseChange extends IceAbility { tb = TempBlock.get(b); if (melted_blocks.contains(tb.getBlock())) { melted_blocks.remove(tb.getBlock()); + tb.revertBlock(); + tb.setType(Material.ICE); } - tb.revertBlock(); } if (tb == null) { tb = new TempBlock(b, Material.ICE, (byte)0); - } else { - tb.setType(Material.ICE); } blocks.add(tb); PLAYER_BY_BLOCK.put(tb, player); @@ -284,7 +338,7 @@ public class PhaseChange extends IceAbility { List ice = new ArrayList(); for (Location l : GeneralMethods.getCircle(center, radius, 3, true, true, 0)) { - if (isIce(l.getBlock())) { + if (isIce(l.getBlock()) || isSnow(l.getBlock())) { ice.add(l.getBlock()); } } @@ -304,30 +358,44 @@ public class PhaseChange extends IceAbility { meltArea(center, meltRadius); } + @SuppressWarnings("deprecation") public void melt(Block b) { if (b.getWorld() != player.getWorld()) { return; } - if (b.getLocation().distanceSquared(player.getLocation()) > controlRadius*controlRadius) { return; } - if (GeneralMethods.isRegionProtectedFromBuild(player, b.getLocation())) { return; } - + if (SurgeWall.getWallBlocks().containsKey(b)) { + return; + } + if (SurgeWave.isBlockWave(b)) { + return; + } + if (!SurgeWave.canThaw(b)) { + SurgeWave.thaw(b); + return; + } + if (!Torrent.canThaw(b)) { + Torrent.thaw(b); + return; + } + if (WaterArmsSpear.canThaw(b)) { + WaterArmsSpear.thaw(b); + return; + } if (TempBlock.isTempBlock(b)) { TempBlock tb = TempBlock.get(b); - if (!isIce(tb.getBlock())) { + if (!isIce(tb.getBlock()) && !isSnow(tb.getBlock())) { return; } - tb.revertBlock(); - if (blocks.contains(tb)) { - blocks.remove(tb); - PLAYER_BY_BLOCK.remove(tb); + if (PLAYER_BY_BLOCK.containsKey(tb)) { + thaw(tb); } } else if (isWater(b)) { //Figure out what to do here also @@ -335,6 +403,12 @@ public class PhaseChange extends IceAbility { Material m = allowMeltFlow ? Material.WATER : Material.STATIONARY_WATER; b.setType(m); melted_blocks.add(b); + } else if (isSnow(b)) { + byte data = b.getData(); + Material m = allowMeltFlow ? Material.WATER : Material.STATIONARY_WATER; + b.setType(m); + b.setData(data); + melted_blocks.add(b); } } /** @@ -356,9 +430,9 @@ public class PhaseChange extends IceAbility { } /** - * Only works if the block is a {#link TempBlock} and PhaseChange frozen! + * Only works if the block is a {@link TempBlock} and PhaseChange frozen! * @param b Block being thawed - * @return false if not a {#link TempBlock} + * @return false if not a {@link TempBlock} */ public static boolean thaw(Block b) { if (!TempBlock.isTempBlock(b)) {