mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2025-01-10 17:08:06 +00:00
EarthTunnel
This commit is contained in:
parent
767c99ed65
commit
3db97a4c75
5 changed files with 148 additions and 0 deletions
|
@ -29,6 +29,7 @@ import com.projectkorra.ProjectKorra.earthbending.EarthArmor;
|
|||
import com.projectkorra.ProjectKorra.earthbending.EarthBlast;
|
||||
import com.projectkorra.ProjectKorra.earthbending.EarthColumn;
|
||||
import com.projectkorra.ProjectKorra.earthbending.EarthPassive;
|
||||
import com.projectkorra.ProjectKorra.earthbending.EarthTunnel;
|
||||
import com.projectkorra.ProjectKorra.earthbending.Shockwave;
|
||||
import com.projectkorra.ProjectKorra.firebending.Cook;
|
||||
import com.projectkorra.ProjectKorra.firebending.FireBlast;
|
||||
|
@ -106,6 +107,9 @@ public class BendingManager implements Runnable {
|
|||
AirSuction.progressAll();
|
||||
Fireball.progressAll();
|
||||
HealingWaters.heal(Bukkit.getServer());
|
||||
for (Player player : EarthTunnel.instances.keySet()) {
|
||||
EarthTunnel.progress(player);
|
||||
}
|
||||
for (Player player : EarthArmor.instances.keySet()) {
|
||||
EarthArmor.moveArmor(player);
|
||||
}
|
||||
|
|
|
@ -280,6 +280,14 @@ public class ConfigManager {
|
|||
+ "This ability will erect a circle of earth to trap the creature in.");
|
||||
config.addDefault("Abilities.Earth.EarthGrab.Range", 15);
|
||||
|
||||
config.addDefault("Abilities.Earth.EarthTunnel.Enabled", true);
|
||||
config.addDefault("Abilities.Earth.EarthTunnel.Description", "Earth Tunnel is a completely utility ability for earthbenders. To use, simply sneak (default: shift) in the direction you want to tunnel. You will slowly begin tunneling in the direction you're facing for as long as you sneak or if the tunnel has been dug long enough. This ability will be interrupted if it hits a block that cannot be earthbent.");
|
||||
config.addDefault("Abilities.Earth.EarthTunnel.MaxRadius", 1);
|
||||
config.addDefault("Abilities.Earth.EarthTunnel.Range", 10);
|
||||
config.addDefault("Abilities.Earth.EarthTunnel.Radius", 0.25);
|
||||
config.addDefault("Abilities.Earth.EarthTunnel.Revert", true);
|
||||
config.addDefault("Abilities.Earth.EarthTunnel.Interval", 30);
|
||||
|
||||
config.addDefault("Abilities.Earth.RaiseEarth.Enabled", true);
|
||||
config.addDefault("Abilities.Earth.RaiseEarth.Description", "To use, simply left-click on an earthbendable block. "
|
||||
+ "A column of earth will shoot upwards from that location. "
|
||||
|
|
|
@ -68,6 +68,7 @@ import com.projectkorra.ProjectKorra.earthbending.EarthBlast;
|
|||
import com.projectkorra.ProjectKorra.earthbending.EarthColumn;
|
||||
import com.projectkorra.ProjectKorra.earthbending.EarthGrab;
|
||||
import com.projectkorra.ProjectKorra.earthbending.EarthPassive;
|
||||
import com.projectkorra.ProjectKorra.earthbending.EarthTunnel;
|
||||
import com.projectkorra.ProjectKorra.earthbending.EarthWall;
|
||||
import com.projectkorra.ProjectKorra.earthbending.Shockwave;
|
||||
import com.projectkorra.ProjectKorra.firebending.Cook;
|
||||
|
@ -252,6 +253,9 @@ public class PKListener implements Listener {
|
|||
if (abil.equalsIgnoreCase("EarthGrab")) {
|
||||
EarthGrab.EarthGrabSelf(player);
|
||||
}
|
||||
if (abil.equalsIgnoreCase("EarthTunnel")) {
|
||||
new EarthTunnel(player);
|
||||
}
|
||||
}
|
||||
|
||||
if (Methods.isFireAbility(abil)) {
|
||||
|
|
124
src/com/projectkorra/ProjectKorra/earthbending/EarthTunnel.java
Normal file
124
src/com/projectkorra/ProjectKorra/earthbending/EarthTunnel.java
Normal file
|
@ -0,0 +1,124 @@
|
|||
package com.projectkorra.ProjectKorra.earthbending;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.projectkorra.ProjectKorra.Methods;
|
||||
import com.projectkorra.ProjectKorra.ProjectKorra;
|
||||
|
||||
public class EarthTunnel {
|
||||
|
||||
public static ConcurrentHashMap<Player, EarthTunnel> instances = new ConcurrentHashMap<Player, EarthTunnel>();
|
||||
|
||||
private static final double maxradius = ProjectKorra.plugin.getConfig().getDouble("Abilities.Earth.EarthTunnel.MaxRadius");
|
||||
private static final double range = ProjectKorra.plugin.getConfig().getDouble("Abilities.Earth.EarthTunnel.Range");
|
||||
private static final double radiusinc = ProjectKorra.plugin.getConfig().getDouble("Abilities.Earth.EarthTunnel.Radius");
|
||||
// private static final double speed = 10;
|
||||
|
||||
private static boolean revert = ProjectKorra.plugin.getConfig().getBoolean("Abilities.Earth.EarthTunnel.Revert");
|
||||
|
||||
private static final long interval = ProjectKorra.plugin.getConfig().getLong("Abilities.Earth.EarthTunnel.Interval");
|
||||
|
||||
private Player player;
|
||||
private Block block;
|
||||
private Location origin, location;
|
||||
private Vector direction;
|
||||
private double depth, radius, angle;
|
||||
private long time;
|
||||
|
||||
public EarthTunnel(Player player) {
|
||||
this.player = player;
|
||||
location = player.getEyeLocation().clone();
|
||||
origin = player.getTargetBlock(null, (int) range).getLocation();
|
||||
block = origin.getBlock();
|
||||
direction = location.getDirection().clone().normalize();
|
||||
depth = origin.distance(location) - 1;
|
||||
if (depth < 0)
|
||||
depth = 0;
|
||||
angle = 0;
|
||||
radius = radiusinc;
|
||||
// ortho = new Vector(direction.getY(), -direction.getX(),
|
||||
// 0).normalize();
|
||||
// Methods.verbose(ortho.clone().dot(direction));
|
||||
time = System.currentTimeMillis();
|
||||
|
||||
instances.put(player, this);
|
||||
}
|
||||
|
||||
public boolean progress() {
|
||||
if (player.isDead() || !player.isOnline()) {
|
||||
instances.remove(player);
|
||||
return false;
|
||||
}
|
||||
if (System.currentTimeMillis() - time >= interval) {
|
||||
time = System.currentTimeMillis();
|
||||
// Methods.verbose("progressing");
|
||||
if (Math.abs(Math.toDegrees(player.getEyeLocation().getDirection()
|
||||
.angle(direction))) > 20
|
||||
|| !player.isSneaking()) {
|
||||
instances.remove(player);
|
||||
return false;
|
||||
} else {
|
||||
while (!Methods.isEarthbendable(player, block)) {
|
||||
// Methods.verbose("going");
|
||||
if (!Methods.isTransparentToEarthbending(player, block)) {
|
||||
// Methods.verbose("false! at" + angle + " " + radius +
|
||||
// " "
|
||||
// + depth);
|
||||
instances.remove(player);
|
||||
return false;
|
||||
}
|
||||
if (angle >= 360) {
|
||||
angle = 0;
|
||||
if (radius >= maxradius) {
|
||||
radius = radiusinc;
|
||||
if (depth >= range) {
|
||||
instances.remove(player);
|
||||
return false;
|
||||
} else {
|
||||
depth += .5;
|
||||
}
|
||||
} else {
|
||||
radius += radiusinc;
|
||||
}
|
||||
} else {
|
||||
angle += 20;
|
||||
}
|
||||
// block.setType(Material.GLASS);
|
||||
Vector vec = Methods.getOrthogonalVector(direction, angle,
|
||||
radius);
|
||||
block = location.clone()
|
||||
.add(direction.clone().normalize().multiply(depth))
|
||||
.add(vec).getBlock();
|
||||
}
|
||||
|
||||
if (revert) {
|
||||
Methods.addTempAirBlock(block);
|
||||
} else {
|
||||
block.breakNaturally();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean progress(Player player) {
|
||||
return instances.get(player).progress();
|
||||
}
|
||||
|
||||
public static String getDescription() {
|
||||
return "Earth Tunnel is a completely utility ability for earthbenders. "
|
||||
+ "To use, simply sneak (default: shift) in the direction you want to tunnel. "
|
||||
+ "You will slowly begin tunneling in the direction you're facing for as long as you "
|
||||
+ "sneak or if the tunnel has been dug long enough. This ability will be interupted "
|
||||
+ "if it hits a block that cannot be earthbent.";
|
||||
}
|
||||
|
||||
}
|
|
@ -189,6 +189,14 @@ Abilities:
|
|||
Enabled: true
|
||||
Description: "To use, simply left-click while targeting a creature within range. This ability will erect a circle of earth to trap the creature in."
|
||||
Range: 15
|
||||
EarthTunnel:
|
||||
Enabled: true
|
||||
Description: "Earth Tunnel is a completely utility ability for earthbenders. To use, simply sneak (default: shift) in the direction you want to tunnel. You will slowly begin tunneling in the direction you're facing for as long as you sneak or if the tunnel has been dug long enough. This ability will be interrupted if it hits a block that cannot be earthbent."
|
||||
MaxRadius: 1
|
||||
Range: 10
|
||||
Radius: 0.25
|
||||
Revert: true
|
||||
Interval: 30
|
||||
RaiseEarth:
|
||||
Enabled: true
|
||||
Description: "To use, simply left-click on an earthbendable block. A column of earth will shoot upwards from that location. Anything in the way of the column will be brought up with it, leaving talented benders the ability to trap brainless entities up there. Additionally, simply sneak (default shift) looking at an earthbendable block. A wall of earth will shoot upwards from that location. Anything in the way of the wall will be brought up with it."
|
||||
|
|
Loading…
Reference in a new issue