mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2025-02-11 03:30:10 +00:00
Surge
This commit is contained in:
parent
d941a74564
commit
043be110ca
6 changed files with 1142 additions and 15 deletions
|
@ -36,6 +36,8 @@ import com.projectkorra.ProjectKorra.waterbending.Plantbending;
|
||||||
import com.projectkorra.ProjectKorra.waterbending.WaterManipulation;
|
import com.projectkorra.ProjectKorra.waterbending.WaterManipulation;
|
||||||
import com.projectkorra.ProjectKorra.waterbending.WaterPassive;
|
import com.projectkorra.ProjectKorra.waterbending.WaterPassive;
|
||||||
import com.projectkorra.ProjectKorra.waterbending.WaterSpout;
|
import com.projectkorra.ProjectKorra.waterbending.WaterSpout;
|
||||||
|
import com.projectkorra.ProjectKorra.waterbending.WaterWall;
|
||||||
|
import com.projectkorra.ProjectKorra.waterbending.Wave;
|
||||||
|
|
||||||
public class BendingManager implements Runnable {
|
public class BendingManager implements Runnable {
|
||||||
|
|
||||||
|
@ -43,7 +45,7 @@ public class BendingManager implements Runnable {
|
||||||
|
|
||||||
long time;
|
long time;
|
||||||
long interval;
|
long interval;
|
||||||
|
|
||||||
ArrayList<World> worlds = new ArrayList<World>();
|
ArrayList<World> worlds = new ArrayList<World>();
|
||||||
ConcurrentHashMap<World, Boolean> nights = new ConcurrentHashMap<World, Boolean>();
|
ConcurrentHashMap<World, Boolean> nights = new ConcurrentHashMap<World, Boolean>();
|
||||||
ConcurrentHashMap<World, Boolean> days = new ConcurrentHashMap<World, Boolean>();
|
ConcurrentHashMap<World, Boolean> days = new ConcurrentHashMap<World, Boolean>();
|
||||||
|
@ -63,7 +65,7 @@ public class BendingManager implements Runnable {
|
||||||
interval = System.currentTimeMillis() - time;
|
interval = System.currentTimeMillis() - time;
|
||||||
time = System.currentTimeMillis();
|
time = System.currentTimeMillis();
|
||||||
ProjectKorra.time_step = interval;
|
ProjectKorra.time_step = interval;
|
||||||
|
|
||||||
AvatarState.manageAvatarStates();
|
AvatarState.manageAvatarStates();
|
||||||
AirBlast.progressAll();
|
AirBlast.progressAll();
|
||||||
AirPassive.handlePassive(Bukkit.getServer());
|
AirPassive.handlePassive(Bukkit.getServer());
|
||||||
|
@ -88,40 +90,48 @@ public class BendingManager implements Runnable {
|
||||||
for (int ID: Tornado.instances.keySet()) {
|
for (int ID: Tornado.instances.keySet()) {
|
||||||
Tornado.progress(ID);
|
Tornado.progress(ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int id: FireStream.instances.keySet()) {
|
for (int id: FireStream.instances.keySet()) {
|
||||||
FireStream.progress(id);
|
FireStream.progress(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Block block: FireStream.ignitedblocks.keySet()) {
|
for (Block block: FireStream.ignitedblocks.keySet()) {
|
||||||
if (block.getType() != Material.FIRE) {
|
if (block.getType() != Material.FIRE) {
|
||||||
FireStream.ignitedblocks.remove(block);
|
FireStream.ignitedblocks.remove(block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int ID: Catapult.instances.keySet()) {
|
for (int ID: Catapult.instances.keySet()) {
|
||||||
Catapult.progress(ID);
|
Catapult.progress(ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int ID: EarthColumn.instances.keySet()) {
|
for (int ID: EarthColumn.instances.keySet()) {
|
||||||
EarthColumn.progress(ID);
|
EarthColumn.progress(ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int ID: CompactColumn.instances.keySet()) {
|
for (int ID: CompactColumn.instances.keySet()) {
|
||||||
CompactColumn.progress(ID);
|
CompactColumn.progress(ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int ID: WaterManipulation.instances.keySet()) {
|
for (int ID: WaterManipulation.instances.keySet()) {
|
||||||
WaterManipulation.progress(ID);
|
WaterManipulation.progress(ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int ID: WaterWall.instances.keySet()) {
|
||||||
|
WaterWall.progress(ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int ID : Wave.instances.keySet()) {
|
||||||
|
Wave.progress(ID);
|
||||||
|
}
|
||||||
|
|
||||||
FireStream.dissipateAll();
|
FireStream.dissipateAll();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Methods.stopBending();
|
Methods.stopBending();
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleDayNight() {
|
public void handleDayNight() {
|
||||||
for (World world: plugin.getServer().getWorlds()) {
|
for (World world: plugin.getServer().getWorlds()) {
|
||||||
if (world.getWorldType() == WorldType.NORMAL && !worlds.contains(world)) {
|
if (world.getWorldType() == WorldType.NORMAL && !worlds.contains(world)) {
|
||||||
|
@ -146,7 +156,7 @@ public class BendingManager implements Runnable {
|
||||||
}
|
}
|
||||||
days.replace(world, true);
|
days.replace(world, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Methods.isDay(world) && day) {
|
if (!Methods.isDay(world) && day) {
|
||||||
for (Player player: world.getPlayers()) {
|
for (Player player: world.getPlayers()) {
|
||||||
if (Methods.isBender(player.getName(), Element.Fire) && player.hasPermission("bending.message.daymessage")) {
|
if (Methods.isBender(player.getName(), Element.Fire) && player.hasPermission("bending.message.daymessage")) {
|
||||||
|
@ -155,7 +165,7 @@ public class BendingManager implements Runnable {
|
||||||
}
|
}
|
||||||
days.replace(world, false);
|
days.replace(world, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Methods.isNight(world) && !night) {
|
if (Methods.isNight(world) && !night) {
|
||||||
for (Player player: world.getPlayers()) {
|
for (Player player: world.getPlayers()) {
|
||||||
if (Methods.isBender(player.getName(), Element.Water) && player.hasPermission("bending.message.nightmessage")) {
|
if (Methods.isBender(player.getName(), Element.Water) && player.hasPermission("bending.message.nightmessage")) {
|
||||||
|
@ -164,7 +174,7 @@ public class BendingManager implements Runnable {
|
||||||
}
|
}
|
||||||
nights.replace(world, true);
|
nights.replace(world, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Methods.isNight(world) && night) {
|
if (!Methods.isNight(world) && night) {
|
||||||
for (Player player: world.getPlayers()) {
|
for (Player player: world.getPlayers()) {
|
||||||
if (Methods.isBender(player.getName(), Element.Water) && player.hasPermission("bending.message.nightmessage")) {
|
if (Methods.isBender(player.getName(), Element.Water) && player.hasPermission("bending.message.nightmessage")) {
|
||||||
|
@ -174,10 +184,10 @@ public class BendingManager implements Runnable {
|
||||||
nights.replace(world, false);
|
nights.replace(world, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (World world: removeworlds) {
|
for (World world: removeworlds) {
|
||||||
worlds.remove(world);
|
worlds.remove(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,6 +150,14 @@ public class ConfigManager {
|
||||||
config.addDefault("Abilities.Water.PhaseChange.Range", 20);
|
config.addDefault("Abilities.Water.PhaseChange.Range", 20);
|
||||||
config.addDefault("Abilities.Water.PhaseChange.Radius", 5);
|
config.addDefault("Abilities.Water.PhaseChange.Radius", 5);
|
||||||
|
|
||||||
|
config.addDefault("Abilities.Water.Surge.Enabled", true);
|
||||||
|
config.addDefault("Abilities.Water.Surge.Description", "This ability has two distinct features. If you sneak to select a source block, you can then click in a direction and a large wave will be launched in that direction. If you sneak again while the wave is en route, the wave will freeze the next target it hits. If, instead, you click to select a source block, you can hold sneak to form a wall of water at your cursor location. Click to shift between a water wall and an ice wall. Release sneak to dissipate it.");
|
||||||
|
config.addDefault("Abilities.Water.Surge.Wave.Radius", 3);
|
||||||
|
config.addDefault("Abilities.Water.Surge.Wave.HorizontalPush", 1);
|
||||||
|
config.addDefault("Abilities.Water.Surge.VerticalPush", 0.2);
|
||||||
|
config.addDefault("Abilities.Water.Surge.Wall.Range", 5);
|
||||||
|
config.addDefault("Abilities.Water.Surge.Wall.Radius", 2);
|
||||||
|
|
||||||
plugin.getConfig().addDefault("Abilities.Water.Plantbending.RegrowTime", 180000);
|
plugin.getConfig().addDefault("Abilities.Water.Plantbending.RegrowTime", 180000);
|
||||||
|
|
||||||
config.addDefault("Abilities.Water.WaterBubble.Enabled", true);
|
config.addDefault("Abilities.Water.WaterBubble.Enabled", true);
|
||||||
|
|
|
@ -70,6 +70,8 @@ import com.projectkorra.ProjectKorra.waterbending.OctopusForm;
|
||||||
import com.projectkorra.ProjectKorra.waterbending.WaterManipulation;
|
import com.projectkorra.ProjectKorra.waterbending.WaterManipulation;
|
||||||
import com.projectkorra.ProjectKorra.waterbending.WaterPassive;
|
import com.projectkorra.ProjectKorra.waterbending.WaterPassive;
|
||||||
import com.projectkorra.ProjectKorra.waterbending.WaterSpout;
|
import com.projectkorra.ProjectKorra.waterbending.WaterSpout;
|
||||||
|
import com.projectkorra.ProjectKorra.waterbending.WaterWall;
|
||||||
|
import com.projectkorra.ProjectKorra.waterbending.Wave;
|
||||||
|
|
||||||
public class PKListener implements Listener {
|
public class PKListener implements Listener {
|
||||||
|
|
||||||
|
@ -187,6 +189,9 @@ public class PKListener implements Listener {
|
||||||
if (abil.equalsIgnoreCase("WaterManipulation")) {
|
if (abil.equalsIgnoreCase("WaterManipulation")) {
|
||||||
new WaterManipulation(player);
|
new WaterManipulation(player);
|
||||||
}
|
}
|
||||||
|
if (abil.equalsIgnoreCase("Surge")) {
|
||||||
|
WaterWall.form(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Methods.isEarthAbility(abil)) {
|
if (Methods.isEarthAbility(abil)) {
|
||||||
|
@ -368,6 +373,9 @@ public class PKListener implements Listener {
|
||||||
if (abil.equalsIgnoreCase("WaterManipulation")) {
|
if (abil.equalsIgnoreCase("WaterManipulation")) {
|
||||||
WaterManipulation.moveWater(player);
|
WaterManipulation.moveWater(player);
|
||||||
}
|
}
|
||||||
|
if (abil.equalsIgnoreCase("Surge")) {
|
||||||
|
new WaterWall(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Methods.isEarthAbility(abil)) {
|
if (Methods.isEarthAbility(abil)) {
|
||||||
|
|
570
src/com/projectkorra/ProjectKorra/waterbending/WaterWall.java
Normal file
570
src/com/projectkorra/ProjectKorra/waterbending/WaterWall.java
Normal file
|
@ -0,0 +1,570 @@
|
||||||
|
package com.projectkorra.ProjectKorra.waterbending;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
import org.bukkit.Effect;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
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;
|
||||||
|
import com.projectkorra.ProjectKorra.TempBlock;
|
||||||
|
import com.projectkorra.ProjectKorra.Ability.AvatarState;
|
||||||
|
|
||||||
|
public class WaterWall {
|
||||||
|
|
||||||
|
public static ConcurrentHashMap<Integer, WaterWall> instances = new ConcurrentHashMap<Integer, WaterWall>();
|
||||||
|
|
||||||
|
private static final long interval = 30;
|
||||||
|
|
||||||
|
public static ConcurrentHashMap<Block, Block> affectedblocks = new ConcurrentHashMap<Block, Block>();
|
||||||
|
public static ConcurrentHashMap<Block, Player> wallblocks = new ConcurrentHashMap<Block, Player>();
|
||||||
|
|
||||||
|
private static final byte full = 0x0;
|
||||||
|
// private static final byte half = 0x4;
|
||||||
|
|
||||||
|
private static double range = ProjectKorra.plugin.getConfig().getDouble("Abilities.Water.Surge.Wall.Range");
|
||||||
|
private static final double defaultradius = ProjectKorra.plugin.getConfig().getDouble("Abilities.Water.Surge.Wall.Radius");
|
||||||
|
// private static double speed = 1.5;
|
||||||
|
|
||||||
|
Player player;
|
||||||
|
private Location location = null;
|
||||||
|
private Block sourceblock = null;
|
||||||
|
// private Block oldwater = null;
|
||||||
|
private boolean progressing = false;
|
||||||
|
private Location firstdestination = null;
|
||||||
|
private Location targetdestination = null;
|
||||||
|
private Vector firstdirection = null;
|
||||||
|
private Vector targetdirection = null;
|
||||||
|
// private boolean falling = false;
|
||||||
|
private boolean settingup = false;
|
||||||
|
private boolean forming = false;
|
||||||
|
private boolean frozen = false;
|
||||||
|
private long time;
|
||||||
|
private double radius = defaultradius;
|
||||||
|
|
||||||
|
public WaterWall(Player player) {
|
||||||
|
this.player = player;
|
||||||
|
|
||||||
|
if (Wave.instances.containsKey(player.getEntityId())) {
|
||||||
|
Wave wave = Wave.instances.get(player.getEntityId());
|
||||||
|
if (!wave.progressing) {
|
||||||
|
Wave.launch(player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (AvatarState.isAvatarState(player)) {
|
||||||
|
radius = AvatarState.getValue(radius);
|
||||||
|
}
|
||||||
|
if (instances.containsKey(player.getEntityId())) {
|
||||||
|
if (instances.get(player.getEntityId()).progressing) {
|
||||||
|
freezeThaw(player);
|
||||||
|
} else if (prepare()) {
|
||||||
|
if (instances.containsKey(player.getEntityId())) {
|
||||||
|
instances.get(player.getEntityId()).cancel();
|
||||||
|
}
|
||||||
|
// Methods.verbose("New water wall prepared");
|
||||||
|
instances.put(player.getEntityId(), this);
|
||||||
|
time = System.currentTimeMillis();
|
||||||
|
|
||||||
|
}
|
||||||
|
} else if (prepare()) {
|
||||||
|
if (instances.containsKey(player.getEntityId())) {
|
||||||
|
instances.get(player.getEntityId()).cancel();
|
||||||
|
}
|
||||||
|
// Methods.verbose("New water wall prepared");
|
||||||
|
instances.put(player.getEntityId(), this);
|
||||||
|
time = System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Wave.cooldowns.containsKey(player.getName())) {
|
||||||
|
if (Wave.cooldowns.get(player.getName()) + ProjectKorra.plugin.getConfig().getLong("Properties.GlobalCooldown") >= System.currentTimeMillis()) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
Wave.cooldowns.remove(player.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!instances.containsKey(player.getEntityId())
|
||||||
|
&& WaterReturn.hasWaterBottle(player)) {
|
||||||
|
|
||||||
|
Location eyeloc = player.getEyeLocation();
|
||||||
|
Block block = eyeloc.add(eyeloc.getDirection().normalize())
|
||||||
|
.getBlock();
|
||||||
|
if (Methods.isTransparentToEarthbending(player, block)
|
||||||
|
&& Methods.isTransparentToEarthbending(player,
|
||||||
|
eyeloc.getBlock())) {
|
||||||
|
block.setType(Material.WATER);
|
||||||
|
block.setData(full);
|
||||||
|
Wave wave = new Wave(player);
|
||||||
|
wave.canhitself = false;
|
||||||
|
wave.moveWater();
|
||||||
|
if (!wave.progressing) {
|
||||||
|
block.setType(Material.AIR);
|
||||||
|
wave.cancel();
|
||||||
|
} else {
|
||||||
|
WaterReturn.emptyWaterBottle(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void freezeThaw(Player player) {
|
||||||
|
instances.get(player.getEntityId()).freezeThaw();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void freezeThaw() {
|
||||||
|
if (frozen) {
|
||||||
|
thaw();
|
||||||
|
} else {
|
||||||
|
freeze();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void freeze() {
|
||||||
|
frozen = true;
|
||||||
|
for (Block block : wallblocks.keySet()) {
|
||||||
|
if (wallblocks.get(block) == player) {
|
||||||
|
new TempBlock(block, Material.ICE, (byte) 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void thaw() {
|
||||||
|
frozen = false;
|
||||||
|
for (Block block : wallblocks.keySet()) {
|
||||||
|
if (wallblocks.get(block) == player) {
|
||||||
|
new TempBlock(block, Material.WATER, full);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean prepare() {
|
||||||
|
cancelPrevious();
|
||||||
|
// Block block = player.getTargetBlock(null, (int) range);
|
||||||
|
Block block = Methods.getWaterSourceBlock(player, range,
|
||||||
|
Methods.canPlantbend(player));
|
||||||
|
if (block != null) {
|
||||||
|
sourceblock = block;
|
||||||
|
focusBlock();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cancelPrevious() {
|
||||||
|
if (instances.containsKey(player.getEntityId())) {
|
||||||
|
WaterWall old = instances.get(player.getEntityId());
|
||||||
|
if (old.progressing) {
|
||||||
|
old.removeWater(old.sourceblock);
|
||||||
|
} else {
|
||||||
|
old.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cancel() {
|
||||||
|
unfocusBlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void focusBlock() {
|
||||||
|
location = sourceblock.getLocation();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void unfocusBlock() {
|
||||||
|
instances.remove(player.getEntityId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void moveWater() {
|
||||||
|
if (sourceblock != null) {
|
||||||
|
targetdestination = player.getTargetBlock(
|
||||||
|
Methods.getTransparentEarthbending(), (int) range)
|
||||||
|
.getLocation();
|
||||||
|
|
||||||
|
if (targetdestination.distance(location) <= 1) {
|
||||||
|
progressing = false;
|
||||||
|
targetdestination = null;
|
||||||
|
} else {
|
||||||
|
progressing = true;
|
||||||
|
settingup = true;
|
||||||
|
firstdestination = getToEyeLevel();
|
||||||
|
firstdirection = getDirection(sourceblock.getLocation(),
|
||||||
|
firstdestination);
|
||||||
|
targetdirection = getDirection(firstdestination,
|
||||||
|
targetdestination);
|
||||||
|
if (Methods.isPlant(sourceblock))
|
||||||
|
new Plantbending(sourceblock);
|
||||||
|
if (!Methods.isAdjacentToThreeOrMoreSources(sourceblock)) {
|
||||||
|
sourceblock.setType(Material.AIR);
|
||||||
|
}
|
||||||
|
addWater(sourceblock);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Location getToEyeLevel() {
|
||||||
|
Location loc = sourceblock.getLocation().clone();
|
||||||
|
loc.setY(targetdestination.getY());
|
||||||
|
return loc;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Vector getDirection(Location location, Location destination) {
|
||||||
|
double x1, y1, z1;
|
||||||
|
double x0, y0, z0;
|
||||||
|
|
||||||
|
x1 = destination.getX();
|
||||||
|
y1 = destination.getY();
|
||||||
|
z1 = destination.getZ();
|
||||||
|
|
||||||
|
x0 = location.getX();
|
||||||
|
y0 = location.getY();
|
||||||
|
z0 = location.getZ();
|
||||||
|
|
||||||
|
return new Vector(x1 - x0, y1 - y0, z1 - z0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean progress() {
|
||||||
|
if (player.isDead() || !player.isOnline()) {
|
||||||
|
breakBlock();
|
||||||
|
// instances.remove(player.getEntityId());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!Methods.canBend(player.getName(), "Surge")) {
|
||||||
|
if (!forming)
|
||||||
|
// removeWater(oldwater);
|
||||||
|
breakBlock();
|
||||||
|
unfocusBlock();
|
||||||
|
returnWater();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (System.currentTimeMillis() - time >= interval) {
|
||||||
|
time = System.currentTimeMillis();
|
||||||
|
|
||||||
|
if (!forming) {
|
||||||
|
// removeWater(oldwater);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Methods.getBoundAbility(player) == null) {
|
||||||
|
unfocusBlock();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!progressing
|
||||||
|
&& !Methods.getBoundAbility(player).equalsIgnoreCase("Surge")) {
|
||||||
|
unfocusBlock();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (progressing
|
||||||
|
&& (!player.isSneaking() || !Methods.getBoundAbility(player).equalsIgnoreCase("Surge"))) {
|
||||||
|
breakBlock();
|
||||||
|
returnWater();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!progressing) {
|
||||||
|
sourceblock.getWorld().playEffect(location, Effect.SMOKE, 4,
|
||||||
|
(int) range);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (forming) {
|
||||||
|
ArrayList<Block> blocks = new ArrayList<Block>();
|
||||||
|
Location loc = Methods.getTargetedLocation(player, (int) range,
|
||||||
|
8, 9, 79);
|
||||||
|
location = loc.clone();
|
||||||
|
Vector dir = player.getEyeLocation().getDirection();
|
||||||
|
Vector vec;
|
||||||
|
Block block;
|
||||||
|
for (double i = 0; i <= Methods.waterbendingNightAugment(radius,
|
||||||
|
player.getWorld()); i += 0.5) {
|
||||||
|
for (double angle = 0; angle < 360; angle += 10) {
|
||||||
|
// loc.getBlock().setType(Material.GLOWSTONE);
|
||||||
|
vec = Methods.getOrthogonalVector(dir.clone(), angle, i);
|
||||||
|
block = loc.clone().add(vec).getBlock();
|
||||||
|
// if (Methods.isRegionProtectedFromBuild(player,
|
||||||
|
// Abilities.Surge, block.getLocation()))
|
||||||
|
// continue;
|
||||||
|
if (wallblocks.containsKey(block)) {
|
||||||
|
blocks.add(block);
|
||||||
|
} else if (!blocks.contains(block)
|
||||||
|
&& (block.getType() == Material.AIR
|
||||||
|
|| block.getType() == Material.FIRE || Methods
|
||||||
|
.isWaterbendable(block, player))) {
|
||||||
|
wallblocks.put(block, player);
|
||||||
|
addWallBlock(block);
|
||||||
|
// if (frozen) {
|
||||||
|
// block.setType(Material.ICE);
|
||||||
|
// } else {
|
||||||
|
// block.setType(Material.WATER);
|
||||||
|
// block.setData(full);
|
||||||
|
// }
|
||||||
|
// block.setType(Material.GLASS);
|
||||||
|
blocks.add(block);
|
||||||
|
FireBlast.removeFireBlastsAroundPoint(
|
||||||
|
block.getLocation(), 2);
|
||||||
|
// Methods.verbose(wallblocks.size());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Block blocki : wallblocks.keySet()) {
|
||||||
|
if (wallblocks.get(blocki) == player
|
||||||
|
&& !blocks.contains(blocki)) {
|
||||||
|
finalRemoveWater(blocki);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sourceblock.getLocation().distance(firstdestination) < .5
|
||||||
|
&& settingup) {
|
||||||
|
settingup = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector direction;
|
||||||
|
if (settingup) {
|
||||||
|
direction = firstdirection;
|
||||||
|
} else {
|
||||||
|
direction = targetdirection;
|
||||||
|
}
|
||||||
|
|
||||||
|
location = location.clone().add(direction);
|
||||||
|
|
||||||
|
Block block = location.getBlock();
|
||||||
|
if (block.getLocation().equals(sourceblock.getLocation())) {
|
||||||
|
location = location.clone().add(direction);
|
||||||
|
block = location.getBlock();
|
||||||
|
}
|
||||||
|
if (block.getType() != Material.AIR) {
|
||||||
|
breakBlock();
|
||||||
|
returnWater();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!progressing) {
|
||||||
|
breakBlock();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
addWater(block);
|
||||||
|
removeWater(sourceblock);
|
||||||
|
sourceblock = block;
|
||||||
|
|
||||||
|
if (location.distance(targetdestination) < 1) {
|
||||||
|
|
||||||
|
removeWater(sourceblock);
|
||||||
|
// removeWater(oldwater);
|
||||||
|
forming = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addWallBlock(Block block) {
|
||||||
|
if (frozen) {
|
||||||
|
new TempBlock(block, Material.ICE, (byte) 0);
|
||||||
|
} else {
|
||||||
|
new TempBlock(block, Material.WATER, full);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void breakBlock() {
|
||||||
|
finalRemoveWater(sourceblock);
|
||||||
|
for (Block block : wallblocks.keySet()) {
|
||||||
|
if (wallblocks.get(block) == player) {
|
||||||
|
finalRemoveWater(block);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
instances.remove(player.getEntityId());
|
||||||
|
}
|
||||||
|
|
||||||
|
// private void reduceWater(Block block) {
|
||||||
|
// if (affectedblocks.containsKey(block)) {
|
||||||
|
// if (!Methods.adjacentToThreeOrMoreSources(block)) {
|
||||||
|
// block.setType(Material.WATER);
|
||||||
|
// block.setData(half);
|
||||||
|
// }
|
||||||
|
// oldwater = block;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
private void removeWater(Block block) {
|
||||||
|
if (block != null) {
|
||||||
|
if (affectedblocks.containsKey(block)) {
|
||||||
|
if (!Methods.isAdjacentToThreeOrMoreSources(block)) {
|
||||||
|
TempBlock.revertBlock(block, Material.AIR);
|
||||||
|
}
|
||||||
|
affectedblocks.remove(block);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void finalRemoveWater(Block block) {
|
||||||
|
if (affectedblocks.containsKey(block)) {
|
||||||
|
// block.setType(Material.WATER);
|
||||||
|
// block.setData(half);
|
||||||
|
// if (!Methods.adjacentToThreeOrMoreSources(block)) {
|
||||||
|
// block.setType(Material.AIR);
|
||||||
|
// }
|
||||||
|
TempBlock.revertBlock(block, Material.AIR);
|
||||||
|
affectedblocks.remove(block);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wallblocks.containsKey(block)) {
|
||||||
|
// if (block.getType() == Material.ICE
|
||||||
|
// || block.getType() == Material.WATER
|
||||||
|
// || block.getType() == Material.STATIONARY_WATER) {
|
||||||
|
// block.setType(Material.AIR);
|
||||||
|
// }
|
||||||
|
TempBlock.revertBlock(block, Material.AIR);
|
||||||
|
wallblocks.remove(block);
|
||||||
|
// block.setType(Material.WATER);
|
||||||
|
// block.setData(half);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addWater(Block block) {
|
||||||
|
|
||||||
|
// if (Methods.isRegionProtectedFromBuild(player, Abilities.Surge,
|
||||||
|
// block.getLocation()))
|
||||||
|
// return;
|
||||||
|
|
||||||
|
if (!TempBlock.isTempBlock(block)) {
|
||||||
|
new TempBlock(block, Material.WATER, full);
|
||||||
|
// new TempBlock(block, Material.ICE, (byte) 0);
|
||||||
|
affectedblocks.put(block, block);
|
||||||
|
}
|
||||||
|
|
||||||
|
// if (!affectedblocks.containsKey(block)) {
|
||||||
|
// affectedblocks.put(block, block);
|
||||||
|
// }
|
||||||
|
// if (FreezeMelt.frozenblocks.containsKey(block))
|
||||||
|
// FreezeMelt.frozenblocks.remove(block);
|
||||||
|
// block.setType(Material.WATER);
|
||||||
|
// block.setData(full);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void moveWater(Player player) {
|
||||||
|
if (instances.containsKey(player.getEntityId())) {
|
||||||
|
instances.get(player.getEntityId()).moveWater();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean progress(int ID) {
|
||||||
|
return instances.get(ID).progress();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void form(Player player) {
|
||||||
|
|
||||||
|
if (!instances.containsKey(player.getEntityId())) {
|
||||||
|
if (!Wave.instances.containsKey(player.getEntityId())
|
||||||
|
&& Methods.getWaterSourceBlock(player,
|
||||||
|
(int) Wave.defaultrange, Methods.canPlantbend(player)) == null
|
||||||
|
&& WaterReturn.hasWaterBottle(player)) {
|
||||||
|
|
||||||
|
if (Wave.cooldowns.containsKey(player.getName())) {
|
||||||
|
if (Wave.cooldowns.get(player.getName()) + ProjectKorra.plugin.getConfig().getLong("Properties.GlobalCooldown") >= System.currentTimeMillis()) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
Wave.cooldowns.remove(player.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Location eyeloc = player.getEyeLocation();
|
||||||
|
Block block = eyeloc.add(eyeloc.getDirection().normalize())
|
||||||
|
.getBlock();
|
||||||
|
if (Methods.isTransparentToEarthbending(player, block)
|
||||||
|
&& Methods.isTransparentToEarthbending(player,
|
||||||
|
eyeloc.getBlock())) {
|
||||||
|
block.setType(Material.WATER);
|
||||||
|
block.setData(full);
|
||||||
|
WaterWall wall = new WaterWall(player);
|
||||||
|
wall.moveWater();
|
||||||
|
if (!wall.progressing) {
|
||||||
|
block.setType(Material.AIR);
|
||||||
|
wall.cancel();
|
||||||
|
} else {
|
||||||
|
WaterReturn.emptyWaterBottle(player);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
new Wave(player);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
if (Methods.isWaterbendable(
|
||||||
|
player.getTargetBlock(null, (int) Wave.defaultrange),
|
||||||
|
player)) {
|
||||||
|
new Wave(player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
moveWater(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void removeAll() {
|
||||||
|
for (Block block : affectedblocks.keySet()) {
|
||||||
|
TempBlock.revertBlock(block, Material.AIR);
|
||||||
|
affectedblocks.remove(block);
|
||||||
|
wallblocks.remove(block);
|
||||||
|
}
|
||||||
|
for (Block block : wallblocks.keySet()) {
|
||||||
|
TempBlock.revertBlock(block, Material.AIR);
|
||||||
|
affectedblocks.remove(block);
|
||||||
|
wallblocks.remove(block);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean canThaw(Block block) {
|
||||||
|
if (wallblocks.keySet().contains(block))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void thaw(Block block) {
|
||||||
|
finalRemoveWater(block);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean wasBrokenFor(Player player, Block block) {
|
||||||
|
if (instances.containsKey(player.getEntityId())) {
|
||||||
|
WaterWall wall = instances.get(player.getEntityId());
|
||||||
|
if (wall.sourceblock == null)
|
||||||
|
return false;
|
||||||
|
if (wall.sourceblock.equals(block))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void returnWater() {
|
||||||
|
if (location != null) {
|
||||||
|
new WaterReturn(player, location.getBlock());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getDescription() {
|
||||||
|
return "This ability has two distinct features. If you sneak to select a source block, "
|
||||||
|
+ "you can then click in a direction and a large wave will be launched in that direction. "
|
||||||
|
+ "If you sneak again while the wave is en route, the wave will freeze the next target it hits. "
|
||||||
|
+ "If, instead, you click to select a source block, you can hold sneak to form a wall of water at "
|
||||||
|
+ "your cursor location. Click to shift between a water wall and an ice wall. "
|
||||||
|
+ "Release sneak to dissipate it.";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
521
src/com/projectkorra/ProjectKorra/waterbending/Wave.java
Normal file
521
src/com/projectkorra/ProjectKorra/waterbending/Wave.java
Normal file
|
@ -0,0 +1,521 @@
|
||||||
|
package com.projectkorra.ProjectKorra.waterbending;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
import org.bukkit.Effect;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import com.projectkorra.ProjectKorra.Methods;
|
||||||
|
import com.projectkorra.ProjectKorra.ProjectKorra;
|
||||||
|
import com.projectkorra.ProjectKorra.TempBlock;
|
||||||
|
import com.projectkorra.ProjectKorra.Ability.AvatarState;
|
||||||
|
|
||||||
|
public class Wave {
|
||||||
|
|
||||||
|
public static ConcurrentHashMap<Integer, Wave> instances = new ConcurrentHashMap<Integer, Wave>();
|
||||||
|
|
||||||
|
private static final long interval = 30;
|
||||||
|
|
||||||
|
// public static ConcurrentHashMap<Block, Block> affectedblocks = new
|
||||||
|
// ConcurrentHashMap<Block, Block>();
|
||||||
|
|
||||||
|
private static final byte full = 0x0;
|
||||||
|
// private static final byte half = 0x4;
|
||||||
|
private static final double defaultmaxradius = ProjectKorra.plugin.getConfig().getDouble("Abilities.Water.Surge.Wave.Radius");
|
||||||
|
private static final double defaultfactor = ProjectKorra.plugin.getConfig().getDouble("Abilities.Water.Surge.Wave.HorizontalPush");
|
||||||
|
private static final double upfactor = ProjectKorra.plugin.getConfig().getDouble("Abilities.Water.Surge.Wave.VerticalPush");
|
||||||
|
private static final double maxfreezeradius = 7;
|
||||||
|
|
||||||
|
public static ConcurrentHashMap<String, Long> cooldowns = new ConcurrentHashMap<String, Long>();
|
||||||
|
|
||||||
|
static double defaultrange = 20;
|
||||||
|
// private static int damage = 5;
|
||||||
|
// private static double speed = 1.5;
|
||||||
|
|
||||||
|
Player player;
|
||||||
|
private Location location = null;
|
||||||
|
private Block sourceblock = null;
|
||||||
|
boolean progressing = false;
|
||||||
|
private Location targetdestination = null;
|
||||||
|
private Vector targetdirection = null;
|
||||||
|
private ConcurrentHashMap<Block, Block> wave = new ConcurrentHashMap<Block, Block>();
|
||||||
|
private ConcurrentHashMap<Block, Block> frozenblocks = new ConcurrentHashMap<Block, Block>();
|
||||||
|
private double radius = 1;
|
||||||
|
private long time;
|
||||||
|
private double maxradius = defaultmaxradius;
|
||||||
|
private boolean freeze = false;
|
||||||
|
private boolean activatefreeze = false;
|
||||||
|
private Location frozenlocation;
|
||||||
|
double range = defaultrange;
|
||||||
|
private double factor = defaultfactor;
|
||||||
|
boolean canhitself = true;
|
||||||
|
|
||||||
|
public Wave(Player player) {
|
||||||
|
this.player = player;
|
||||||
|
|
||||||
|
if (instances.containsKey(player.getEntityId())) {
|
||||||
|
if (instances.get(player.getEntityId()).progressing
|
||||||
|
&& !instances.get(player.getEntityId()).freeze) {
|
||||||
|
instances.get(player.getEntityId()).freeze = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (AvatarState.isAvatarState(player)) {
|
||||||
|
maxradius = AvatarState.getValue(maxradius);
|
||||||
|
}
|
||||||
|
maxradius = Methods
|
||||||
|
.waterbendingNightAugment(maxradius, player.getWorld());
|
||||||
|
if (prepare()) {
|
||||||
|
if (instances.containsKey(player.getEntityId())) {
|
||||||
|
instances.get(player.getEntityId()).cancel();
|
||||||
|
}
|
||||||
|
instances.put(player.getEntityId(), this);
|
||||||
|
time = System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean prepare() {
|
||||||
|
cancelPrevious();
|
||||||
|
// Block block = player.getTargetBlock(null, (int) range);
|
||||||
|
Block block = Methods.getWaterSourceBlock(player, range,
|
||||||
|
Methods.canPlantbend(player));
|
||||||
|
if (block != null) {
|
||||||
|
sourceblock = block;
|
||||||
|
focusBlock();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cancelPrevious() {
|
||||||
|
if (instances.containsKey(player.getEntityId())) {
|
||||||
|
Wave old = instances.get(player.getEntityId());
|
||||||
|
if (old.progressing) {
|
||||||
|
old.breakBlock();
|
||||||
|
old.thaw();
|
||||||
|
old.returnWater();
|
||||||
|
} else {
|
||||||
|
old.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cancel() {
|
||||||
|
unfocusBlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void focusBlock() {
|
||||||
|
location = sourceblock.getLocation();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void unfocusBlock() {
|
||||||
|
instances.remove(player.getEntityId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void moveWater() {
|
||||||
|
if (cooldowns.containsKey(player.getName())) {
|
||||||
|
if (cooldowns.get(player.getName()) + ProjectKorra.plugin.getConfig().getLong("Properties.GlobalCooldown") >= System.currentTimeMillis()) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
cooldowns.remove(player.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cooldowns.put(player.getName(), System.currentTimeMillis());
|
||||||
|
if (sourceblock != null) {
|
||||||
|
if (sourceblock.getWorld() != player.getWorld()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
range = Methods.waterbendingNightAugment(range, player.getWorld());
|
||||||
|
if (AvatarState.isAvatarState(player))
|
||||||
|
factor = AvatarState.getValue(factor);
|
||||||
|
Entity target = Methods.getTargetedEntity(player, range, new ArrayList<Entity>());
|
||||||
|
if (target == null) {
|
||||||
|
targetdestination = player.getTargetBlock(
|
||||||
|
Methods.getTransparentEarthbending(), (int) range)
|
||||||
|
.getLocation();
|
||||||
|
} else {
|
||||||
|
targetdestination = ((LivingEntity) target).getEyeLocation();
|
||||||
|
}
|
||||||
|
if (targetdestination.distance(location) <= 1) {
|
||||||
|
progressing = false;
|
||||||
|
targetdestination = null;
|
||||||
|
} else {
|
||||||
|
progressing = true;
|
||||||
|
targetdirection = getDirection(sourceblock.getLocation(),
|
||||||
|
targetdestination).normalize();
|
||||||
|
targetdestination = location.clone().add(
|
||||||
|
targetdirection.clone().multiply(range));
|
||||||
|
if (Methods.isPlant(sourceblock))
|
||||||
|
new Plantbending(sourceblock);
|
||||||
|
if (!Methods.isAdjacentToThreeOrMoreSources(sourceblock)) {
|
||||||
|
sourceblock.setType(Material.AIR);
|
||||||
|
}
|
||||||
|
addWater(sourceblock);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Vector getDirection(Location location, Location destination) {
|
||||||
|
double x1, y1, z1;
|
||||||
|
double x0, y0, z0;
|
||||||
|
|
||||||
|
x1 = destination.getX();
|
||||||
|
y1 = destination.getY();
|
||||||
|
z1 = destination.getZ();
|
||||||
|
|
||||||
|
x0 = location.getX();
|
||||||
|
y0 = location.getY();
|
||||||
|
z0 = location.getZ();
|
||||||
|
|
||||||
|
return new Vector(x1 - x0, y1 - y0, z1 - z0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean progress() {
|
||||||
|
if (player.isDead() || !player.isOnline()
|
||||||
|
|| !Methods.canBend(player.getName(), "Surge")) {
|
||||||
|
breakBlock();
|
||||||
|
thaw();
|
||||||
|
// instances.remove(player.getEntityId());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (System.currentTimeMillis() - time >= interval) {
|
||||||
|
time = System.currentTimeMillis();
|
||||||
|
|
||||||
|
if (Methods.getBoundAbility(player) == null) {
|
||||||
|
unfocusBlock();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!progressing
|
||||||
|
&& !Methods.getBoundAbility(player).equalsIgnoreCase("Surge")) {
|
||||||
|
unfocusBlock();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!progressing) {
|
||||||
|
sourceblock.getWorld().playEffect(location, Effect.SMOKE, 4,
|
||||||
|
(int) range);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (location.getWorld() != player.getWorld()) {
|
||||||
|
thaw();
|
||||||
|
breakBlock();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (activatefreeze) {
|
||||||
|
if (location.distance(player.getLocation()) > range) {
|
||||||
|
progressing = false;
|
||||||
|
thaw();
|
||||||
|
breakBlock();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (Methods.getBoundAbility(player) == null || !Methods.getBoundAbility(player).equalsIgnoreCase("Surge")) {
|
||||||
|
progressing = false;
|
||||||
|
thaw();
|
||||||
|
breakBlock();
|
||||||
|
returnWater();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!Methods.canBend(player.getName(), "Surge")) {
|
||||||
|
progressing = false;
|
||||||
|
thaw();
|
||||||
|
breakBlock();
|
||||||
|
returnWater();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
Vector direction = targetdirection;
|
||||||
|
|
||||||
|
location = location.clone().add(direction);
|
||||||
|
Block blockl = location.getBlock();
|
||||||
|
|
||||||
|
ArrayList<Block> blocks = new ArrayList<Block>();
|
||||||
|
|
||||||
|
if ((((blockl.getType() == Material.AIR
|
||||||
|
|| blockl.getType() == Material.FIRE
|
||||||
|
|| Methods.isPlant(blockl)
|
||||||
|
|| Methods.isWater(blockl) || Methods
|
||||||
|
.isWaterbendable(blockl, player))) && blockl
|
||||||
|
.getType() != Material.LEAVES)) {
|
||||||
|
|
||||||
|
for (double i = 0; i <= radius; i += .5) {
|
||||||
|
for (double angle = 0; angle < 360; angle += 10) {
|
||||||
|
Vector vec = Methods.getOrthogonalVector(
|
||||||
|
targetdirection, angle, i);
|
||||||
|
Block block = location.clone().add(vec).getBlock();
|
||||||
|
if (!blocks.contains(block)
|
||||||
|
&& (block.getType() == Material.AIR || block
|
||||||
|
.getType() == Material.FIRE)
|
||||||
|
|| Methods.isWaterbendable(block, player)) {
|
||||||
|
blocks.add(block);
|
||||||
|
FireBlast.removeFireBlastsAroundPoint(
|
||||||
|
block.getLocation(), 2);
|
||||||
|
}
|
||||||
|
// if (!blocks.contains(block)
|
||||||
|
// && (Methods.isPlant(block) && block.getType() !=
|
||||||
|
// Material.LEAVES)) {
|
||||||
|
// blocks.add(block);
|
||||||
|
// block.breakNaturally();
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Block block : wave.keySet()) {
|
||||||
|
if (!blocks.contains(block))
|
||||||
|
finalRemoveWater(block);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Block block : blocks) {
|
||||||
|
if (!wave.containsKey(block))
|
||||||
|
addWater(block);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wave.isEmpty()) {
|
||||||
|
// blockl.setType(Material.GLOWSTONE);
|
||||||
|
breakBlock();
|
||||||
|
progressing = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Entity entity : Methods.getEntitiesAroundPoint(location,
|
||||||
|
2 * radius)) {
|
||||||
|
|
||||||
|
boolean knockback = false;
|
||||||
|
for (Block block : wave.keySet()) {
|
||||||
|
if (entity.getLocation().distance(block.getLocation()) <= 2) {
|
||||||
|
if (entity instanceof LivingEntity
|
||||||
|
&& freeze
|
||||||
|
&& entity.getEntityId() != player
|
||||||
|
.getEntityId()) {
|
||||||
|
activatefreeze = true;
|
||||||
|
frozenlocation = entity.getLocation();
|
||||||
|
freeze();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (entity.getEntityId() != player.getEntityId()
|
||||||
|
|| canhitself)
|
||||||
|
knockback = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (knockback) {
|
||||||
|
Vector dir = direction.clone();
|
||||||
|
dir.setY(dir.getY() * upfactor);
|
||||||
|
entity.setVelocity(entity
|
||||||
|
.getVelocity()
|
||||||
|
.clone()
|
||||||
|
.add(dir.clone().multiply(
|
||||||
|
Methods.waterbendingNightAugment(factor,
|
||||||
|
player.getWorld()))));
|
||||||
|
entity.setFallDistance(0);
|
||||||
|
if (entity.getFireTicks() > 0)
|
||||||
|
entity.getWorld().playEffect(entity.getLocation(),
|
||||||
|
Effect.EXTINGUISH, 0);
|
||||||
|
entity.setFireTicks(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!progressing) {
|
||||||
|
breakBlock();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (location.distance(targetdestination) < 1) {
|
||||||
|
progressing = false;
|
||||||
|
breakBlock();
|
||||||
|
returnWater();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (radius < maxradius)
|
||||||
|
radius += .5;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void breakBlock() {
|
||||||
|
for (Block block : wave.keySet()) {
|
||||||
|
finalRemoveWater(block);
|
||||||
|
}
|
||||||
|
instances.remove(player.getEntityId());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void finalRemoveWater(Block block) {
|
||||||
|
if (wave.containsKey(block)) {
|
||||||
|
// block.setType(Material.WATER);
|
||||||
|
// block.setData(half);
|
||||||
|
// if (!Methods.adjacentToThreeOrMoreSources(block) || radius > 1) {
|
||||||
|
// block.setType(Material.AIR);
|
||||||
|
// }
|
||||||
|
TempBlock.revertBlock(block, Material.AIR);
|
||||||
|
wave.remove(block);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addWater(Block block) {
|
||||||
|
// if (Methods.isRegionProtectedFromBuild(player, Abilities.Surge,
|
||||||
|
// block.getLocation()))
|
||||||
|
// return;
|
||||||
|
if (!TempBlock.isTempBlock(block)) {
|
||||||
|
new TempBlock(block, Material.WATER, full);
|
||||||
|
// new TempBlock(block, Material.ICE, (byte) 0);
|
||||||
|
wave.put(block, block);
|
||||||
|
}
|
||||||
|
// block.setType(Material.WATER);
|
||||||
|
// block.setData(full);
|
||||||
|
// wave.put(block, block);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void clearWave() {
|
||||||
|
for (Block block : wave.keySet()) {
|
||||||
|
TempBlock.revertBlock(block, Material.AIR);
|
||||||
|
}
|
||||||
|
wave.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void moveWater(Player player) {
|
||||||
|
if (instances.containsKey(player.getEntityId())) {
|
||||||
|
instances.get(player.getEntityId()).moveWater();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean progress(int ID) {
|
||||||
|
return instances.get(ID).progress();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isBlockWave(Block block) {
|
||||||
|
for (int ID : instances.keySet()) {
|
||||||
|
if (instances.get(ID).wave.containsKey(block))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void launch(Player player) {
|
||||||
|
moveWater(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void removeAll() {
|
||||||
|
for (int id : instances.keySet()) {
|
||||||
|
for (Block block : instances.get(id).wave.keySet()) {
|
||||||
|
block.setType(Material.AIR);
|
||||||
|
instances.get(id).wave.remove(block);
|
||||||
|
}
|
||||||
|
for (Block block : instances.get(id).frozenblocks.keySet()) {
|
||||||
|
block.setType(Material.AIR);
|
||||||
|
instances.get(id).frozenblocks.remove(block);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void freeze() {
|
||||||
|
clearWave();
|
||||||
|
|
||||||
|
double freezeradius = radius;
|
||||||
|
if (freezeradius > maxfreezeradius) {
|
||||||
|
freezeradius = maxfreezeradius;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Block block : Methods.getBlocksAroundPoint(frozenlocation,
|
||||||
|
freezeradius)) {
|
||||||
|
// if (Methods.isRegionProtectedFromBuild(player, Abilities.Surge,
|
||||||
|
// block.getLocation())
|
||||||
|
// || Methods.isRegionProtectedFromBuild(player,
|
||||||
|
// Abilities.PhaseChange, block.getLocation()))
|
||||||
|
// continue;
|
||||||
|
if (TempBlock.isTempBlock(block))
|
||||||
|
continue;
|
||||||
|
if (block.getType() == Material.AIR
|
||||||
|
|| block.getType() == Material.SNOW) {
|
||||||
|
// block.setType(Material.ICE);
|
||||||
|
new TempBlock(block, Material.ICE, (byte) 0);
|
||||||
|
frozenblocks.put(block, block);
|
||||||
|
}
|
||||||
|
if (Methods.isWater(block)) {
|
||||||
|
FreezeMelt.freeze(player, block);
|
||||||
|
}
|
||||||
|
if (Methods.isPlant(block) && block.getType() != Material.LEAVES) {
|
||||||
|
block.breakNaturally();
|
||||||
|
// block.setType(Material.ICE);
|
||||||
|
new TempBlock(block, Material.ICE, (byte) 0);
|
||||||
|
frozenblocks.put(block, block);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void thaw() {
|
||||||
|
for (Block block : frozenblocks.keySet()) {
|
||||||
|
// if (block.getType() == Material.ICE) {
|
||||||
|
// // block.setType(Material.WATER);
|
||||||
|
// // block.setData((byte) 0x7);
|
||||||
|
// block.setType(Material.AIR);
|
||||||
|
// }
|
||||||
|
TempBlock.revertBlock(block, Material.AIR);
|
||||||
|
frozenblocks.remove(block);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void thaw(Block block) {
|
||||||
|
for (int id : instances.keySet()) {
|
||||||
|
if (instances.get(id).frozenblocks.containsKey(block)) {
|
||||||
|
// if (block.getType() == Material.ICE) {
|
||||||
|
// // block.setType(Material.WATER);
|
||||||
|
// // block.setData((byte) 0x7);
|
||||||
|
// block.setType(Material.AIR);
|
||||||
|
// }
|
||||||
|
TempBlock.revertBlock(block, Material.AIR);
|
||||||
|
instances.get(id).frozenblocks.remove(block);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean canThaw(Block block) {
|
||||||
|
for (int id : instances.keySet()) {
|
||||||
|
if (instances.get(id).frozenblocks.containsKey(block)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void returnWater() {
|
||||||
|
if (location != null) {
|
||||||
|
new WaterReturn(player, location.getBlock());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getDescription() {
|
||||||
|
return "To use, place your cursor over a waterbendable object "
|
||||||
|
+ "(water, ice, plants if you have plantbending) and tap sneak "
|
||||||
|
+ "(default: shift). Smoke will appear where you've selected, "
|
||||||
|
+ "indicating the origin of your ability. After you have selected an origin, "
|
||||||
|
+ "simply left-click in any direction and you will see your water spout off in that "
|
||||||
|
+ "direction and form a large wave, knocking back all within its path. "
|
||||||
|
+ "If you look towards a creature when you use this ability, it will target that creature. "
|
||||||
|
+ "Additionally, tapping sneak while the wave is en route will cause that wave to encase the "
|
||||||
|
+ "first target it hits in ice.";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -92,6 +92,16 @@ Abilities:
|
||||||
Radius: 5
|
Radius: 5
|
||||||
Plantbending:
|
Plantbending:
|
||||||
RegrowTime: 180000
|
RegrowTime: 180000
|
||||||
|
Surge:
|
||||||
|
Enabled: true
|
||||||
|
Description: "This ability has two distinct features. If you sneak to select a source block, you can then click in a direction and a large wave will be launched in that direction. If you sneak again while the wave is en route, the wave will freeze the next target it hits. If, instead, you click to select a source block, you can hold sneak to form a wall of water at your cursor location. Click to shift between a water wall and an ice wall. Release sneak to dissipate it."
|
||||||
|
Wave:
|
||||||
|
Radius: 3
|
||||||
|
HorizontalPush: 1
|
||||||
|
VerticalPush: 0.2
|
||||||
|
Wall:
|
||||||
|
Range: 5
|
||||||
|
Radius: 2
|
||||||
WaterBubble:
|
WaterBubble:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
Description: "To use, the bender must merely have the ability selected. All water around the user in a small bubble will vanish, replacing itself once the user either gets too far away or selects a different ability."
|
Description: "To use, the bender must merely have the ability selected. All water around the user in a small bubble will vanish, replacing itself once the user either gets too far away or selects a different ability."
|
||||||
|
|
Loading…
Reference in a new issue