PhaseChange

This commit is contained in:
MistPhizzle 2014-06-25 12:48:05 -04:00
parent 867f0acd12
commit 8c60f64623
7 changed files with 255 additions and 28 deletions

View file

@ -28,6 +28,7 @@ import com.projectkorra.ProjectKorra.firebending.FireJet;
import com.projectkorra.ProjectKorra.firebending.FirePassive;
import com.projectkorra.ProjectKorra.firebending.FireStream;
import com.projectkorra.ProjectKorra.waterbending.Bloodbending;
import com.projectkorra.ProjectKorra.waterbending.FreezeMelt;
import com.projectkorra.ProjectKorra.waterbending.Plantbending;
import com.projectkorra.ProjectKorra.waterbending.WaterPassive;
import com.projectkorra.ProjectKorra.waterbending.WaterSpout;
@ -76,6 +77,7 @@ public class BendingManager implements Runnable {
AirSpout.spoutAll();
WaterSpout.handleSpouts(Bukkit.getServer());
Cook.progressAll();
FreezeMelt.handleFrozenBlocks();
for (int ID: Tornado.instances.keySet()) {
Tornado.progress(ID);
}

View file

@ -126,6 +126,19 @@ public class ConfigManager {
config.addDefault("Abilities.Water.Bloodbending.ThrowFactor", 2);
config.addDefault("Abilities.Water.Bloodbending.Range", 10);
config.addDefault("Abilities.Water.PhaseChange.Enabled", true);
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.PhaseChange.Range", 20);
config.addDefault("Abilities.Water.PhaseChange.Radius", 5);
plugin.getConfig().addDefault("Abilities.Water.Plantbending.RegrowTime", 180000);
config.addDefault("Abilities.Water.WaterSpout.Enabled", true);

View file

@ -35,6 +35,7 @@ import com.projectkorra.ProjectKorra.Ability.AbilityModuleManager;
import com.projectkorra.ProjectKorra.Ability.AvatarState;
import com.projectkorra.ProjectKorra.earthbending.EarthColumn;
import com.projectkorra.ProjectKorra.earthbending.EarthPassive;
import com.projectkorra.ProjectKorra.waterbending.FreezeMelt;
import com.projectkorra.ProjectKorra.waterbending.WaterCore;
public class Methods {

View file

@ -13,6 +13,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockFadeEvent;
import org.bukkit.event.block.BlockFormEvent;
import org.bukkit.event.block.BlockFromToEvent;
@ -61,6 +62,8 @@ import com.projectkorra.ProjectKorra.firebending.Extinguish;
import com.projectkorra.ProjectKorra.firebending.FireJet;
import com.projectkorra.ProjectKorra.firebending.FireStream;
import com.projectkorra.ProjectKorra.waterbending.Bloodbending;
import com.projectkorra.ProjectKorra.waterbending.FreezeMelt;
import com.projectkorra.ProjectKorra.waterbending.Melt;
import com.projectkorra.ProjectKorra.waterbending.WaterCore;
import com.projectkorra.ProjectKorra.waterbending.WaterPassive;
import com.projectkorra.ProjectKorra.waterbending.WaterSpout;
@ -168,11 +171,12 @@ public class PKListener implements Listener {
if (abil.equalsIgnoreCase("Bloodbending")) {
new Bloodbending(player);
}
if (abil.equalsIgnoreCase("WaterSpout")) {
new WaterSpout(player);
if (abil.equalsIgnoreCase("PhaseChange")) {
new Melt(player);
}
}
if (Methods.isEarthAbility(abil)) {
if (Methods.isWeapon(player.getItemInHand().getType()) && !plugin.getConfig().getBoolean("Properties.Earth.CanBendWithWeapons")) {
return;
@ -184,7 +188,7 @@ public class PKListener implements Listener {
new Collapse(player);
}
}
if (Methods.isFireAbility(abil)) {
if (Methods.isWeapon(player.getItemInHand().getType()) && !plugin.getConfig().getBoolean("Properties.Fire.CanBendWithWeapons")) {
return;
@ -203,7 +207,7 @@ public class PKListener implements Listener {
event.setCancelled(true);
return;
}
if (WaterSpout.instances.containsKey(event.getPlayer()) || AirSpout.getPlayers().contains(event.getPlayer())) {
Vector vel = new Vector();
vel.setX(event.getTo().getX() - event.getFrom().getX());
@ -213,13 +217,13 @@ public class PKListener implements Listener {
double currspeed = vel.length();
double maxspeed = .15;
if (currspeed > maxspeed) {
// only if moving set a factor
// double recspeed = 0.6;
// vel = vel.ultiply(recspeed * currspeed);
vel = vel.normalize().multiply(maxspeed);
// apply the new velocity (MAY REQUIRE A SCHEDULED TASK
// INSTEAD!)
event.getPlayer().setVelocity(vel);
// only if moving set a factor
// double recspeed = 0.6;
// vel = vel.ultiply(recspeed * currspeed);
vel = vel.normalize().multiply(maxspeed);
// apply the new velocity (MAY REQUIRE A SCHEDULED TASK
// INSTEAD!)
event.getPlayer().setVelocity(vel);
}
}
@ -340,8 +344,14 @@ public class PKListener implements Listener {
if (abil.equalsIgnoreCase("Bloodbending")) {
Bloodbending.launch(player);
}
if (abil.equalsIgnoreCase("PhaseChange")) {
new FreezeMelt(player);
}
if (abil.equalsIgnoreCase("WaterSpout")) {
new WaterSpout(player);
}
}
if (Methods.isEarthAbility(abil)) {
if (Methods.isWeapon(player.getItemInHand().getType()) && !plugin.getConfig().getBoolean("Properties.Earth.CanBendWithWeapons")) {
return;
@ -349,11 +359,11 @@ public class PKListener implements Listener {
if (abil.equalsIgnoreCase("Catapult")) {
new Catapult(player);
}
if (abil.equalsIgnoreCase("RaiseEarth")) {
new EarthColumn(player);
}
if (abil.equalsIgnoreCase("Collapse")) {
new CompactColumn(player);
}
@ -362,7 +372,7 @@ public class PKListener implements Listener {
if (Methods.isWeapon(player.getItemInHand().getType()) && !plugin.getConfig().getBoolean("Properties.Fire.CanBendWithWeapons")) {
return;
}
if (abil.equalsIgnoreCase("FireJet")) {
new FireJet(player);
}
@ -411,10 +421,64 @@ public class PKListener implements Listener {
if (block.getType() == Material.FIRE) {
return;
}
event.setCancelled(Illumination.blocks.containsKey(block));
if (!event.isCancelled()) {
event.setCancelled(!WaterManipulation.canPhysicsChange(block));
}
if (!event.isCancelled()) {
event.setCancelled(FreezeMelt.frozenblocks.containsKey(block));
}
if (!event.isCancelled()) {
event.setCancelled(!Wave.canThaw(block));
}
if (!event.isCancelled()) {
event.setCancelled(!Torrent.canThaw(block));
}
if (FireStream.ignitedblocks.containsKey(block)) {
FireStream.remove(block);
}
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) {
Block block = event.getBlock();
Player player = event.getPlayer();
if (WaterWall.wasBrokenFor(player, block)
|| OctopusForm.wasBrokenFor(player, block)
|| Torrent.wasBrokenFor(player, block)) {
event.setCancelled(true);
return;
}
EarthBlast blast = EarthBlast.getBlastFromSource(block);
if (blast != null) {
blast.cancel();
}
if (FreezeMelt.frozenblocks.containsKey(block)) {
FreezeMelt.thaw(block);
event.setCancelled(true);
// } else if (!WalkOnWater.canThaw(block)) {
// WalkOnWater.thaw(block);
} else if (WaterWall.wallblocks.containsKey(block)) {
WaterWall.thaw(block);
event.setCancelled(true);
} else if (Illumination.blocks.containsKey(block)) {
event.setCancelled(true);
// } else if (Illumination.blocks.containsKey(block
// .getRelative(BlockFace.UP))) {
// event.setCancelled(true);
} else if (!Wave.canThaw(block)) {
Wave.thaw(block);
event.setCancelled(true);
// event.setCancelled(true);
} else if (Methods.movedearth.containsKey(block)) {
// Methods.removeEarthbendedBlockIndex(block);
Methods.removeRevertIndex(block);
} else if (TempBlock.isTempBlock(block)) {
TempBlock.revertBlock(block, Material.AIR);
}
}
@EventHandler
public void onPlayerDamageByPlayer(EntityDamageByEntityEvent e) {
Entity en = e.getEntity();

View file

@ -0,0 +1,141 @@
package com.projectkorra.ProjectKorra.waterbending;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import com.projectkorra.ProjectKorra.Methods;
import com.projectkorra.ProjectKorra.ProjectKorra;
import com.projectkorra.ProjectKorra.TempBlock;
import com.projectkorra.ProjectKorra.Ability.AvatarState;
public class FreezeMelt {
public static ConcurrentHashMap<Block, Byte> frozenblocks = new ConcurrentHashMap<Block, Byte>();
public static final int defaultrange = ProjectKorra.plugin.getConfig().getInt("Abilities.Water.PhaseChange.Range");
public static final int defaultradius = ProjectKorra.plugin.getConfig().getInt("Abilities.Water.PhaseChange.Radius");
public FreezeMelt(Player player) {
// BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
//
// if (bPlayer.isOnCooldown(Abilities.PhaseChange))
// return;
int range = (int) Methods.waterbendingNightAugment(defaultrange,
player.getWorld());
int radius = (int) Methods.waterbendingNightAugment(defaultradius,
player.getWorld());
if (AvatarState.isAvatarState(player)) {
range = AvatarState.getValue(range);
// radius = AvatarState.getValue(radius);
}
boolean cooldown = false;
Location location = Methods.getTargetedLocation(player, range);
for (Block block : Methods.getBlocksAroundPoint(location, radius)) {
if (isFreezable(player, block)) {
freeze(player, block);
cooldown = true;
}
}
//
// if (cooldown)
// bPlayer.cooldown(Abilities.PhaseChange);
}
private static boolean isFreezable(Player player, Block block) {
if (Methods.isRegionProtectedFromBuild(player, Abilities.PhaseChange,
block.getLocation()))
return false;
if (block.getType() == Material.WATER
|| block.getType() == Material.STATIONARY_WATER)
if (WaterManipulation.canPhysicsChange(block)
&& !TempBlock.isTempBlock(block))
return true;
return false;
}
static void freeze(Player player, Block block) {
// if (Methods.isRegionProtectedFromBuild(player, Abilities.PhaseChange,
// block.getLocation()))
// return;
if (TempBlock.isTempBlock(block))
return;
byte data = block.getData();
block.setType(Material.ICE);
frozenblocks.put(block, data);
}
public static void thaw(Block block) {
if (frozenblocks.containsKey(block)) {
byte data = frozenblocks.get(block);
frozenblocks.remove(block);
block.setType(Material.WATER);
block.setData(data);
}
}
public static void handleFrozenBlocks() {
for (Block block : frozenblocks.keySet()) {
if (canThaw(block))
thaw(block);
}
}
public static boolean canThaw(Block block) {
if (frozenblocks.containsKey(block)) {
for (Player player : block.getWorld().getPlayers()) {
if (Methods.getBoundAbility(player) != null && Methods.getBoundAbility(player).equalsIgnoreCase("OctopusForm")) {
if (block.getLocation().distance(player.getLocation()) <= OctopusForm.radius + 2)
return false;
}
if (Methods.canBend(player.getName(), "PhaseChange")) {
double range = Methods.waterbendingNightAugment(defaultrange,
player.getWorld());
if (AvatarState.isAvatarState(player)) {
range = AvatarState.getValue(range);
}
if (block.getLocation().distance(player.getLocation()) <= range)
return false;
}
}
}
if (!WaterManipulation.canPhysicsChange(block))
return false;
return true;
}
private static void thawAll() {
for (Block block : frozenblocks.keySet()) {
if (block.getType() == Material.ICE) {
byte data = frozenblocks.get(block);
block.setType(Material.WATER);
block.setData(data);
frozenblocks.remove(block);
}
}
}
public static void removeAll() {
thawAll();
}
public static String getDescription() {
return "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. ";
}
}

View file

@ -7,6 +7,7 @@ import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import com.projectkorra.ProjectKorra.Methods;
import com.projectkorra.ProjectKorra.ProjectKorra;
import com.projectkorra.ProjectKorra.TempBlock;
import com.projectkorra.ProjectKorra.Ability.AvatarState;
@ -15,15 +16,15 @@ public class Melt {
private static final int defaultrange = FreezeMelt.defaultrange;
private static final int defaultradius = FreezeMelt.defaultradius;
private static final int defaultevaporateradius = 3;
private static final int seaLevel = ConfigManager.seaLevel;
private static final int seaLevel = ProjectKorra.plugin.getConfig().getInt("Properties.SeaLevel");
private static final byte full = 0x0;
public Melt(Player player) {
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
if (bPlayer.isOnCooldown(Abilities.PhaseChange))
return;
// BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
//
// if (bPlayer.isOnCooldown(Abilities.PhaseChange))
// return;
int range = (int) Methods.waterbendingNightAugment(defaultrange,
player.getWorld());
@ -51,13 +52,13 @@ public class Melt {
}
}
bPlayer.cooldown(Abilities.PhaseChange);
// bPlayer.cooldown(Abilities.PhaseChange);
}
public static void melt(Player player, Block block) {
if (Methods.isRegionProtectedFromBuild(player, Abilities.PhaseChange,
block.getLocation()))
return;
// if (Methods.isRegionProtectedFromBuild(player, Abilities.PhaseChange,
// block.getLocation()))
// return;
if (!Wave.canThaw(block)) {
Wave.thaw(block);
return;
@ -82,9 +83,9 @@ public class Melt {
}
public static void evaporate(Player player, Block block) {
if (Methods.isRegionProtectedFromBuild(player, Abilities.PhaseChange,
block.getLocation()))
return;
// if (Methods.isRegionProtectedFromBuild(player, Abilities.PhaseChange,
// block.getLocation()))
// return;
if (Methods.isWater(block) && !TempBlock.isTempBlock(block)
&& WaterManipulation.canPhysicsChange(block)) {
block.setType(Material.AIR);

View file

@ -78,6 +78,11 @@ Abilities:
Description: "This ability was made illegal for a reason. With this ability selected, sneak while targeting something and you will bloodbend that target. Bloodbent targets cannot move, bend, or attack. You are free to control their actions by looking elsewhere - they will be forced to move in that direciton. Additionally, clicking while bloodbending will launch that target off in the direction you're looking. People who are capable of bloodbending are immune to technique, and you are immune to theirs.";
ThrowFactor: 2
Range: 10
PhaseChange:
Enabled: true
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 things 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 targeting water with FreezeMelt, it will evaporate water around that block that is above sea level."
Range: 20
Radius: 5
Plantbending:
RegrowTime: 180000
WaterSpout: