mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2024-12-22 16:05:01 +00:00
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:
parent
3ac4736e44
commit
91bb27882e
5 changed files with 82 additions and 69 deletions
|
@ -1,7 +1,7 @@
|
|||
package com.projectkorra.projectkorra.earthbending;
|
||||
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.ability.EarthAbility;
|
||||
import java.util.HashSet;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
|
@ -9,10 +9,10 @@ import org.bukkit.block.Block;
|
|||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Random;
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.ability.MetalAbility;
|
||||
|
||||
public class Extraction extends EarthAbility {
|
||||
public class Extraction extends MetalAbility {
|
||||
|
||||
private int doubleChance;
|
||||
private int tripleChance;
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
package com.projectkorra.projectkorra.firebending;
|
||||
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.ability.AirAbility;
|
||||
import com.projectkorra.projectkorra.ability.FireAbility;
|
||||
import com.projectkorra.projectkorra.util.DamageHandler;
|
||||
import com.projectkorra.projectkorra.util.ParticleEffect;
|
||||
import com.projectkorra.projectkorra.util.TempBlock;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
|
@ -14,9 +11,12 @@ import org.bukkit.entity.LivingEntity;
|
|||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.ability.AirAbility;
|
||||
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 {
|
||||
|
||||
|
@ -98,7 +98,7 @@ public class WallOfFire extends FireAbility {
|
|||
AirAbility.breakBreathbendingHold(entity);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ public class IceBlast extends IceAbility {
|
|||
|
||||
block(player);
|
||||
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) {
|
||||
return;
|
||||
|
|
|
@ -252,7 +252,7 @@ public class SurgeWall extends WaterAbility {
|
|||
} else if (!blocks.contains(block)
|
||||
&& (block.getType() == Material.AIR
|
||||
|| block.getType() == Material.FIRE
|
||||
|| isWaterbendable(block))) {
|
||||
|| isWaterbendable(block)) && isTransparent(block)) {
|
||||
WALL_BLOCKS.put(block, player);
|
||||
addWallBlock(block);
|
||||
blocks.add(block);
|
||||
|
|
|
@ -1,5 +1,18 @@
|
|||
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.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.ability.AirAbility;
|
||||
|
@ -14,23 +27,10 @@ import com.projectkorra.projectkorra.util.DamageHandler;
|
|||
import com.projectkorra.projectkorra.util.ParticleEffect;
|
||||
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 {
|
||||
|
||||
private static final ConcurrentHashMap<Block, Block> AFFECTED_BLOCKS = new ConcurrentHashMap<>();
|
||||
|
||||
|
||||
private boolean progressing;
|
||||
private boolean falling;
|
||||
private boolean settingUp;
|
||||
|
@ -55,10 +55,10 @@ public class WaterManipulation extends WaterAbility {
|
|||
private Vector firstDirection;
|
||||
private Vector targetDirection;
|
||||
private HashSet<Byte> waterTypes;
|
||||
|
||||
|
||||
public WaterManipulation(Player player) {
|
||||
super(player);
|
||||
|
||||
|
||||
this.progressing = false;
|
||||
this.falling = false;
|
||||
this.settingUp = false;
|
||||
|
@ -72,12 +72,12 @@ public class WaterManipulation extends WaterAbility {
|
|||
this.speed = getConfig().getDouble("Abilities.Water.WaterManipulation.Speed");
|
||||
this.deflectRange = getConfig().getDouble("Abilities.Water.WaterManipulation.DeflectRange");
|
||||
this.waterTypes = new HashSet<Byte>();
|
||||
|
||||
|
||||
this.interval = (long) (1000. / speed);
|
||||
this.waterTypes.add((byte) 0);
|
||||
this.waterTypes.add((byte) 8);
|
||||
this.waterTypes.add((byte) 9);
|
||||
|
||||
|
||||
if (prepare()) {
|
||||
prepared = true;
|
||||
start();
|
||||
|
@ -142,7 +142,8 @@ public class WaterManipulation extends WaterAbility {
|
|||
progressing = true;
|
||||
settingUp = true;
|
||||
firstDestination = getToEyeLevel();
|
||||
firstDirection = GeneralMethods.getDirection(sourceBlock.getLocation(), firstDestination).normalize();
|
||||
firstDirection = GeneralMethods.getDirection(sourceBlock.getLocation(), firstDestination)
|
||||
.normalize();
|
||||
targetDestination = GeneralMethods.getPointOnLine(firstDestination, targetDestination, range);
|
||||
targetDirection = GeneralMethods.getDirection(firstDestination, targetDestination).normalize();
|
||||
|
||||
|
@ -160,10 +161,11 @@ public class WaterManipulation extends WaterAbility {
|
|||
}
|
||||
|
||||
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();
|
||||
block(player);
|
||||
|
||||
|
||||
if (block != null) {
|
||||
sourceBlock = block;
|
||||
focusBlock();
|
||||
|
@ -194,7 +196,7 @@ public class WaterManipulation extends WaterAbility {
|
|||
sourceBlock.getWorld().playEffect(location, Effect.SMOKE, 4, (int) selectRange);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (sourceBlock.getLocation().distanceSquared(firstDestination) < 0.5 * 0.5) {
|
||||
settingUp = false;
|
||||
}
|
||||
|
@ -230,8 +232,8 @@ public class WaterManipulation extends WaterAbility {
|
|||
double radius = collisionRadius;
|
||||
Player source = player;
|
||||
if (!(location == null)) {
|
||||
if (EarthBlast.annihilateBlasts(location, radius, source)
|
||||
|| WaterManipulation.annihilateBlasts(location, radius, source)
|
||||
if (EarthBlast.annihilateBlasts(location, radius, source)
|
||||
|| WaterManipulation.annihilateBlasts(location, radius, source)
|
||||
|| FireBlast.annihilateBlasts(location, radius, source)) {
|
||||
remove();
|
||||
new WaterReturn(player, sourceBlock);
|
||||
|
@ -280,7 +282,7 @@ public class WaterManipulation extends WaterAbility {
|
|||
Location location = player.getEyeLocation();
|
||||
Vector vector = location.getDirection();
|
||||
entity.setVelocity(vector.normalize().multiply(pushFactor));
|
||||
|
||||
|
||||
if (bPlayer.isAvatarState()) {
|
||||
damage = AvatarState.getValue(damage);
|
||||
}
|
||||
|
@ -312,7 +314,8 @@ public class WaterManipulation extends WaterAbility {
|
|||
trail = new TempBlock(sourceBlock, Material.STATIONARY_WATER, (byte) 1);
|
||||
sourceBlock = block;
|
||||
|
||||
if (location.distanceSquared(targetDestination) <= 1 || location.distanceSquared(firstDestination) > range * range) {
|
||||
if (location.distanceSquared(targetDestination) <= 1
|
||||
|| location.distanceSquared(firstDestination) > range * range) {
|
||||
falling = true;
|
||||
progressing = false;
|
||||
}
|
||||
|
@ -356,18 +359,22 @@ public class WaterManipulation extends WaterAbility {
|
|||
|
||||
@SuppressWarnings("deprecation")
|
||||
private static void addWater(Block block) {
|
||||
if (!AFFECTED_BLOCKS.containsKey(block)) {
|
||||
AFFECTED_BLOCKS.put(block, block);
|
||||
if (!isWater(block)) {
|
||||
if (!AFFECTED_BLOCKS.containsKey(block)) {
|
||||
AFFECTED_BLOCKS.put(block, block);
|
||||
}
|
||||
if (PhaseChangeFreeze.getFrozenBlocks().containsKey(block)) {
|
||||
PhaseChangeFreeze.getFrozenBlocks().remove(block);
|
||||
}
|
||||
block.setType(Material.STATIONARY_WATER);
|
||||
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);
|
||||
}
|
||||
}
|
||||
if (PhaseChangeFreeze.getFrozenBlocks().containsKey(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.setData((byte) 0);
|
||||
|
||||
}
|
||||
|
||||
public static boolean annihilateBlasts(Location location, double radius, Player player) {
|
||||
|
@ -396,9 +403,10 @@ public class WaterManipulation extends WaterAbility {
|
|||
Location location = player.getEyeLocation();
|
||||
Vector vector = location.getDirection();
|
||||
Location mloc = manip.location;
|
||||
if (mloc.distanceSquared(location) <= manip.selectRange * manip.selectRange
|
||||
&& GeneralMethods.getDistanceFromLine(vector, location, manip.location) < manip.deflectRange
|
||||
&& mloc.distanceSquared(location.clone().add(vector)) < mloc.distanceSquared(location.clone().add(vector.clone().multiply(-1)))) {
|
||||
if (mloc.distanceSquared(location) <= manip.selectRange * manip.selectRange
|
||||
&& GeneralMethods.getDistanceFromLine(vector, location, manip.location) < manip.deflectRange
|
||||
&& mloc.distanceSquared(location.clone().add(vector)) < mloc
|
||||
.distanceSquared(location.clone().add(vector.clone().multiply(-1)))) {
|
||||
manip.remove();
|
||||
}
|
||||
}
|
||||
|
@ -449,7 +457,7 @@ public class WaterManipulation extends WaterAbility {
|
|||
private static Location getTargetLocation(Player player, double range) {
|
||||
Location location;
|
||||
Entity target = GeneralMethods.getTargetedEntity(player, range);
|
||||
|
||||
|
||||
if (target == null) {
|
||||
location = GeneralMethods.getTargetedLocation(player, range, getTransparentMaterial());
|
||||
} else {
|
||||
|
@ -463,7 +471,8 @@ public class WaterManipulation extends WaterAbility {
|
|||
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
|
||||
if (bPlayer == null) {
|
||||
return;
|
||||
} if (bPlayer.isOnCooldown("WaterManipulation")) {
|
||||
}
|
||||
if (bPlayer.isOnCooldown("WaterManipulation")) {
|
||||
redirectTargettedBlasts(player);
|
||||
return;
|
||||
}
|
||||
|
@ -478,16 +487,19 @@ public class WaterManipulation extends WaterAbility {
|
|||
waterManip.moveWater();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!handledPrepare && WaterReturn.hasWaterBottle(player)) {
|
||||
Location eyeLoc = player.getEyeLocation();
|
||||
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 (getTargetLocation(player, range).distanceSquared(block.getLocation()) > 1) {
|
||||
block.setType(Material.WATER);
|
||||
block.setData((byte) 0);
|
||||
|
||||
|
||||
WaterManipulation waterManip = new WaterManipulation(player);
|
||||
waterManip.moveWater();
|
||||
if (!waterManip.progressing) {
|
||||
|
@ -518,9 +530,10 @@ public class WaterManipulation extends WaterAbility {
|
|||
Location location = player.getEyeLocation();
|
||||
Vector vector = location.getDirection();
|
||||
Location mloc = manip.location;
|
||||
if (mloc.distanceSquared(location) <= manip.selectRange * manip.selectRange
|
||||
&& GeneralMethods.getDistanceFromLine(vector, location, manip.location) < manip.deflectRange
|
||||
&& mloc.distanceSquared(location.clone().add(vector)) < mloc.distanceSquared(location.clone().add(vector.clone().multiply(-1)))) {
|
||||
if (mloc.distanceSquared(location) <= manip.selectRange * manip.selectRange
|
||||
&& GeneralMethods.getDistanceFromLine(vector, location, manip.location) < manip.deflectRange
|
||||
&& mloc.distanceSquared(location.clone().add(vector)) < mloc
|
||||
.distanceSquared(location.clone().add(vector.clone().multiply(-1)))) {
|
||||
manip.redirect(player, getTargetLocation(player, manip.selectRange));
|
||||
}
|
||||
}
|
||||
|
@ -561,7 +574,7 @@ public class WaterManipulation extends WaterAbility {
|
|||
public long getCooldown() {
|
||||
return cooldown;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isSneakAbility() {
|
||||
return true;
|
||||
|
@ -635,11 +648,11 @@ public class WaterManipulation extends WaterAbility {
|
|||
public void setInterval(long interval) {
|
||||
this.interval = interval;
|
||||
}
|
||||
|
||||
|
||||
public double getRange() {
|
||||
return range;
|
||||
}
|
||||
|
||||
|
||||
public void setRange(double range) {
|
||||
this.range = range;
|
||||
}
|
||||
|
@ -763,5 +776,5 @@ public class WaterManipulation extends WaterAbility {
|
|||
public void setCollisionRadius(double collisionRadius) {
|
||||
this.collisionRadius = collisionRadius;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue