diff --git a/src/com/projectkorra/projectkorra/GeneralMethods.java b/src/com/projectkorra/projectkorra/GeneralMethods.java index 6cb31770..e00dbd8e 100644 --- a/src/com/projectkorra/projectkorra/GeneralMethods.java +++ b/src/com/projectkorra/projectkorra/GeneralMethods.java @@ -650,7 +650,9 @@ public class GeneralMethods { */ public static void dropItems(final Block block, final Collection items) { for (final ItemStack item : items) { - block.getWorld().dropItem(block.getLocation(), item); + if(item.getType() != Material.AIR) { + block.getWorld().dropItem(block.getLocation(), item); + } } } diff --git a/src/com/projectkorra/projectkorra/airbending/AirBlast.java b/src/com/projectkorra/projectkorra/airbending/AirBlast.java index d6beae7e..7ff93428 100644 --- a/src/com/projectkorra/projectkorra/airbending/AirBlast.java +++ b/src/com/projectkorra/projectkorra/airbending/AirBlast.java @@ -20,6 +20,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; +import org.bukkit.util.BlockIterator; import org.bukkit.util.Vector; import com.projectkorra.projectkorra.BendingPlayer; @@ -206,12 +207,35 @@ public class AirBlast extends AirAbility { if (this.random.nextInt(4) == 0) { playAirbendingSound(this.location); } - if (GeneralMethods.checkDiagonalWall(this.location, this.direction)) { + + BlockIterator blocks = new BlockIterator(this.getLocation().getWorld(), this.location.toVector(), this.direction, 0, (int) Math.ceil(this.direction.clone().multiply(speedFactor).length())); + + while (blocks.hasNext() && checkLocation(blocks.next())); + + this.location.add(this.direction.clone().multiply(speedFactor)); + } + + public boolean checkLocation(Block block) { + if (GeneralMethods.checkDiagonalWall(block.getLocation(), this.direction)) { this.remove(); - return; + return false; } - this.location = this.location.add(this.direction.clone().multiply(this.speedFactor)); + if ((!block.isPassable() || block.isLiquid()) && !this.affectedLevers.contains(block)) { + if (block.getType() == Material.LAVA && this.canCoolLava) { + if (LavaFlow.isLavaFlowBlock(block)) { + LavaFlow.removeBlock(block); // TODO: Make more generic for future lava generating moves. + } else if (block.getBlockData() instanceof Levelled && ((Levelled) block.getBlockData()).getLevel() == 0) { + new TempBlock(block, Material.OBSIDIAN); + } else { + new TempBlock(block, Material.COBBLESTONE); + } + } + this.remove(); + return false; + } + + return true; } private void affect(final Entity entity) { @@ -400,20 +424,6 @@ public class AirBlast extends AirAbility { } } - if ((GeneralMethods.isSolid(block) || block.isLiquid()) && !this.affectedLevers.contains(block) && this.canCoolLava) { - if (block.getType() == Material.LAVA) { - if (LavaFlow.isLavaFlowBlock(block)) { - LavaFlow.removeBlock(block); // TODO: Make more generic for future lava generating moves. - } else if (block.getBlockData() instanceof Levelled && ((Levelled) block.getBlockData()).getLevel() == 0) { - new TempBlock(block, Material.OBSIDIAN); - } else { - new TempBlock(block, Material.COBBLESTONE); - } - } - this.remove(); - return; - } - /* * If a player presses shift and AirBlasts straight down then the * AirBlast's location gets messed up and reading the distance returns diff --git a/src/com/projectkorra/projectkorra/airbending/AirSwipe.java b/src/com/projectkorra/projectkorra/airbending/AirSwipe.java index 7225ff61..0030148d 100644 --- a/src/com/projectkorra/projectkorra/airbending/AirSwipe.java +++ b/src/com/projectkorra/projectkorra/airbending/AirSwipe.java @@ -14,6 +14,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; +import org.bukkit.util.BlockIterator; import org.bukkit.util.Vector; import com.projectkorra.projectkorra.GeneralMethods; @@ -145,6 +146,15 @@ public class AirSwipe extends AirAbility { for (final Vector direction : this.streams.keySet()) { Location location = this.streams.get(direction); if (direction != null && location != null) { + + BlockIterator blocks = new BlockIterator(this.getLocation().getWorld(), location.toVector(), direction, 0, (int) Math.ceil(direction.clone().multiply(speed).length())); + + while (blocks.hasNext()) { + if(!blocks.next().isPassable()) { + this.streams.remove(direction); + } + } + location = location.clone().add(direction.clone().multiply(this.speed)); this.streams.put(direction, location); @@ -152,7 +162,7 @@ public class AirSwipe extends AirAbility { this.streams.clear(); } else { final Block block = location.getBlock(); - if (!ElementalAbility.isTransparent(this.player, block)) { + if (!ElementalAbility.isTransparent(this.player, block) || !block.isPassable()) { this.streams.remove(direction); continue; } diff --git a/src/com/projectkorra/projectkorra/configuration/ConfigManager.java b/src/com/projectkorra/projectkorra/configuration/ConfigManager.java index 6f05790c..5e81ad74 100644 --- a/src/com/projectkorra/projectkorra/configuration/ConfigManager.java +++ b/src/com/projectkorra/projectkorra/configuration/ConfigManager.java @@ -505,7 +505,6 @@ public class ConfigManager { plantBlocks.add(Material.JUNGLE_LEAVES.toString()); plantBlocks.add(Material.OAK_LEAVES.toString()); plantBlocks.add(Material.SPRUCE_LEAVES.toString()); - plantBlocks.add(Material.DEAD_BUSH.toString()); plantBlocks.add(Material.ORANGE_TULIP.toString()); plantBlocks.add(Material.PINK_TULIP.toString()); plantBlocks.add(Material.RED_TULIP.toString()); @@ -812,9 +811,9 @@ public class ConfigManager { config.addDefault("Abilities.Air.Passive.GracefulDescent.Enabled", true); config.addDefault("Abilities.Air.AirBlast.Enabled", true); - config.addDefault("Abilities.Air.AirBlast.Speed", 25); + config.addDefault("Abilities.Air.AirBlast.Speed", 15); config.addDefault("Abilities.Air.AirBlast.Range", 20); - config.addDefault("Abilities.Air.AirBlast.Radius", 2); + config.addDefault("Abilities.Air.AirBlast.Radius", .5); config.addDefault("Abilities.Air.AirBlast.SelectRange", 10); config.addDefault("Abilities.Air.AirBlast.SelectParticles", 4); config.addDefault("Abilities.Air.AirBlast.Particles", 6); @@ -866,7 +865,7 @@ public class ConfigManager { config.addDefault("Abilities.Air.AirSuction.Speed", 25); config.addDefault("Abilities.Air.AirSuction.Range", 20); config.addDefault("Abilities.Air.AirSuction.SelectRange", 10); - config.addDefault("Abilities.Air.AirSuction.Radius", 2); + config.addDefault("Abilities.Air.AirSuction.Radius", .5); config.addDefault("Abilities.Air.AirSuction.Push.Self", 2.0); config.addDefault("Abilities.Air.AirSuction.Push.Others", 1.3); config.addDefault("Abilities.Air.AirSuction.Cooldown", 500); @@ -974,7 +973,7 @@ public class ConfigManager { config.addDefault("Abilities.Water.IceBlast.Damage", 3); config.addDefault("Abilities.Water.IceBlast.Range", 20); config.addDefault("Abilities.Water.IceBlast.DeflectRange", 3); - config.addDefault("Abilities.Water.IceBlast.CollisionRadius", 1.5); + config.addDefault("Abilities.Water.IceBlast.CollisionRadius", 1.0); config.addDefault("Abilities.Water.IceBlast.Interval", 20); config.addDefault("Abilities.Water.IceBlast.Cooldown", 1500); config.addDefault("Abilities.Water.IceBlast.AllowSnow", false); @@ -995,7 +994,7 @@ public class ConfigManager { config.addDefault("Abilities.Water.IceSpike.Field.Cooldown", 2000); config.addDefault("Abilities.Water.IceSpike.Blast.Range", 20); config.addDefault("Abilities.Water.IceSpike.Blast.Damage", 1); - config.addDefault("Abilities.Water.IceSpike.Blast.CollisionRadius", 1.5); + config.addDefault("Abilities.Water.IceSpike.Blast.CollisionRadius", 1.0); config.addDefault("Abilities.Water.IceSpike.Blast.DeflectRange", 3); config.addDefault("Abilities.Water.IceSpike.Blast.Cooldown", 500); config.addDefault("Abilities.Water.IceSpike.Blast.SlowCooldown", 5000); @@ -1139,7 +1138,7 @@ public class ConfigManager { config.addDefault("Abilities.Water.WaterManipulation.Damage", 3.0); config.addDefault("Abilities.Water.WaterManipulation.Range", 25); config.addDefault("Abilities.Water.WaterManipulation.SelectRange", 16); - config.addDefault("Abilities.Water.WaterManipulation.CollisionRadius", 1.5); + config.addDefault("Abilities.Water.WaterManipulation.CollisionRadius", 1.0); config.addDefault("Abilities.Water.WaterManipulation.DeflectRange", 3); config.addDefault("Abilities.Water.WaterManipulation.Speed", 35); config.addDefault("Abilities.Water.WaterManipulation.Knockback", 0.3); @@ -1362,7 +1361,7 @@ public class ConfigManager { config.addDefault("Abilities.Fire.FireBlast.Enabled", true); config.addDefault("Abilities.Fire.FireBlast.Speed", 20); config.addDefault("Abilities.Fire.FireBlast.Range", 20); - config.addDefault("Abilities.Fire.FireBlast.CollisionRadius", 1.5); + config.addDefault("Abilities.Fire.FireBlast.CollisionRadius", 1.0); config.addDefault("Abilities.Fire.FireBlast.Knockback", 0.3); config.addDefault("Abilities.Fire.FireBlast.Damage", 3); config.addDefault("Abilities.Fire.FireBlast.Cooldown", 1500); diff --git a/src/com/projectkorra/projectkorra/firebending/FireBlast.java b/src/com/projectkorra/projectkorra/firebending/FireBlast.java index c6481f96..9aa7c330 100644 --- a/src/com/projectkorra/projectkorra/firebending/FireBlast.java +++ b/src/com/projectkorra/projectkorra/firebending/FireBlast.java @@ -15,6 +15,7 @@ import org.bukkit.block.Smoker; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.util.BlockIterator; import org.bukkit.util.Vector; import com.projectkorra.projectkorra.GeneralMethods; @@ -72,13 +73,13 @@ public class FireBlast extends FireAbility { this.setFields(); this.safeBlocks = safeBlocks; - + this.damage = damage; this.location = location.clone(); this.origin = location.clone(); this.direction = direction.clone().normalize(); // The following code determines the total additive modifier between Blue Fire & Day Modifiers - this.applyModifiers(); + this.applyModifiers(this.damage, this.range); this.start(); } @@ -102,18 +103,18 @@ public class FireBlast extends FireAbility { this.location = this.location.add(this.direction.clone()); // The following code determines the total additive modifier between Blue Fire & Day Modifiers - this.applyModifiers(); + this.applyModifiers(this.damage, this.range); this.start(); this.bPlayer.addCooldown("FireBlast", this.cooldown); } - private void applyModifiers() { + private void applyModifiers(double damage, double range) { int damageMod = 0; int rangeMod = 0; damageMod = (int) (this.getDayFactor(damage) - damage); - rangeMod = (int) (this.getDayFactor(this.range) - this.range); + rangeMod = (int) (this.getDayFactor(range) - range); damageMod = (int) (bPlayer.canUseSubElement(SubElement.BLUE_FIRE) ? (BlueFireAbility.getDamageFactor() * damage - damage) + damageMod : damageMod); rangeMod = (int) (bPlayer.canUseSubElement(SubElement.BLUE_FIRE) ? (BlueFireAbility.getRangeFactor() * range - range) + rangeMod : rangeMod); @@ -152,6 +153,12 @@ public class FireBlast extends FireAbility { return; } + + BlockIterator blocks = new BlockIterator(this.getLocation().getWorld(), this.location.toVector(), this.direction, 0, (int) Math.ceil(this.direction.clone().multiply(speedFactor).length())); + + while (blocks.hasNext() && checkLocation(blocks.next())); + + this.location.add(this.direction.clone().multiply(speedFactor)); this.location = this.location.add(this.direction.clone().multiply(this.speedFactor)); if (this.random.nextInt(4) == 0) { @@ -159,6 +166,14 @@ public class FireBlast extends FireAbility { } } + public boolean checkLocation(Block block) { + if (GeneralMethods.checkDiagonalWall(block.getLocation(), this.direction) || !block.isPassable()) { + this.remove(); + return false; + } + + return true; + } private void affect(final Entity entity) { if (entity.getUniqueId() != this.player.getUniqueId() && !GeneralMethods.isRegionProtectedFromBuild(this, entity.getLocation()) && !((entity instanceof Player) && Commands.invincible.contains(((Player) entity).getName()))) { if (this.bPlayer.isAvatarState()) {