Various Fixes

* Fixed IceBlast Selection Bug

* Added KnockBack to WallOfFire

Also organized imports.

* Fixed WallOfFire Knockback

* Fixed Watermanip creating air pockets.

Also organized imports.

* Fixed surge wall removing leaves, also re-did my fix on WaterManipulation creating air pockets.

I thought I tested my fix for watermanipulation really well, but I
didn't test it as well as I thought, my bad. With my previous fix, it
fixed watermanip's air pockets, but it would create waterblocks if used
from a waterbottle, this is now fixed.

* Changed addWater to a non-static method, also changed player to non-static.

* Changed Extraction to be a metal ability.

* Fixed WaterManipulation for sure this time.

Sorry for all of the fails before, I would fix a problem, then another
one would arise. This has been test, and I haven't found any new issues,
and I have fixed the previous ones.
This commit is contained in:
Jay Stannon 2016-06-16 06:44:04 +10:00 committed by OmniCypher
parent 3ac4736e44
commit 91bb27882e
5 changed files with 82 additions and 69 deletions

View file

@ -1,7 +1,7 @@
package com.projectkorra.projectkorra.earthbending; package com.projectkorra.projectkorra.earthbending;
import com.projectkorra.projectkorra.GeneralMethods; import java.util.HashSet;
import com.projectkorra.projectkorra.ability.EarthAbility; import java.util.Random;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -9,10 +9,10 @@ import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import java.util.HashSet; import com.projectkorra.projectkorra.GeneralMethods;
import java.util.Random; import com.projectkorra.projectkorra.ability.MetalAbility;
public class Extraction extends EarthAbility { public class Extraction extends MetalAbility {
private int doubleChance; private int doubleChance;
private int tripleChance; private int tripleChance;

View file

@ -1,11 +1,8 @@
package com.projectkorra.projectkorra.firebending; package com.projectkorra.projectkorra.firebending;
import com.projectkorra.projectkorra.GeneralMethods; import java.util.ArrayList;
import com.projectkorra.projectkorra.ability.AirAbility; import java.util.List;
import com.projectkorra.projectkorra.ability.FireAbility; import java.util.Random;
import com.projectkorra.projectkorra.util.DamageHandler;
import com.projectkorra.projectkorra.util.ParticleEffect;
import com.projectkorra.projectkorra.util.TempBlock;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -14,9 +11,12 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import java.util.ArrayList; import com.projectkorra.projectkorra.GeneralMethods;
import java.util.List; import com.projectkorra.projectkorra.ability.AirAbility;
import java.util.Random; import com.projectkorra.projectkorra.ability.FireAbility;
import com.projectkorra.projectkorra.util.DamageHandler;
import com.projectkorra.projectkorra.util.ParticleEffect;
import com.projectkorra.projectkorra.util.TempBlock;
public class WallOfFire extends FireAbility { public class WallOfFire extends FireAbility {
@ -98,7 +98,7 @@ public class WallOfFire extends FireAbility {
AirAbility.breakBreathbendingHold(entity); AirAbility.breakBreathbendingHold(entity);
} }
entity.setFireTicks((int) (fireTicks * 20)); entity.setFireTicks((int) (fireTicks * 20));
GeneralMethods.setVelocity(entity, new Vector(0, 0, 0)); entity.setVelocity(player.getLocation().getDirection().multiply(1.4));
new FireDamageTimer(entity, player); new FireDamageTimer(entity, player);
} }

View file

@ -63,7 +63,7 @@ public class IceBlast extends IceAbility {
block(player); block(player);
range = getNightFactor(range, player.getWorld()); range = getNightFactor(range, player.getWorld());
Block sourceBlock = BlockSource.getWaterSourceBlock(player, range, ClickType.SHIFT_DOWN, false, true, false); Block sourceBlock = BlockSource.getWaterSourceBlock(player, range, ClickType.SHIFT_DOWN, false, true, false, false, false);
if (sourceBlock == null) { if (sourceBlock == null) {
return; return;

View file

@ -252,7 +252,7 @@ public class SurgeWall extends WaterAbility {
} else if (!blocks.contains(block) } else if (!blocks.contains(block)
&& (block.getType() == Material.AIR && (block.getType() == Material.AIR
|| block.getType() == Material.FIRE || block.getType() == Material.FIRE
|| isWaterbendable(block))) { || isWaterbendable(block)) && isTransparent(block)) {
WALL_BLOCKS.put(block, player); WALL_BLOCKS.put(block, player);
addWallBlock(block); addWallBlock(block);
blocks.add(block); blocks.add(block);

View file

@ -1,5 +1,18 @@
package com.projectkorra.projectkorra.waterbending; package com.projectkorra.projectkorra.waterbending;
import java.util.HashSet;
import java.util.Random;
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.BendingPlayer; import com.projectkorra.projectkorra.BendingPlayer;
import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ability.AirAbility; import com.projectkorra.projectkorra.ability.AirAbility;
@ -14,19 +27,6 @@ import com.projectkorra.projectkorra.util.DamageHandler;
import com.projectkorra.projectkorra.util.ParticleEffect; import com.projectkorra.projectkorra.util.ParticleEffect;
import com.projectkorra.projectkorra.util.TempBlock; 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.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import java.util.HashSet;
import java.util.Random;
import java.util.concurrent.ConcurrentHashMap;
public class WaterManipulation extends WaterAbility { public class WaterManipulation extends WaterAbility {
private static final ConcurrentHashMap<Block, Block> AFFECTED_BLOCKS = new ConcurrentHashMap<>(); private static final ConcurrentHashMap<Block, Block> AFFECTED_BLOCKS = new ConcurrentHashMap<>();
@ -142,7 +142,8 @@ public class WaterManipulation extends WaterAbility {
progressing = true; progressing = true;
settingUp = true; settingUp = true;
firstDestination = getToEyeLevel(); firstDestination = getToEyeLevel();
firstDirection = GeneralMethods.getDirection(sourceBlock.getLocation(), firstDestination).normalize(); firstDirection = GeneralMethods.getDirection(sourceBlock.getLocation(), firstDestination)
.normalize();
targetDestination = GeneralMethods.getPointOnLine(firstDestination, targetDestination, range); targetDestination = GeneralMethods.getPointOnLine(firstDestination, targetDestination, range);
targetDirection = GeneralMethods.getDirection(firstDestination, targetDestination).normalize(); targetDirection = GeneralMethods.getDirection(firstDestination, targetDestination).normalize();
@ -160,7 +161,8 @@ public class WaterManipulation extends WaterAbility {
} }
public boolean prepare() { public boolean prepare() {
Block block = BlockSource.getWaterSourceBlock(player, selectRange, ClickType.SHIFT_DOWN, true, true, bPlayer.canPlantbend()); Block block = BlockSource.getWaterSourceBlock(player, selectRange, ClickType.SHIFT_DOWN, true, true,
bPlayer.canPlantbend());
cancelPrevious(); cancelPrevious();
block(player); block(player);
@ -312,7 +314,8 @@ public class WaterManipulation extends WaterAbility {
trail = new TempBlock(sourceBlock, Material.STATIONARY_WATER, (byte) 1); trail = new TempBlock(sourceBlock, Material.STATIONARY_WATER, (byte) 1);
sourceBlock = block; sourceBlock = block;
if (location.distanceSquared(targetDestination) <= 1 || location.distanceSquared(firstDestination) > range * range) { if (location.distanceSquared(targetDestination) <= 1
|| location.distanceSquared(firstDestination) > range * range) {
falling = true; falling = true;
progressing = false; progressing = false;
} }
@ -356,18 +359,22 @@ public class WaterManipulation extends WaterAbility {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private static void addWater(Block block) { private static void addWater(Block block) {
if (!isWater(block)) {
if (!AFFECTED_BLOCKS.containsKey(block)) { if (!AFFECTED_BLOCKS.containsKey(block)) {
AFFECTED_BLOCKS.put(block, block); AFFECTED_BLOCKS.put(block, block);
} }
if (PhaseChangeFreeze.getFrozenBlocks().containsKey(block)) { if (PhaseChangeFreeze.getFrozenBlocks().containsKey(block)) {
PhaseChangeFreeze.getFrozenBlocks().remove(block); PhaseChangeFreeze.getFrozenBlocks().remove(block);
} }
if (isWater(block)) {
ParticleEffect.WATER_BUBBLE.display((float) Math.random(), (float) Math.random(),
(float) Math.random(), 0f, 5, block.getLocation().clone().add(.5,.5,.5), 257D);
}
block.setType(Material.STATIONARY_WATER); block.setType(Material.STATIONARY_WATER);
block.setData((byte) 0); block.setData((byte) 0);
} else {
if (isWater(block) && !AFFECTED_BLOCKS.containsKey(block)) {
ParticleEffect.WATER_BUBBLE.display((float) Math.random(), (float) Math.random(), (float) Math.random(), 0f,
5, block.getLocation().clone().add(.5, .5, .5), 257D);
}
}
} }
public static boolean annihilateBlasts(Location location, double radius, Player player) { public static boolean annihilateBlasts(Location location, double radius, Player player) {
@ -398,7 +405,8 @@ public class WaterManipulation extends WaterAbility {
Location mloc = manip.location; Location mloc = manip.location;
if (mloc.distanceSquared(location) <= manip.selectRange * manip.selectRange if (mloc.distanceSquared(location) <= manip.selectRange * manip.selectRange
&& GeneralMethods.getDistanceFromLine(vector, location, manip.location) < manip.deflectRange && GeneralMethods.getDistanceFromLine(vector, location, manip.location) < manip.deflectRange
&& mloc.distanceSquared(location.clone().add(vector)) < mloc.distanceSquared(location.clone().add(vector.clone().multiply(-1)))) { && mloc.distanceSquared(location.clone().add(vector)) < mloc
.distanceSquared(location.clone().add(vector.clone().multiply(-1)))) {
manip.remove(); manip.remove();
} }
} }
@ -463,7 +471,8 @@ public class WaterManipulation extends WaterAbility {
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
if (bPlayer == null) { if (bPlayer == null) {
return; return;
} if (bPlayer.isOnCooldown("WaterManipulation")) { }
if (bPlayer.isOnCooldown("WaterManipulation")) {
redirectTargettedBlasts(player); redirectTargettedBlasts(player);
return; return;
} }
@ -482,6 +491,9 @@ public class WaterManipulation extends WaterAbility {
if (!handledPrepare && WaterReturn.hasWaterBottle(player)) { if (!handledPrepare && WaterReturn.hasWaterBottle(player)) {
Location eyeLoc = player.getEyeLocation(); Location eyeLoc = player.getEyeLocation();
Block block = eyeLoc.add(eyeLoc.getDirection().normalize()).getBlock(); Block block = eyeLoc.add(eyeLoc.getDirection().normalize()).getBlock();
if (!AFFECTED_BLOCKS.containsKey(block)) {
AFFECTED_BLOCKS.put(block, block);
}
if (isTransparent(player, block) && isTransparent(player, eyeLoc.getBlock())) { if (isTransparent(player, block) && isTransparent(player, eyeLoc.getBlock())) {
if (getTargetLocation(player, range).distanceSquared(block.getLocation()) > 1) { if (getTargetLocation(player, range).distanceSquared(block.getLocation()) > 1) {
@ -520,7 +532,8 @@ public class WaterManipulation extends WaterAbility {
Location mloc = manip.location; Location mloc = manip.location;
if (mloc.distanceSquared(location) <= manip.selectRange * manip.selectRange if (mloc.distanceSquared(location) <= manip.selectRange * manip.selectRange
&& GeneralMethods.getDistanceFromLine(vector, location, manip.location) < manip.deflectRange && GeneralMethods.getDistanceFromLine(vector, location, manip.location) < manip.deflectRange
&& mloc.distanceSquared(location.clone().add(vector)) < mloc.distanceSquared(location.clone().add(vector.clone().multiply(-1)))) { && mloc.distanceSquared(location.clone().add(vector)) < mloc
.distanceSquared(location.clone().add(vector.clone().multiply(-1)))) {
manip.redirect(player, getTargetLocation(player, manip.selectRange)); manip.redirect(player, getTargetLocation(player, manip.selectRange));
} }
} }