diff --git a/src/com/projectkorra/projectkorra/GeneralMethods.java b/src/com/projectkorra/projectkorra/GeneralMethods.java index 1c7c24d8..ccf82892 100644 --- a/src/com/projectkorra/projectkorra/GeneralMethods.java +++ b/src/com/projectkorra/projectkorra/GeneralMethods.java @@ -1187,8 +1187,8 @@ public class GeneralMethods { public static Entity getTargetedEntity(final Player player, final double range) { return getTargetedEntity(player, range, new ArrayList()); } - - public static Location getTargetedLocation(final Player player, final double range, final boolean ignoreTempBlocks, final Material... nonOpaque2) { + + public static Location getTargetedLocation(final Player player, final double range, final boolean ignoreTempBlocks, final boolean checkDiagonals, final Material... nonOpaque2) { final Location origin = player.getEyeLocation(); final Vector direction = origin.getDirection(); @@ -1208,6 +1208,11 @@ public class GeneralMethods { for (double i = 0; i < range; i += 0.2) { location.add(vec); + + if (checkDiagonals && checkDiagonalWall(location, vec)) { + location.subtract(vec); + break; + } final Block block = location.getBlock(); @@ -1224,12 +1229,16 @@ public class GeneralMethods { return location; } + public static Location getTargetedLocation(final Player player, final double range, final boolean ignoreTempBlocks, final Material... nonOpaque2) { + return getTargetedLocation(player, range, ignoreTempBlocks, true, nonOpaque2); + } + public static Location getTargetedLocation(final Player player, final double range, final Material... nonOpaque2) { return getTargetedLocation(player, range, false, nonOpaque2); } public static Location getTargetedLocation(final Player player, final int range) { - return getTargetedLocation(player, range, Material.AIR); + return getTargetedLocation(player, range); } public static Block getTopBlock(final Location loc, final int range) { diff --git a/src/com/projectkorra/projectkorra/airbending/Suffocate.java b/src/com/projectkorra/projectkorra/airbending/Suffocate.java index 81623b49..a42abeae 100644 --- a/src/com/projectkorra/projectkorra/airbending/Suffocate.java +++ b/src/com/projectkorra/projectkorra/airbending/Suffocate.java @@ -142,7 +142,6 @@ public class Suffocate extends AirAbility { } } - this.bPlayer.addCooldown(this); this.start(); } @@ -171,7 +170,7 @@ public class Suffocate extends AirAbility { if (this.player.getWorld().equals(this.targets.get(0).getWorld())) { dist = this.player.getEyeLocation().distance(this.targets.get(0).getEyeLocation()); } - final Location targetLoc = this.player.getEyeLocation().clone().add(this.player.getEyeLocation().getDirection().normalize().multiply(dist)); + final Location targetLoc = GeneralMethods.getTargetedLocation(player, dist, false, getTransparentMaterials()); final List ents = GeneralMethods.getEntitiesAroundPoint(targetLoc, this.constantAimRadius); for (int i = 0; i < this.targets.size(); i++) { @@ -336,6 +335,7 @@ public class Suffocate extends AirAbility { @Override public void remove() { super.remove(); + this.bPlayer.addCooldown(this); for (int i = 0; i < this.tasks.size(); i++) { this.tasks.get(i).cancel(); this.tasks.remove(i); diff --git a/src/com/projectkorra/projectkorra/configuration/ConfigManager.java b/src/com/projectkorra/projectkorra/configuration/ConfigManager.java index e90002d9..871f4ada 100644 --- a/src/com/projectkorra/projectkorra/configuration/ConfigManager.java +++ b/src/com/projectkorra/projectkorra/configuration/ConfigManager.java @@ -876,7 +876,7 @@ public class ConfigManager { config.addDefault("Abilities.Air.Suffocate.Enabled", true); config.addDefault("Abilities.Air.Suffocate.ChargeTime", 500); - config.addDefault("Abilities.Air.Suffocate.Cooldown", 0); + config.addDefault("Abilities.Air.Suffocate.Cooldown", 6500); config.addDefault("Abilities.Air.Suffocate.Range", 20); config.addDefault("Abilities.Air.Suffocate.Damage", 2); config.addDefault("Abilities.Air.Suffocate.DamageInitialDelay", 2); diff --git a/src/com/projectkorra/projectkorra/earthbending/EarthBlast.java b/src/com/projectkorra/projectkorra/earthbending/EarthBlast.java index b00cf9ad..6157139e 100644 --- a/src/com/projectkorra/projectkorra/earthbending/EarthBlast.java +++ b/src/com/projectkorra/projectkorra/earthbending/EarthBlast.java @@ -5,6 +5,7 @@ import java.util.ArrayList; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -71,7 +72,6 @@ public class EarthBlast extends EarthAbility { if (this.bPlayer.isAvatarState()) { this.cooldown = getConfig().getLong("Abilities.Avatar.AvatarState.Earth.EarthBlast.Cooldown"); this.damage = getConfig().getDouble("Abilities.Avatar.AvatarState.Earth.EarthBlast.Damage"); - } if (this.prepare()) { @@ -380,8 +380,12 @@ public class EarthBlast extends EarthAbility { this.firstDestination = this.location.clone(); if (this.destination.getY() - this.location.getY() > 2) { this.firstDestination.setY(this.destination.getY() - 1); - } else { + } else if (this.location.getY() > player.getEyeLocation().getY() && this.location.getBlock().getRelative(BlockFace.UP).isPassable()) { + this.firstDestination.subtract(0, 2, 0); + } else if (this.location.getBlock().getRelative(BlockFace.UP).isPassable() && this.location.getBlock().getRelative(BlockFace.UP, 2).isPassable()) { this.firstDestination.add(0, 2, 0); + } else { + this.firstDestination.add(GeneralMethods.getDirection(this.location, this.destination).normalize().setY(0)); } if (this.destination.distanceSquared(this.location) <= 1) { diff --git a/src/com/projectkorra/projectkorra/earthbending/RaiseEarth.java b/src/com/projectkorra/projectkorra/earthbending/RaiseEarth.java index fbc88f19..12330e89 100644 --- a/src/com/projectkorra/projectkorra/earthbending/RaiseEarth.java +++ b/src/com/projectkorra/projectkorra/earthbending/RaiseEarth.java @@ -2,7 +2,6 @@ package com.projectkorra.projectkorra.earthbending; import java.util.ArrayList; import java.util.List; -import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.bukkit.Location; @@ -15,11 +14,10 @@ import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.configuration.ConfigManager; import com.projectkorra.projectkorra.util.BlockSource; import com.projectkorra.projectkorra.util.ClickType; +import com.projectkorra.projectkorra.util.TempBlock; public class RaiseEarth extends EarthAbility { - private static final Map ALL_AFFECTED_BLOCKS = new ConcurrentHashMap<>(); - private int distance; @Attribute(Attribute.HEIGHT) private int height; @@ -104,7 +102,7 @@ public class RaiseEarth extends EarthAbility { private boolean canInstantiate() { for (final Block block : this.affectedBlocks.keySet()) { - if (!this.isEarthbendable(block) || ALL_AFFECTED_BLOCKS.containsKey(block)) { + if (!this.isEarthbendable(block) || TempBlock.isTempBlock(block)) { return false; } } @@ -143,11 +141,15 @@ public class RaiseEarth extends EarthAbility { } public static boolean blockInAllAffectedBlocks(final Block block) { - return ALL_AFFECTED_BLOCKS.containsKey(block); + for (RaiseEarth raiseEarth : getAbilities(RaiseEarth.class)) { + if (raiseEarth.affectedBlocks.contains(block)) { + return true; + } + } + return false; } public static void revertAffectedBlock(final Block block) { - ALL_AFFECTED_BLOCKS.remove(block); for (final RaiseEarth raiseEarth : getAbilities(RaiseEarth.class)) { raiseEarth.affectedBlocks.remove(block); }