PhaseChange recode and EarthGrab fix (#661)

* Fix metalclips

- Removed a check that was preventing metalclips from progressing past 1 clip on a target.

* Fix metalclips

- Fixed a bug limiting the metal clip count to one

* Improve MetalClips

- Fixed bug where shooting at a block spawned two clips
- Added ShootCooldown and CrushCooldown
- ShootCooldown only applies to shooting clips
- Changed how crushing works:
--- Removed old style and variables
--- When controlling an entity with 4 clips, the controller can click to
cause the armor to "crush" and damage the entity.
--- Has own cooldown, default of 2000 (2 seconds)
- Changed launching
--- Works with all clip amounts except 4
--- When the user releases sneak, the entity will be launched at varying
power depending on how many clips were attached.
- Changed ability cooldown to activate only after the ability is
finished.

* Add CrushDamage option to MetalClips

* New Damage Type, MetalClips changes

- Fixed MetalClips bug caused in magnetizing
- Added ignoreArmor option to damageEntity method, default true for most
abilities. If wanted to be changed, someone needs to go through and add
false as a parameter
- Changed default config option for MetalClips description

* PhaseChange recode

* Chris wanted changes

* Chris doesn't want bugs

* Only you can prevent bugs

- Added checks for worlds to prevent errors

* Remove unnecessary auto generated comments

* Loony didn't like the passive

* Added RegionProtection checks

* PhaseChange

* Revert "PhaseChange"

This reverts commit 761c73f5756771674719ffca52413cffa09243a8.

* Revert "Added RegionProtection checks"

This reverts commit b53a02a74d0276d4d1e773e1c197666cbcfab624.

* Revert "Loony didn't like the passive"

This reverts commit 6612bb7fa8eea3e26c01d0ef761c658447779e03.

* Revert "Remove unnecessary auto generated comments"

This reverts commit da9c45106d0b7e256c278e6a84d15f7a7340a140.

* Revert "Only you can prevent bugs"

This reverts commit 630161659ea89bfb106924c8ab1fbcdb8f6f1310.

* Revert "Chris doesn't want bugs"

This reverts commit eda2dee6b52dd38c73f35680c5e4484adc5b5b91.

* Revert "Chris wanted changes"

This reverts commit 30b76c10c4adc63784ea7115eb4f9c636650d6c5.

* Revert "PhaseChange recode"

This reverts commit f8f290dd8c57a3467a87de7e43b58ce635196c62.

* Conflicts

* Stupid conflicts

* I hope and pray

* Revert "Revert "Chris wanted changes""

This reverts commit e612607c8a16a735c92014714c00aa671954b4a5.

* Revert "Revert "Chris doesn't want bugs""

This reverts commit bd656b814d7ffa2d9c84fa304d3adb8f1535f782.

* Revert "Revert "Only you can prevent bugs""

This reverts commit 7772c95737130cf414ff1af49dcfb48865be5374.

* Revert "Revert "Remove unnecessary auto generated comments""

This reverts commit 69315dc7baa6cd237fbd89394e544913596ec6e3.

* Revert "Revert "Loony didn't like the passive""

This reverts commit ea397c6323e50d219395d5912850513afd6f2a7b.

* Revert "Revert "Added RegionProtection checks""

This reverts commit 8cb41709f65e4322e68b2f0e1792987f7fc214f2.

* Revert "Revert "PhaseChange""

This reverts commit da6b0e7071acf74df6447b15daf4ae6e39f057f6.

* Working PhaseChange finally

* Fix EarthGrab

* Air fixes, PhaseChange changes
This commit is contained in:
Simplicitee 2016-12-19 23:43:56 -05:00 committed by Christopher Martin
parent 24ca9182c0
commit 5ad7f1f3b5
12 changed files with 666 additions and 561 deletions

View file

@ -862,6 +862,18 @@ public class GeneralMethods {
public static long getGlobalCooldown() {
return ConfigManager.defaultConfig.get().getLong("Properties.GlobalCooldown");
}
/**
*
* @param one One location being tested
* @param two Another location being tested
* @return The horizontal distance between two locations
*/
public static double getHorizontalDistance(Location one, Location two) {
double x = one.getX() - two.getX();
double z = one.getZ() - two.getZ();
return Math.sqrt((x*x) + (z*z));
}
@SuppressWarnings("incomplete-switch")
public static int getIntCardinalDirection(Vector vector) {

View file

@ -157,8 +157,7 @@ import com.projectkorra.projectkorra.waterbending.HealingWaters;
import com.projectkorra.projectkorra.waterbending.IceBlast;
import com.projectkorra.projectkorra.waterbending.IceSpikeBlast;
import com.projectkorra.projectkorra.waterbending.OctopusForm;
import com.projectkorra.projectkorra.waterbending.PhaseChangeFreeze;
import com.projectkorra.projectkorra.waterbending.PhaseChangeMelt;
import com.projectkorra.projectkorra.waterbending.PhaseChange;
import com.projectkorra.projectkorra.waterbending.PlantArmor;
import com.projectkorra.projectkorra.waterbending.SurgeWall;
import com.projectkorra.projectkorra.waterbending.SurgeWave;
@ -168,6 +167,7 @@ import com.projectkorra.projectkorra.waterbending.WaterManipulation;
import com.projectkorra.projectkorra.waterbending.WaterPassive;
import com.projectkorra.projectkorra.waterbending.WaterSpout;
import com.projectkorra.projectkorra.waterbending.WaterSpoutWave;
import com.projectkorra.projectkorra.waterbending.PhaseChange.PhaseChangeType;
import com.projectkorra.rpg.RPGMethods;
public class PKListener implements Listener {
@ -200,9 +200,10 @@ public class PKListener implements Listener {
blast.remove();
}
if (PhaseChangeFreeze.getFrozenBlocks().containsKey(block)) {
PhaseChangeFreeze.thaw(block);
event.setCancelled(true);
if (PhaseChange.getFrozenBlocksAsBlock().contains(block)) {
if (PhaseChange.thaw(block)) {
event.setCancelled(true);
}
} else if (SurgeWall.getWallBlocks().containsKey(block)) {
SurgeWall.thaw(block);
event.setCancelled(true);
@ -282,7 +283,7 @@ public class PKListener implements Listener {
event.setCancelled(!EarthPassive.canPhysicsChange(block));
}
if (!event.isCancelled()) {
event.setCancelled(PhaseChangeFreeze.getFrozenBlocks().containsKey(block));
event.setCancelled(PhaseChange.getFrozenBlocksAsBlock().contains(block));
}
if (!event.isCancelled()) {
event.setCancelled(!SurgeWave.canThaw(block));
@ -511,8 +512,8 @@ public class PKListener implements Listener {
if (blast != null) {
blast.remove();
}
if (PhaseChangeFreeze.getFrozenBlocks().containsKey(block)) {
PhaseChangeFreeze.thaw(block);
if (PhaseChange.getFrozenBlocksAsBlock().contains(block)) {
PhaseChange.thaw(block);
}
if (SurgeWall.getWallBlocks().containsKey(block)) {
block.setType(Material.AIR);
@ -788,7 +789,7 @@ public class PKListener implements Listener {
if (!event.isCancelled() && event.getCause() == DamageCause.FALL) {
Player source = Flight.getLaunchedBy(player);
if (source != null) {
if (source == player) {
event.setCancelled(true);
}
}
@ -1040,6 +1041,7 @@ public class PKListener implements Listener {
}
Player player = event.getPlayer();
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
if (Paralyze.isParalyzed(player)) {
event.setCancelled(true);
return;
@ -1091,7 +1093,6 @@ public class PKListener implements Listener {
}
else {
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
if (bPlayer != null) {
if (bPlayer.hasElement(Element.AIR) || bPlayer.hasElement(Element.CHI) || bPlayer.hasElement(Element.EARTH)) {
PassiveHandler.checkSpeedPassives(player);
@ -1266,7 +1267,12 @@ public class PKListener implements Listener {
OctopusForm.form(player);
}
else if (abil.equalsIgnoreCase("PhaseChange")) {
new PhaseChangeMelt(player);
if (!CoreAbility.hasAbility(player, PhaseChange.class)) {
new PhaseChange(player, PhaseChangeType.MELT);
} else {
PhaseChange pc = CoreAbility.getAbility(player, PhaseChange.class);
pc.startNewType(PhaseChangeType.MELT);
}
}
else if (abil.equalsIgnoreCase("WaterManipulation")) {
new WaterManipulation(player);
@ -1487,7 +1493,12 @@ public class PKListener implements Listener {
new OctopusForm(player);
}
else if (abil.equalsIgnoreCase("PhaseChange")) {
new PhaseChangeFreeze(player);
if (!CoreAbility.hasAbility(player, PhaseChange.class)) {
new PhaseChange(player, PhaseChangeType.FREEZE);
} else {
PhaseChange pc = CoreAbility.getAbility(player, PhaseChange.class);
pc.startNewType(PhaseChangeType.FREEZE);
}
}
else if (abil.equalsIgnoreCase("PlantArmor")) {
new PlantArmor(player);

View file

@ -1,21 +1,5 @@
package com.projectkorra.projectkorra.ability;
import com.projectkorra.projectkorra.BendingPlayer;
import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ability.util.Collision;
import com.projectkorra.projectkorra.util.BlockSource;
import com.projectkorra.projectkorra.util.ParticleEffect;
import com.projectkorra.projectkorra.util.TempBlock;
import com.projectkorra.projectkorra.util.ParticleEffect.ParticleData;
import com.projectkorra.projectkorra.waterbending.PhaseChangeFreeze;
import com.projectkorra.projectkorra.waterbending.PhaseChangeMelt;
import com.projectkorra.projectkorra.waterbending.SurgeWall;
import com.projectkorra.projectkorra.waterbending.SurgeWave;
import com.projectkorra.projectkorra.waterbending.WaterArms;
import com.projectkorra.projectkorra.waterbending.WaterSpout;
import com.projectkorra.rpg.RPGMethods;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
@ -26,6 +10,21 @@ import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import com.projectkorra.projectkorra.BendingPlayer;
import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ability.util.Collision;
import com.projectkorra.projectkorra.util.BlockSource;
import com.projectkorra.projectkorra.util.ParticleEffect;
import com.projectkorra.projectkorra.util.ParticleEffect.ParticleData;
import com.projectkorra.projectkorra.util.TempBlock;
import com.projectkorra.projectkorra.waterbending.PhaseChange;
import com.projectkorra.projectkorra.waterbending.SurgeWall;
import com.projectkorra.projectkorra.waterbending.SurgeWave;
import com.projectkorra.projectkorra.waterbending.WaterArms;
import com.projectkorra.projectkorra.waterbending.WaterSpout;
import com.projectkorra.rpg.RPGMethods;
public abstract class WaterAbility extends ElementalAbility {
public WaterAbility(Player player) {
@ -233,7 +232,7 @@ public abstract class WaterAbility extends ElementalAbility {
BlockFace[] faces = { BlockFace.DOWN, BlockFace.UP, BlockFace.NORTH, BlockFace.EAST, BlockFace.WEST, BlockFace.SOUTH };
boolean adjacent = false;
for (BlockFace face : faces) {
if (PhaseChangeFreeze.getFrozenBlocks().containsKey((block.getRelative(face)))) {
if (PhaseChange.getFrozenBlocksAsBlock().contains((block.getRelative(face)))) {
adjacent = true;
}
}
@ -342,8 +341,6 @@ public abstract class WaterAbility extends ElementalAbility {
}
public static void stopBending() {
PhaseChangeFreeze.removeAllCleanup();
PhaseChangeMelt.removeAllCleanup();
SurgeWall.removeAllCleanup();
SurgeWave.removeAllCleanup();
WaterArms.removeAllCleanup();

View file

@ -257,10 +257,10 @@ public class ConfigManager {
config.addDefault("Abilities.Water.IceSpike.DeathMessage", "{victim} was impaled by {attacker}'s {ability}");
config.addDefault("Abilities.Water.OctopusForm.Description", "This ability allows the waterbender to manipulate a large quantity of water into a form resembling that of an octopus. " + "To use, left click to select a water source. Then, hold sneak to channel this ability. " + "While channeling, the water will form itself around you and has a chance to block incoming attacks. " + "Additionally, you can left click while channeling to attack things near you, dealing damage and knocking them back. " + "Releasing sneak at any time will dissipate the form.");
config.addDefault("Abilities.Water.OctopusForm.DeathMessage", "{victim} was slapped by {attacker}'s {ability}");
config.addDefault("Abilities.Water.PhaseChange.Description", "To use, simply left click. " + "Any water you are looking at within range will instantly freeze over into solid ice. " + "Provided you stay within range of the ice and do not unbind FreezeMelt, " + "that ice will not thaw. If, however, you do either of those the ice will instantly thaw. " + "If you sneak (default: shift), anything around where you are looking at will instantly melt. " + "Since this is a more favorable state for these things, they will never re-freeze unless they " + "would otherwise by nature or some other bending ability. Additionally, if you tap sneak while " + "targetting water with FreezeMelt, it will evaporate water around that block that is above " + "sea level. ");
config.addDefault("Abilities.Water.PlantArmor.Description", "PlantArmor is a defensive ability in the arsenal of the plantbender. Left clicking on leaves with this ability will temporarily clad you in strong armor made out of plants! You can use this defensively, but you can also use the armor as a source for other plantbending skills.");
config.addDefault("Abilities.Water.Surge.Description", "This ability has two distinct features. If you sneak to select a source block, you can then left 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 left click to select a source block, you can hold sneak to form a wall of water at your cursor location. Left click to shift between a water wall and an ice wall. Release sneak to dissipate it.");
config.addDefault("Abilities.Water.Torrent.Description", "Torrent is one of the strongest moves in a waterbender's arsenal. To use, first left click a source block to select it; then hold sneak to begin streaming the water around you. Water flowing around you this way will damage and knock back nearby enemies and projectiles. If you release sneak during this, you will create a large wave that expands outwards from you, launching anything in its path back. Instead, if you left click you release the water and channel it to flow towards your cursor. Anything caught in the blast will be tossed about violently and take damage. Finally, if you left click again when the water is torrenting, it will freeze the area around it when it is obstructed.");
config.addDefault("Abilities.Water.PhaseChange.Description", "To use, simply left-click. " + "Any water you are looking at within range will instantly freeze over into solid ice. " + "Provided you stay within range of the ice, " + "that ice will not thaw. If, however, you do either of those the ice will instantly thaw. " + "If you sneak (default: shift), anything around where you are looking at will instantly melt. " + "Since this is a more favorable state for these things, they will never re-freeze unless they " + "would otherwise by nature or some other bending ability." + " Sneaking while running will cause you to skate forwards on ice, and create ice from water under you." + " Having PhaseChange bound while moving removes ice from where you are standing and directly in front of you."/* Additionally, if you tap sneak while " + "targeting water with PhaseChange, it will evaporate water around that block that is above " + "sea level. "*/);
config.addDefault("Abilities.Water.PlantArmor.Description", "PlantArmor is a defensive ability in the arsenal of the plantbender. Clicking on leaves with this ability will temporarily clad you in strong armor made out of plants! You can use this defensively, but you can also use the armor as a source for other plantbending skills.");
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.Torrent.Description", "Torrent is one of the strongest moves in a waterbender's arsenal. To use, first click a source block to select it; then hold shift to begin streaming the water around you. Water flowing around you this way will damage and knock back nearby enemies and projectiles. If you release shift during this, you will create a large wave that expands outwards from you, launching anything in its path back. Instead, if you click you release the water and channel it to flow towards your cursor. Anything caught in the blast will be tossed about violently and take damage. Finally, if you click again when the water is torrenting, it will freeze the area around it when it is obstructed.");
config.addDefault("Abilities.Water.Torrent.DeathMessage", "{victim} was taken down by {attacker}'s {ability}");
config.addDefault("Abilities.Water.WaterArms.Description", "One of the most diverse moves in a Waterbender's arsenal, this move creates tendrils " + "of water from the players arms to emulate their actual arms. Each water arms mode will be bound to a slot, switch slots to change mode. " + "To deactive the arms, hold Sneak and Double left click." + "\nPull - Use your Arms to pull blocks, items, mobs or even players towards you!" + "\nPunch - An offensive attack, harming players or mobs!" + "\nGrapple - Scale walls and speed across battlefields, using your Arms as a grappling hook!" + "\nGrab - Grab an entity with your arm, and swing them about!" + "\nFreeze - Use your Arms to fire small blasts of ice in any direction!" + "\nSpear - Throw your Arms in any direction, freezing whatever it hits!");
config.addDefault("Abilities.Water.WaterArms.SneakMessage", "Active Ability:");
@ -670,10 +670,19 @@ public class ConfigManager {
config.addDefault("Abilities.Water.OctopusForm.AngleIncrement", 45);
config.addDefault("Abilities.Water.PhaseChange.Enabled", true);
config.addDefault("Abilities.Water.PhaseChange.Range", 16);
config.addDefault("Abilities.Water.PhaseChange.Radius", 4);
config.addDefault("Abilities.Water.PhaseChange.Freeze.Cooldown", 0);
config.addDefault("Abilities.Water.PhaseChange.Melt.Cooldown", 0);
config.addDefault("Abilities.Water.PhaseChange.SourceRange", 7);
config.addDefault("Abilities.Water.PhaseChange.Freeze.Cooldown", 500);
config.addDefault("Abilities.Water.PhaseChange.Freeze.Radius", 3);
config.addDefault("Abilities.Water.PhaseChange.Freeze.Depth", 1);
config.addDefault("Abilities.Water.PhaseChange.Freeze.ControlRadius", 25);
config.addDefault("Abilities.Water.PhaseChange.Melt.Cooldown", 2000);
config.addDefault("Abilities.Water.PhaseChange.Melt.Delay", 50);
config.addDefault("Abilities.Water.PhaseChange.Melt.Radius", 7);
config.addDefault("Abilities.Water.PhaseChange.Melt.AllowFlow", true);
config.addDefault("Abilities.Water.PhaseChange.Skate.Cooldown", 7000);
config.addDefault("Abilities.Water.PhaseChange.Skate.Duration", 7000);
config.addDefault("Abilities.Water.PhaseChange.Skate.Radius", 1);
config.addDefault("Abilities.Water.PhaseChange.Skate.Speed", 0.335);
config.addDefault("Abilities.Water.PlantArmor.Enabled", true);
config.addDefault("Abilities.Water.PlantArmor.Duration", 7500);

View file

@ -17,7 +17,7 @@ import com.projectkorra.projectkorra.ability.EarthAbility;
import com.projectkorra.projectkorra.util.ParticleEffect;
public class EarthGrab extends EarthAbility {
private long cooldown;
private double lowestDistance;
private double selectRange;
@ -35,7 +35,7 @@ public class EarthGrab extends EarthAbility {
public EarthGrab(Player player) {
super(player);
this.selectRange = getConfig().getDouble("Abilities.Earth.EarthGrab.SelectRange");
this.height = getConfig().getDouble("Abilities.Earth.EarthGrab.Height");
this.cooldown = getConfig().getLong("Abilities.Earth.EarthGrab.Cooldown");
@ -47,24 +47,24 @@ public class EarthGrab extends EarthAbility {
this.loc = player.getLocation();
this.dir = player.getLocation().getDirection().clone().normalize().multiply(1.5);
this.random = new Random();
if (!bPlayer.canBend(this)) {
return;
}
if(player.isSneaking()) {
if (player.isSneaking()) {
start();
} else {
Location targetLocation = GeneralMethods.getTargetedLocation(player, 1);
Block block = GeneralMethods.getTopBlock(targetLocation, 1, 1);
if(isEarthbendable(block) && block.getWorld().equals(player.getWorld()) && block.getLocation().distance(player.getLocation()) <= 1.6) {
if (isEarthbendable(block) && block.getWorld().equals(player.getWorld()) && block.getLocation().distance(player.getLocation()) <= 1.6) {
earthGrabSelf();
remove();
}
}
}
public void formDome() {
public void formDome() {
if (closestEntity != null) {
ArrayList<Block> blocks = new ArrayList<Block>();
Location location = closestEntity.getLocation();
@ -75,15 +75,11 @@ public class EarthGrab extends EarthAbility {
double factor2 = 4;
int height1 = 3;
int height2 = 2;
for (double angle = 0; angle <= 360; angle += 20) {
testLoc = loc1.clone().add(
factor * Math.cos(Math.toRadians(angle)), 1,
factor * Math.sin(Math.toRadians(angle)));
testloc2 = loc2.clone().add(
factor2 * Math.cos(Math.toRadians(angle)), 1,
factor2 * Math.sin(Math.toRadians(angle)));
testLoc = loc1.clone().add(factor * Math.cos(Math.toRadians(angle)), 1, factor * Math.sin(Math.toRadians(angle)));
testloc2 = loc2.clone().add(factor2 * Math.cos(Math.toRadians(angle)), 1, factor2 * Math.sin(Math.toRadians(angle)));
for (int y = 0; y < height - height1; y++) {
testLoc = testLoc.clone().add(0, -1, 0);
if (isEarthbendable(testLoc.getBlock())) {
@ -94,7 +90,7 @@ public class EarthGrab extends EarthAbility {
break;
}
}
for (int y = 0; y < height - height2; y++) {
testloc2 = testloc2.clone().add(0, -1, 0);
if (isEarthbendable(testloc2.getBlock())) {
@ -111,12 +107,10 @@ public class EarthGrab extends EarthAbility {
}
}
public void earthGrabSelf() {
public void earthGrabSelf() {
closestEntity = player;
getGround();
ParticleEffect.BLOCK_CRACK.display(
(ParticleEffect.ParticleData) new ParticleEffect.BlockData(blockType, blockByte), 1F, 1F, 1F,
0.1F, 100, player.getLocation(), 500);
ParticleEffect.BLOCK_CRACK.display((ParticleEffect.ParticleData) new ParticleEffect.BlockData(blockType, blockByte), 1F, 1F, 1F, 0.1F, 100, player.getLocation(), 500);
if (closestEntity != null) {
ArrayList<Block> blocks = new ArrayList<Block>();
Location location = closestEntity.getLocation();
@ -127,15 +121,11 @@ public class EarthGrab extends EarthAbility {
double factor2 = 4;
int height1 = 3;
int height2 = 2;
for (double angle = 0; angle <= 360; angle += 20) {
testLoc = loc1.clone().add(
factor * Math.cos(Math.toRadians(angle)), 1,
factor * Math.sin(Math.toRadians(angle)));
testLoc2 = loc2.clone().add(
factor2 * Math.cos(Math.toRadians(angle)), 1,
factor2 * Math.sin(Math.toRadians(angle)));
testLoc = loc1.clone().add(factor * Math.cos(Math.toRadians(angle)), 1, factor * Math.sin(Math.toRadians(angle)));
testLoc2 = loc2.clone().add(factor2 * Math.cos(Math.toRadians(angle)), 1, factor2 * Math.sin(Math.toRadians(angle)));
for (int y = 0; y < height - height1; y++) {
testLoc = testLoc.clone().add(0, -1, 0);
if (isEarthbendable(testLoc.getBlock())) {
@ -146,7 +136,7 @@ public class EarthGrab extends EarthAbility {
break;
}
}
for (int y = 0; y < height - height2; y++) {
testLoc2 = testLoc2.clone().add(0, -1, 0);
if (isEarthbendable(testLoc2.getBlock())) {
@ -167,28 +157,36 @@ public class EarthGrab extends EarthAbility {
public String getName() {
return "EarthGrab";
}
@SuppressWarnings("deprecation")
private void getGround() {
for (int i = 0; i <= 5; i++) {
Block block = loc.getBlock().getRelative(BlockFace.DOWN, i);
if (isEarthbendable(block)) {
groundBlock = block;
blockType = block.getType();
blockByte = block.getData();
return;
private Block getGround() {
Block b = GeneralMethods.getTopBlock(loc, 3);
if (isEarthbendable(b)) {
blockType = b.getType();
blockByte = b.getData();
return b;
} else {
while (!isEarthbendable(b)) {
b = b.getRelative(BlockFace.DOWN);
if (player.getLocation().getBlockY() - b.getY() > 5) {
break;
}
}
if (isEarthbendable(b)) {
return b;
}
}
return null;
}
@Override
public void progress() {
getGround();
bPlayer.addCooldown(this);
if(groundBlock == null) {
groundBlock = getGround();
if (groundBlock == null) {
remove();
return;
}
bPlayer.addCooldown(this);
dir = dir.clone().normalize().multiply(1.5);
dir.setY(0);
double distance = loc.getY() - (double) groundBlock.getY();
@ -201,33 +199,31 @@ public class EarthGrab extends EarthAbility {
dir.setY(0);
}
loc.add(dir);
ParticleEffect.BLOCK_CRACK.display(
(ParticleEffect.ParticleData) new ParticleEffect.BlockData(blockType, blockByte), 1F, 0.1F, 1F,
0.1F, 100, loc.add(0, -1, 0), 500);
if(player.isDead() || !player.isOnline()) {
ParticleEffect.BLOCK_CRACK.display((ParticleEffect.ParticleData) new ParticleEffect.BlockData(blockType, blockByte), 1F, 0.1F, 1F, 0.1F, 100, loc.add(0, -1, 0), 500);
if (player.isDead() || !player.isOnline()) {
remove();
return;
}
if(!player.isSneaking()) {
if (!player.isSneaking()) {
remove();
return;
}
if(loc.getWorld().equals(startLoc.getWorld()) && loc.distance(startLoc) >= selectRange) {
if (loc.getWorld().equals(startLoc.getWorld()) && loc.distance(startLoc) >= selectRange) {
remove();
return;
}
for(Entity e : GeneralMethods.getEntitiesAroundPoint(loc, 2.5)) {
if(e.getEntityId() != player.getEntityId() && e instanceof LivingEntity) {
for (Entity e : GeneralMethods.getEntitiesAroundPoint(loc, 2.5)) {
if (e.getEntityId() != player.getEntityId() && e instanceof LivingEntity) {
closestEntity = e;
formDome();
remove();
return;
}
}
if(random.nextInt(2) == 0) {
if (random.nextInt(2) == 0) {
playEarthbendingSound(loc);
}
}
@Override
@ -239,7 +235,7 @@ public class EarthGrab extends EarthAbility {
public long getCooldown() {
return cooldown;
}
@Override
public boolean isSneakAbility() {
return true;
@ -301,5 +297,5 @@ public class EarthGrab extends EarthAbility {
public void setCooldown(long cooldown) {
this.cooldown = cooldown;
}
}

View file

@ -5,6 +5,7 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
@ -25,7 +26,13 @@ import com.projectkorra.projectkorra.ability.EarthAbility;
import com.projectkorra.projectkorra.ability.FireAbility;
import com.projectkorra.projectkorra.util.ParticleEffect;
import com.projectkorra.projectkorra.util.TempBlock;
import com.projectkorra.projectkorra.waterbending.PhaseChangeMelt;
import com.projectkorra.projectkorra.waterbending.PhaseChange;
import com.projectkorra.projectkorra.waterbending.SurgeWave;
import com.projectkorra.projectkorra.waterbending.Torrent;
import com.projectkorra.projectkorra.waterbending.WaterArmsSpear;
import com.projectkorra.projectkorra.waterbending.WaterCombo;
import com.projectkorra.projectkorra.waterbending.WaterManipulation;
import com.projectkorra.projectkorra.waterbending.WaterSpoutWave;
public class HeatControl extends FireAbility {
@ -50,6 +57,7 @@ public class HeatControl extends FireAbility {
private double meltRange;
private double meltRadius;
private Location meltLocation;
private static final Map<Block, TempBlock> MELTED_BLOCKS = new HashMap<>();
//HeatControl Solidify variables
private int solidifyRadius;
@ -90,7 +98,7 @@ public class HeatControl extends FireAbility {
for (Block block : GeneralMethods.getBlocksAroundPoint(meltLocation, meltRadius)) {
if (isMeltable(block)) {
PhaseChangeMelt.melt(player, block);
melt(player, block);
}
}
@ -288,6 +296,44 @@ public class HeatControl extends FireAbility {
return true;
}
public static void melt(Player player, final Block block) {
if (GeneralMethods.isRegionProtectedFromBuild(player, "HeatControl", block.getLocation())) {
return;
} else if (!SurgeWave.canThaw(block)) {
SurgeWave.thaw(block);
return;
} else if (!Torrent.canThaw(block)) {
Torrent.thaw(block);
return;
} else if (WaterArmsSpear.canThaw(block)) {
WaterArmsSpear.thaw(block);
return;
}
WaterSpoutWave.thaw(block);
WaterCombo.thaw(block);
if (isMeltable(block) && !TempBlock.isTempBlock(block) && WaterManipulation.canPhysicsChange(block)) {
if (block.getType() == Material.SNOW) {
block.setType(Material.AIR);
return;
} else if (PhaseChange.getFrozenBlocksAsBlock().contains(block)) {
PhaseChange.thaw(block);
} else {
TempBlock tb = new TempBlock(block, Material.WATER, (byte)0);
MELTED_BLOCKS.put(block, tb);
new BukkitRunnable() {
@Override
public void run() {
MELTED_BLOCKS.get(block).revertBlock();
MELTED_BLOCKS.remove(block);
}
}.runTaskLater(ProjectKorra.plugin, 5 * 20 * 60);
}
}
}
public void solidify(List<Location> area) {
if (System.currentTimeMillis() < solidifyLastBlockTime + solidifyDelay) {
return;

View file

@ -9,6 +9,7 @@ import com.projectkorra.projectkorra.util.ClickType;
import com.projectkorra.projectkorra.util.DamageHandler;
import com.projectkorra.projectkorra.util.ParticleEffect;
import com.projectkorra.projectkorra.util.TempBlock;
import com.projectkorra.projectkorra.waterbending.PhaseChange.PhaseChangeType;
import org.bukkit.Location;
import org.bukkit.Material;
@ -404,7 +405,16 @@ public class OctopusForm extends WaterAbility {
private void freezeBellow(Block block) {
if (isWater(block.getRelative(BlockFace.DOWN)) && !GeneralMethods.isSolid(block) && !isWater(block)) {//&& !TempBlock.isTempBlock(block)) {
PhaseChangeFreeze.freeze(player, block.getRelative(BlockFace.DOWN));
if (hasAbility(player, PhaseChange.class)) {
getAbility(player, PhaseChange.class).freeze(block);
} else {
PhaseChange pc = new PhaseChange(player, PhaseChangeType.FREEZE);
for (TempBlock tb : pc.getFrozenBlocks()) {
tb.revertBlock();
}
pc.getFrozenBlocks().clear();
pc.freeze(block);
}
}
}

View file

@ -0,0 +1,488 @@
package com.projectkorra.projectkorra.waterbending;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ability.IceAbility;
import com.projectkorra.projectkorra.util.TempBlock;
public class PhaseChange extends IceAbility {
public static enum PhaseChangeType {
FREEZE, MELT, SKATE;
@Override
public String toString() {
if (this == FREEZE) {
return "Freeze";
} else if (this == MELT) {
return "Melt";
} else if (this == SKATE) {
return "Skate";
}
return "";
}
}
private List<PhaseChangeType> active_types = new ArrayList<>();
private static Map<TempBlock, Player> PLAYER_BY_BLOCK = new HashMap<>();
private CopyOnWriteArrayList<TempBlock> blocks = new CopyOnWriteArrayList<>();
private Random r = new Random();
private int sourceRange = 8;
//Freeze Variables
private long freezeCooldown = 500;
private int freezeRadius = 3;
private int depth = 1;
private double controlRadius = 25;
//Melt Variables
private Location meltLoc;
private long meltCooldown = 7000;
private int meltRadius;
private int meltMaxRadius = 7;
private int meltDelay = 50;
private boolean allowMeltFlow;
private long lastBlockTime = 0;
private CopyOnWriteArrayList<Block> melted_blocks = new CopyOnWriteArrayList<>();
/*Skate Variables
private long skateCooldown = 7000;
private int skateRadius = 1;
private long duration = 7000;
private double speed = 0.335;
*/
public PhaseChange(Player player, PhaseChangeType type) {
super(player);
startNewType(type);
start();
}
@Override
public void progress() {
if (!player.isOnline() || player.isDead()) {
remove();
return;
}
if (active_types.contains(PhaseChangeType.FREEZE)) {
if (blocks.isEmpty()) {
active_types.remove(PhaseChangeType.FREEZE);
return;
}
for (TempBlock tb : blocks) {
if (tb.getLocation().getWorld() != player.getWorld()) {
tb.revertBlock();
blocks.remove(tb);
PLAYER_BY_BLOCK.remove(tb);
} else if (tb.getLocation().distanceSquared(player.getLocation()) > (controlRadius*controlRadius)) {
tb.revertBlock();
blocks.remove(tb);
PLAYER_BY_BLOCK.remove(tb);
}
}
}
if (active_types.contains(PhaseChangeType.MELT)) {
if (active_types.contains(PhaseChangeType.SKATE)) {
active_types.remove(PhaseChangeType.MELT);
return;
}
if (!player.isSneaking()) {
active_types.remove(PhaseChangeType.MELT);
bPlayer.addCooldown("PhaseChangeMelt", meltCooldown);
return;
}
if (meltRadius >= meltMaxRadius) {
meltRadius = 1;
}
Location l = GeneralMethods.getTargetedLocation(player, sourceRange);
resetMeltLocation(l);
meltArea(l, meltRadius);
}
/*if (active_types.contains(PhaseChangeType.SKATE)) {
if (!player.isSprinting()) {
active_types.remove(PhaseChangeType.SKATE);
bPlayer.addCooldown("PhaseChangeSkate", skateCooldown);
return;
}
if (System.currentTimeMillis() > getStartTime() + duration) {
return;
}
Location center = player.getLocation().clone().subtract(0, 1, 0);
if (isWater(center.getBlock()) || isIce(center.getBlock())) {
freezeArea(center, skateRadius, PhaseChangeType.SKATE);
Vector v = new Vector(player.getLocation().getDirection().getX(), 0, player.getLocation().getDirection().getZ());
player.setVelocity(v.normalize().multiply(speed));
displaySkateParticles();
}
}*/
if (active_types.isEmpty()) {
remove();
}
}
public void startNewType(PhaseChangeType type) {
if (type == PhaseChangeType.MELT) {
if (bPlayer.isOnCooldown("PhaseChangeMelt")) {
return;
}
}
active_types.add(type);
setFields(type);
}
public void setFields(PhaseChangeType type) {
int night = 1;
if (isNight(player.getWorld())) {
night = (int) Math.round(getNightFactor());
}
sourceRange = night*getConfig().getInt("Abilities.Water.PhaseChange.SourceRange");
if (type == PhaseChangeType.FREEZE) {
depth = night*getConfig().getInt("Abilities.Water.PhaseChange.Freeze.Depth");
controlRadius = night*getConfig().getDouble("Abilities.Water.PhaseChange.Freeze.ControlRadius");
freezeCooldown = getConfig().getLong("Abilities.Water.PhaseChange.Freeze.Cooldown");
freezeRadius = night*getConfig().getInt("Abilities.Water.PhaseChange.Freeze.Radius");
freezeArea(player.getTargetBlock((Set<Material>)null, sourceRange).getLocation());
} else if (type == PhaseChangeType.MELT) {
meltRadius = 1;
meltCooldown = getConfig().getLong("Abilities.Water.PhaseChange.Melt.Cooldown");
meltDelay = getConfig().getInt("Abilities.Water.PhaseChange.Melt.Delay")/night;
meltMaxRadius = night*getConfig().getInt("Abilities.Water.PhaseChange.Melt.Radius");
allowMeltFlow = getConfig().getBoolean("Abilities.Water.PhaseChange.Melt.AllowFlow");
/*} else if (type == PhaseChangeType.SKATE) {
if (bPlayer.isOnCooldown("PhaseChangeSkate")) {
return;
}
duration = night*getConfig().getLong("Abilities.Water.PhaseChange.Skate.Duration");
speed = night*getConfig().getDouble("Abilities.Water.PhaseChange.Skate.Speed");
skateCooldown = getConfig().getLong("Abilities.Water.PhaseChange.Skate.Cooldown");
skateRadius = night*getConfig().getInt("Abilities.Water.PhaseChange.Skate.Radius");
freezeArea(player.getLocation().clone().subtract(0, 1, 0), skateRadius, PhaseChangeType.SKATE);*/
}
}
/*public void displaySkateParticles() {
Location right = GeneralMethods.getRightSide(player.getLocation(), 0.3);
Location left = GeneralMethods.getLeftSide(player.getLocation(), 0.3);
ParticleEffect.SNOW_SHOVEL.display(right, 0, 0, 0, 0.00012F, 1);
ParticleEffect.SNOW_SHOVEL.display(left, 0, 0, 0, 0.00012F, 1);
}*/
public void resetMeltLocation(Location loc) {
if (meltLoc == null) {
meltLoc = loc;
return;
}
if (meltLoc.distance(loc) < 1) {
return;
}
if (!loc.equals(meltLoc)) {
meltLoc = loc;
meltRadius = 1;
}
}
public void freezeArea(Location center, int radius, PhaseChangeType type) {
if (type == PhaseChangeType.FREEZE) {
if (bPlayer.isOnCooldown("PhaseChangeFreeze")) {
return;
}
}
if (depth > 1) {
center.subtract(0, depth-1, 0);
}
for (Location l : GeneralMethods.getCircle(center, radius, depth, false, false, 0)) {
freeze(l.getBlock());
}
if (!blocks.isEmpty()) {
if (type == PhaseChangeType.FREEZE) {
bPlayer.addCooldown("PhaseChangeFreeze", freezeCooldown);
}
}
}
public void freezeArea(Location center, int radius) {
freezeArea(center, radius, PhaseChangeType.FREEZE);
}
public void freezeArea(Location center, PhaseChangeType type) {
freezeArea(center, freezeRadius, type);
}
public void freezeArea(Location center) {
freezeArea(center, freezeRadius);
}
public void freeze(Block b) {
if (b.getWorld() != player.getWorld()) {
return;
}
if (b.getLocation().distanceSquared(player.getLocation()) > controlRadius*controlRadius) {
return;
}
if (GeneralMethods.isRegionProtectedFromBuild(player, b.getLocation())) {
return;
}
if (!isWater(b)) {
return;
}
TempBlock tb = null;
if (TempBlock.isTempBlock(b)) {
tb = TempBlock.get(b);
if (melted_blocks.contains(tb.getBlock())) {
melted_blocks.remove(tb.getBlock());
}
tb.revertBlock();
}
if (tb == null) {
tb = new TempBlock(b, Material.ICE, (byte)0);
} else {
tb.setType(Material.ICE);
}
blocks.add(tb);
PLAYER_BY_BLOCK.put(tb, player);
}
public void meltArea(Location center, int radius) {
if (System.currentTimeMillis() < lastBlockTime + meltDelay) {
return;
}
List<Block> ice = new ArrayList<Block>();
for (Location l : GeneralMethods.getCircle(center, radius, 3, true, true, 0)) {
if (isIce(l.getBlock())) {
ice.add(l.getBlock());
}
}
lastBlockTime = System.currentTimeMillis();
if (ice.size() == 0) {
meltRadius++;
return;
}
Block b = ice.get(r.nextInt(ice.size()));
melt(b);
}
public void meltArea(Location center) {
meltArea(center, meltRadius);
}
public void melt(Block b) {
if (b.getWorld() != player.getWorld()) {
return;
}
if (b.getLocation().distanceSquared(player.getLocation()) > controlRadius*controlRadius) {
return;
}
if (GeneralMethods.isRegionProtectedFromBuild(player, b.getLocation())) {
return;
}
if (TempBlock.isTempBlock(b)) {
TempBlock tb = TempBlock.get(b);
if (!isIce(tb.getBlock())) {
return;
}
tb.revertBlock();
if (blocks.contains(tb)) {
blocks.remove(tb);
PLAYER_BY_BLOCK.remove(tb);
}
} else if (isWater(b)) {
//Figure out what to do here also
} else if (isIce(b)) {
Material m = allowMeltFlow ? Material.WATER : Material.STATIONARY_WATER;
b.setType(m);
melted_blocks.add(b);
}
}
/**
* Only works with PhaseChange frozen blocks!
* @param tb TempBlock being thawed
* @return true when it is thawed successfully
*/
public static boolean thaw(TempBlock tb) {
if (!PLAYER_BY_BLOCK.containsKey(tb)) {
return false;
} else {
Player p = PLAYER_BY_BLOCK.get(tb);
PhaseChange pc = getAbility(p, PhaseChange.class);
PLAYER_BY_BLOCK.remove(tb);
pc.getFrozenBlocks().remove(tb);
tb.revertBlock();
return true;
}
}
/**
* Only works if the block is a {#link TempBlock} and PhaseChange frozen!
* @param b Block being thawed
* @return false if not a {#link TempBlock}
*/
public static boolean thaw(Block b) {
if (!TempBlock.isTempBlock(b)) {
return false;
}
TempBlock tb = TempBlock.get(b);
return thaw(tb);
}
public static Map<TempBlock, Player> getFrozenBlocksMap() {
return PLAYER_BY_BLOCK;
}
public static List<TempBlock> getFrozenBlocksAsTempBlock() {
List<TempBlock> list = new ArrayList<>();
list.addAll(PLAYER_BY_BLOCK.keySet());
return list;
}
public static List<Block> getFrozenBlocksAsBlock() {
List<Block> list = new ArrayList<>();
for (TempBlock tb : PLAYER_BY_BLOCK.keySet()) {
Block b = tb.getBlock();
list.add(b);
}
return list;
}
public void revertFrozenBlocks() {
if (active_types.contains(PhaseChangeType.FREEZE)) {
for (TempBlock tb : blocks) {
tb.revertBlock();
}
blocks.clear();
PLAYER_BY_BLOCK.remove(player);
}
}
public void revertMeltedBlocks() {
if (active_types.contains(PhaseChangeType.MELT)) {
for (Block b : melted_blocks) {
if (TempBlock.isTempBlock(b)) {
TempBlock.get(b).revertBlock();
} else {
b.setType(Material.ICE);
}
}
melted_blocks.clear();
}
}
@Override
public void remove() {
super.remove();
revertFrozenBlocks();
revertMeltedBlocks();
}
@Override
public boolean isSneakAbility() {
return true;
}
@Override
public boolean isHarmlessAbility() {
return true;
}
@Override
public long getCooldown() {
return 0;
}
@Override
public String getName() {
return "PhaseChange";
}
@Override
public Location getLocation() {
return null;
}
public int getDepth() {
return depth;
}
public void setDepth(int value) {
depth = value;
}
public int getSourceRange() {
return sourceRange;
}
public void setSourceRange(int value) {
sourceRange = value;
}
public double getFreezeControlRadius() {
return controlRadius;
}
public int getMeltRadius() {
return meltRadius;
}
/*public int getSkateFreezeRadius() {
return skateRadius;
}*/
public void setFreezeControlRadius(int value) {
controlRadius = value;
}
public CopyOnWriteArrayList<TempBlock> getFrozenBlocks() {
return blocks;
}
public CopyOnWriteArrayList<Block> getMeltedBlocks() {
return melted_blocks;
}
public List<PhaseChangeType> getActiveTypes() {
return active_types;
}
}

View file

@ -1,261 +0,0 @@
package com.projectkorra.projectkorra.waterbending;
import com.projectkorra.projectkorra.BendingPlayer;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.ability.IceAbility;
import com.projectkorra.projectkorra.avatar.AvatarState;
import com.projectkorra.projectkorra.util.TempBlock;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class PhaseChangeFreeze extends IceAbility {
private static final Map<Block, Byte> FROZEN_BLOCKS = new ConcurrentHashMap<>();
private static final double REMOVE_RANGE = 50; // TODO: Make the remove range non static
private static boolean overloading = false;
private static int overloadingLimit = 0;
private static int overloadCounter = 200;
private double range;
private double radius;
private long cooldown;
private Location location;
public PhaseChangeFreeze(Player player) {
super(player);
if (!bPlayer.canBend(this) || !bPlayer.canIcebend() || bPlayer.isOnCooldown("PhaseChangeFreeze")) {
return;
}
this.range = getConfig().getDouble("Abilities.Water.PhaseChange.Range");
this.radius = getConfig().getDouble("Abilities.Water.PhaseChange.Radius");
this.cooldown = getConfig().getLong("Abilities.Water.PhaseChange.Freeze.Cooldown");
this.range = getNightFactor(range);
this.radius = getNightFactor(radius);
if (bPlayer.isAvatarState()) {
range = AvatarState.getValue(range);
}
location = GeneralMethods.getTargetedLocation(player, range);
start();
for (Block block : GeneralMethods.getBlocksAroundPoint(location, radius)) {
if (isFreezable(player, block)) {
freeze(player, block);
}
}
bPlayer.addCooldown("PhaseChangeFreeze", cooldown);
remove();
}
private static boolean isFreezable(Player player, Block block) {
if (GeneralMethods.isRegionProtectedFromBuild(player, "PhaseChange", block.getLocation())) {
return false;
}
return isWater(block) && WaterManipulation.canPhysicsChange(block) && !TempBlock.isTempBlock(block);
}
@SuppressWarnings("deprecation")
public static void freeze(Player player, Block block) {
if (GeneralMethods.isRegionProtectedFromBuild(player, "PhaseChange", block.getLocation())) {
return;
} else if (TempBlock.isTempBlock(block)) {
return;
}
byte data = block.getData();
block.setType(Material.ICE);
if(FROZEN_BLOCKS.size() % 50 == 0) {
playIcebendingSound(block.getLocation());
}
FROZEN_BLOCKS.put(block, data);
}
@SuppressWarnings("deprecation")
public static void thaw(Block block) {
if (FROZEN_BLOCKS.containsKey(block)) {
byte data = FROZEN_BLOCKS.get(block);
FROZEN_BLOCKS.remove(block);
block.setType(Material.WATER);
block.setData(data);
}
}
public static void handleFrozenBlocks() {
int size = FROZEN_BLOCKS.keySet().size();
overloadCounter++;
overloadCounter %= 10;
if (overloadCounter == 0) {
overloading = size > overloadingLimit ? true : false;
}
// We only want to run this method once every 10 ticks if we are overloading.
if (overloading && overloadCounter != 0) {
return;
}
if (overloading) {
int i = 0;
for (Block block : FROZEN_BLOCKS.keySet()) {
final Block fblock = block;
new BukkitRunnable() {
@Override
public void run() {
if (canThaw(fblock)) {
thaw(fblock);
}
}
}.runTaskLater(ProjectKorra.plugin, i % 10);
i++;
}
} else {
for (Block block : FROZEN_BLOCKS.keySet()) {
if (canThaw(block)) {
thaw(block);
}
}
}
}
public static boolean canThaw(Block block) {
if (FROZEN_BLOCKS.containsKey(block)) {
for (Player player : block.getWorld().getPlayers()) {
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
if (bPlayer == null || !player.isOnline()) {
continue;
}
if (bPlayer.getBoundAbilityName().equalsIgnoreCase("OctopusForm")) {
if (block.getWorld().equals(player.getWorld()) && block.getLocation().distance(player.getLocation()) <= REMOVE_RANGE + 2) {
return false;
}
}
if (bPlayer.canBendIgnoreBindsCooldowns(getAbility("PhaseChange"))) {
double range = getNightFactor(REMOVE_RANGE, player.getWorld());
if (bPlayer.isAvatarState()) {
range = AvatarState.getValue(range);
}
if (block.getLocation().distanceSquared(player.getLocation()) <= range * range) {
return false;
}
}
}
}
if (!WaterManipulation.canPhysicsChange(block)) {
return false;
}
return true;
}
@SuppressWarnings("deprecation")
public static void removeAllCleanup() {
for (Block block : FROZEN_BLOCKS.keySet()) {
if (block.getType() == Material.ICE) {
byte data = FROZEN_BLOCKS.get(block);
block.setType(Material.WATER);
block.setData(data);
FROZEN_BLOCKS.remove(block);
}
}
}
@Override
public String getName() {
return "PhaseChange";
}
@Override
public void progress() {}
@Override
public Location getLocation() {
return location;
}
@Override
public long getCooldown() {
return cooldown;
}
@Override
public boolean isSneakAbility() {
return true;
}
@Override
public boolean isHarmlessAbility() {
return false;
}
public static boolean isOverloading() {
return overloading;
}
public static void setOverloading(boolean overloading) {
PhaseChangeFreeze.overloading = overloading;
}
public static int getOverloadingLimit() {
return overloadingLimit;
}
public static void setOverloadingLimit(int overloadingLimit) {
PhaseChangeFreeze.overloadingLimit = overloadingLimit;
}
public static int getOverloadCounter() {
return overloadCounter;
}
public static void setOverloadCounter(int overloadCounter) {
PhaseChangeFreeze.overloadCounter = overloadCounter;
}
public double getRange() {
return range;
}
public void setRange(double range) {
this.range = range;
}
public double getRadius() {
return radius;
}
public void setRadius(double radius) {
this.radius = radius;
}
public static Map<Block, Byte> getFrozenBlocks() {
return FROZEN_BLOCKS;
}
public static double getRemoveRange() {
return REMOVE_RANGE;
}
public void setCooldown(long cooldown) {
this.cooldown = cooldown;
}
public void setLocation(Location location) {
this.location = location;
}
}

View file

@ -1,202 +0,0 @@
package com.projectkorra.projectkorra.waterbending;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.ability.IceAbility;
import com.projectkorra.projectkorra.avatar.AvatarState;
import com.projectkorra.projectkorra.util.TempBlock;
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.scheduler.BukkitRunnable;
import java.util.HashSet;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
public class PhaseChangeMelt extends IceAbility {
private static final List<Block> MELTED_BLOCKS = new CopyOnWriteArrayList<Block>();
private static final byte FULL = 0x0;
private int seaLevel;
private long cooldown;
private double range;
private double radius;
private double evaporateRadius;
private Location location;
public PhaseChangeMelt(Player player) {
super(player);
if (!bPlayer.canBend(this)) {
return;
}
this.seaLevel = getConfig().getInt("Properties.SeaLevel");
this.range = getConfig().getDouble("Abilities.Water.PhaseChange.Range");
this.radius = getConfig().getDouble("Abilities.Water.PhaseChange.Radius");
this.cooldown = getConfig().getLong("Abilities.Water.PhaseChange.Melt.Cooldown");
this.evaporateRadius = 3;
this.range = getNightFactor(range);
this.radius = getNightFactor(radius);
if (!bPlayer.canBend(this) || !bPlayer.canIcebend() || bPlayer.isOnCooldown("PhaseChangeMelt")) {
return;
}
if (bPlayer.isAvatarState()) {
range = AvatarState.getValue(range);
radius = AvatarState.getValue(radius);
}
boolean evaporate = false;
location = GeneralMethods.getTargetedLocation(player, range, 0, 8, 9);
if (isWater(player.getTargetBlock((HashSet<Material>) null, (int) range)) && player.getEyeLocation().getBlockY() > seaLevel) {
evaporate = true;
radius = (int) getNightFactor(evaporateRadius);
}
start();
for (Block block : GeneralMethods.getBlocksAroundPoint(location, radius)) {
if (evaporate && block.getY() > seaLevel) {
evaporate(player, block);
} else {
melt(player, block);
}
}
bPlayer.addCooldown("PhaseChangeMelt", cooldown);
remove();
}
@SuppressWarnings("deprecation")
public static void melt(Player player, final Block block) {
if (GeneralMethods.isRegionProtectedFromBuild(player, "PhaseChange", block.getLocation())) {
return;
} else if (!SurgeWave.canThaw(block)) {
SurgeWave.thaw(block);
return;
} else if (!Torrent.canThaw(block)) {
Torrent.thaw(block);
return;
} else if (WaterArmsSpear.canThaw(block)) {
WaterArmsSpear.thaw(block);
return;
}
WaterSpoutWave.thaw(block);
WaterCombo.thaw(block);
if (isMeltable(block) && !TempBlock.isTempBlock(block) && WaterManipulation.canPhysicsChange(block)) {
if (block.getType() == Material.SNOW) {
block.setType(Material.AIR);
return;
} else if (PhaseChangeFreeze.getFrozenBlocks().containsKey(block)) {
PhaseChangeFreeze.thaw(block);
} else {
MELTED_BLOCKS.add(block);
block.setType(Material.WATER);
block.setData(FULL);
new BukkitRunnable() {
@Override
public void run() {
MELTED_BLOCKS.remove(block);
block.setType(Material.ICE);
}
}.runTaskLater(ProjectKorra.plugin, 5 * 20 * 60);
}
}
}
public static void evaporate(Player player, Block block) {
if (GeneralMethods.isRegionProtectedFromBuild(player, "PhaseChange", block.getLocation())) {
return;
} else if (isWater(block) && !TempBlock.isTempBlock(block) && WaterManipulation.canPhysicsChange(block)) {
block.setType(Material.AIR);
block.getWorld().playEffect(block.getLocation(), Effect.SMOKE, 1);
}
}
public static void removeAllCleanup() {
for (Block b : MELTED_BLOCKS) {
b.setType(Material.ICE);
MELTED_BLOCKS.remove(b);
}
}
@Override
public String getName() {
return "PhaseChange";
}
@Override
public void progress() {
}
@Override
public Location getLocation() {
return location;
}
@Override
public long getCooldown() {
return cooldown;
}
@Override
public boolean isSneakAbility() {
return true;
}
@Override
public boolean isHarmlessAbility() {
return false;
}
public int getSeaLevel() {
return seaLevel;
}
public void setSeaLevel(int seaLevel) {
this.seaLevel = seaLevel;
}
public double getRange() {
return range;
}
public void setRange(double range) {
this.range = range;
}
public double getRadius() {
return radius;
}
public void setRadius(double radius) {
this.radius = radius;
}
public double getEvaporateRadius() {
return evaporateRadius;
}
public void setEvaporateRadius(double evaporateRadius) {
this.evaporateRadius = evaporateRadius;
}
public void setLocation(Location location) {
this.location = location;
}
public static List<Block> getMeltedBlocks() {
return MELTED_BLOCKS;
}
}

View file

@ -351,8 +351,8 @@ public class WaterManipulation extends WaterAbility {
if (!AFFECTED_BLOCKS.containsKey(block)) {
AFFECTED_BLOCKS.put(block, block);
}
if (PhaseChangeFreeze.getFrozenBlocks().containsKey(block)) {
PhaseChangeFreeze.getFrozenBlocks().remove(block);
if (PhaseChange.getFrozenBlocksAsBlock().contains(block)) {
PhaseChange.getFrozenBlocksAsBlock().remove(block);
}
block.setType(Material.STATIONARY_WATER);
block.setData((byte) 0);

View file

@ -13,7 +13,6 @@ public class WaterbendingManager implements Runnable {
@Override
public void run() {
WaterPassive.handlePassive();
PhaseChangeFreeze.handleFrozenBlocks();
Torrent.progressAllCleanup();
WaterArms.progressAllCleanup();
}