mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2024-12-23 00:15:05 +00:00
Fix EarthBlast and Suffocate, and clean up RaiseEarth (#1009)
## Additions * Adds logic for EarthBlast being used on ceilings * Adds default cooldown to Suffocate ## Changes * Fixes Suffocate being usable through walls * Improves logic for EarthBlast pathing in general ## Removals * `ALL_AFFECTED_BLOCKS` in RaiseEarth isn't actually used, removes it.
This commit is contained in:
parent
3972104586
commit
cd9968a1c1
5 changed files with 29 additions and 14 deletions
|
@ -1188,7 +1188,7 @@ public class GeneralMethods {
|
|||
return getTargetedEntity(player, range, new ArrayList<Entity>());
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
|
@ -1209,6 +1209,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();
|
||||
|
||||
if (trans.contains(block.getType())) {
|
||||
|
@ -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) {
|
||||
|
|
|
@ -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<Entity> 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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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<Block, Block> 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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue