Fix Outstanding Bugs (#1073)

## Fixes
* Fixes AirBlast, FireBlast, and AirSwipe going through walls
* Fixes FireBurst not doing damage.
* Fixes GeneralMethods#dropItems not checking for invalid drops.

## Misc. Changes
* Reduce collision radii for most abilities.
This commit is contained in:
Vahagn Tovmasian 2020-07-28 14:21:36 -07:00 committed by GitHub
parent f0dc7ce32b
commit 2d27c3cbbe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 68 additions and 32 deletions

View file

@ -650,7 +650,9 @@ public class GeneralMethods {
*/ */
public static void dropItems(final Block block, final Collection<ItemStack> items) { public static void dropItems(final Block block, final Collection<ItemStack> items) {
for (final ItemStack item : items) { for (final ItemStack item : items) {
block.getWorld().dropItem(block.getLocation(), item); if(item.getType() != Material.AIR) {
block.getWorld().dropItem(block.getLocation(), item);
}
} }
} }

View file

@ -20,6 +20,7 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.BlockIterator;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import com.projectkorra.projectkorra.BendingPlayer; import com.projectkorra.projectkorra.BendingPlayer;
@ -206,12 +207,35 @@ public class AirBlast extends AirAbility {
if (this.random.nextInt(4) == 0) { if (this.random.nextInt(4) == 0) {
playAirbendingSound(this.location); 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(); 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) { 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 * If a player presses shift and AirBlasts straight down then the
* AirBlast's location gets messed up and reading the distance returns * AirBlast's location gets messed up and reading the distance returns

View file

@ -14,6 +14,7 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.BlockIterator;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.GeneralMethods;
@ -145,6 +146,15 @@ public class AirSwipe extends AirAbility {
for (final Vector direction : this.streams.keySet()) { for (final Vector direction : this.streams.keySet()) {
Location location = this.streams.get(direction); Location location = this.streams.get(direction);
if (direction != null && location != null) { 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)); location = location.clone().add(direction.clone().multiply(this.speed));
this.streams.put(direction, location); this.streams.put(direction, location);
@ -152,7 +162,7 @@ public class AirSwipe extends AirAbility {
this.streams.clear(); this.streams.clear();
} else { } else {
final Block block = location.getBlock(); final Block block = location.getBlock();
if (!ElementalAbility.isTransparent(this.player, block)) { if (!ElementalAbility.isTransparent(this.player, block) || !block.isPassable()) {
this.streams.remove(direction); this.streams.remove(direction);
continue; continue;
} }

View file

@ -505,7 +505,6 @@ public class ConfigManager {
plantBlocks.add(Material.JUNGLE_LEAVES.toString()); plantBlocks.add(Material.JUNGLE_LEAVES.toString());
plantBlocks.add(Material.OAK_LEAVES.toString()); plantBlocks.add(Material.OAK_LEAVES.toString());
plantBlocks.add(Material.SPRUCE_LEAVES.toString()); plantBlocks.add(Material.SPRUCE_LEAVES.toString());
plantBlocks.add(Material.DEAD_BUSH.toString());
plantBlocks.add(Material.ORANGE_TULIP.toString()); plantBlocks.add(Material.ORANGE_TULIP.toString());
plantBlocks.add(Material.PINK_TULIP.toString()); plantBlocks.add(Material.PINK_TULIP.toString());
plantBlocks.add(Material.RED_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.Passive.GracefulDescent.Enabled", true);
config.addDefault("Abilities.Air.AirBlast.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.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.SelectRange", 10);
config.addDefault("Abilities.Air.AirBlast.SelectParticles", 4); config.addDefault("Abilities.Air.AirBlast.SelectParticles", 4);
config.addDefault("Abilities.Air.AirBlast.Particles", 6); 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.Speed", 25);
config.addDefault("Abilities.Air.AirSuction.Range", 20); config.addDefault("Abilities.Air.AirSuction.Range", 20);
config.addDefault("Abilities.Air.AirSuction.SelectRange", 10); 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.Self", 2.0);
config.addDefault("Abilities.Air.AirSuction.Push.Others", 1.3); config.addDefault("Abilities.Air.AirSuction.Push.Others", 1.3);
config.addDefault("Abilities.Air.AirSuction.Cooldown", 500); 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.Damage", 3);
config.addDefault("Abilities.Water.IceBlast.Range", 20); config.addDefault("Abilities.Water.IceBlast.Range", 20);
config.addDefault("Abilities.Water.IceBlast.DeflectRange", 3); 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.Interval", 20);
config.addDefault("Abilities.Water.IceBlast.Cooldown", 1500); config.addDefault("Abilities.Water.IceBlast.Cooldown", 1500);
config.addDefault("Abilities.Water.IceBlast.AllowSnow", false); 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.Field.Cooldown", 2000);
config.addDefault("Abilities.Water.IceSpike.Blast.Range", 20); config.addDefault("Abilities.Water.IceSpike.Blast.Range", 20);
config.addDefault("Abilities.Water.IceSpike.Blast.Damage", 1); 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.DeflectRange", 3);
config.addDefault("Abilities.Water.IceSpike.Blast.Cooldown", 500); config.addDefault("Abilities.Water.IceSpike.Blast.Cooldown", 500);
config.addDefault("Abilities.Water.IceSpike.Blast.SlowCooldown", 5000); 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.Damage", 3.0);
config.addDefault("Abilities.Water.WaterManipulation.Range", 25); config.addDefault("Abilities.Water.WaterManipulation.Range", 25);
config.addDefault("Abilities.Water.WaterManipulation.SelectRange", 16); 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.DeflectRange", 3);
config.addDefault("Abilities.Water.WaterManipulation.Speed", 35); config.addDefault("Abilities.Water.WaterManipulation.Speed", 35);
config.addDefault("Abilities.Water.WaterManipulation.Knockback", 0.3); 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.Enabled", true);
config.addDefault("Abilities.Fire.FireBlast.Speed", 20); config.addDefault("Abilities.Fire.FireBlast.Speed", 20);
config.addDefault("Abilities.Fire.FireBlast.Range", 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.Knockback", 0.3);
config.addDefault("Abilities.Fire.FireBlast.Damage", 3); config.addDefault("Abilities.Fire.FireBlast.Damage", 3);
config.addDefault("Abilities.Fire.FireBlast.Cooldown", 1500); config.addDefault("Abilities.Fire.FireBlast.Cooldown", 1500);

View file

@ -15,6 +15,7 @@ import org.bukkit.block.Smoker;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.BlockIterator;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.GeneralMethods;
@ -72,13 +73,13 @@ public class FireBlast extends FireAbility {
this.setFields(); this.setFields();
this.safeBlocks = safeBlocks; this.safeBlocks = safeBlocks;
this.damage = damage;
this.location = location.clone(); this.location = location.clone();
this.origin = location.clone(); this.origin = location.clone();
this.direction = direction.clone().normalize(); this.direction = direction.clone().normalize();
// The following code determines the total additive modifier between Blue Fire & Day Modifiers // The following code determines the total additive modifier between Blue Fire & Day Modifiers
this.applyModifiers(); this.applyModifiers(this.damage, this.range);
this.start(); this.start();
} }
@ -102,18 +103,18 @@ public class FireBlast extends FireAbility {
this.location = this.location.add(this.direction.clone()); this.location = this.location.add(this.direction.clone());
// The following code determines the total additive modifier between Blue Fire & Day Modifiers // The following code determines the total additive modifier between Blue Fire & Day Modifiers
this.applyModifiers(); this.applyModifiers(this.damage, this.range);
this.start(); this.start();
this.bPlayer.addCooldown("FireBlast", this.cooldown); this.bPlayer.addCooldown("FireBlast", this.cooldown);
} }
private void applyModifiers() { private void applyModifiers(double damage, double range) {
int damageMod = 0; int damageMod = 0;
int rangeMod = 0; int rangeMod = 0;
damageMod = (int) (this.getDayFactor(damage) - damage); 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); 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); rangeMod = (int) (bPlayer.canUseSubElement(SubElement.BLUE_FIRE) ? (BlueFireAbility.getRangeFactor() * range - range) + rangeMod : rangeMod);
@ -152,6 +153,12 @@ public class FireBlast extends FireAbility {
return; 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)); this.location = this.location.add(this.direction.clone().multiply(this.speedFactor));
if (this.random.nextInt(4) == 0) { 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) { 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 (entity.getUniqueId() != this.player.getUniqueId() && !GeneralMethods.isRegionProtectedFromBuild(this, entity.getLocation()) && !((entity instanceof Player) && Commands.invincible.contains(((Player) entity).getName()))) {
if (this.bPlayer.isAvatarState()) { if (this.bPlayer.isAvatarState()) {