make airsuction work on self

This commit is contained in:
PhanaticD 2019-01-03 05:19:56 -05:00
parent 89de7a3a36
commit 8b2ec63bcb

View file

@ -1,10 +1,14 @@
package com.projectkorra.projectkorra.airbending; package com.projectkorra.projectkorra.airbending;
import java.util.ArrayList; import com.projectkorra.projectkorra.GeneralMethods;
import java.util.Arrays; import com.projectkorra.projectkorra.ProjectKorra;
import java.util.List; import com.projectkorra.projectkorra.ability.AirAbility;
import java.util.Random; import com.projectkorra.projectkorra.ability.CoreAbility;
import com.projectkorra.projectkorra.ability.util.Collision;
import com.projectkorra.projectkorra.attribute.Attribute;
import com.projectkorra.projectkorra.command.Commands;
import com.projectkorra.projectkorra.object.HorizontalVelocityTracker;
import com.projectkorra.projectkorra.waterbending.WaterSpout;
import org.bukkit.Effect; import org.bukkit.Effect;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -16,15 +20,10 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import com.projectkorra.projectkorra.GeneralMethods; import java.util.ArrayList;
import com.projectkorra.projectkorra.ProjectKorra; import java.util.Arrays;
import com.projectkorra.projectkorra.ability.AirAbility; import java.util.List;
import com.projectkorra.projectkorra.ability.CoreAbility; import java.util.Random;
import com.projectkorra.projectkorra.ability.util.Collision;
import com.projectkorra.projectkorra.attribute.Attribute;
import com.projectkorra.projectkorra.command.Commands;
import com.projectkorra.projectkorra.object.HorizontalVelocityTracker;
import com.projectkorra.projectkorra.waterbending.WaterSpout;
public class AirSuction extends AirAbility { public class AirSuction extends AirAbility {
@ -193,7 +192,6 @@ public class AirSuction extends AirAbility {
} }
for (final Entity entity : GeneralMethods.getEntitiesAroundPoint(this.location, this.radius)) { for (final Entity entity : GeneralMethods.getEntitiesAroundPoint(this.location, this.radius)) {
if (entity.getEntityId() != this.player.getEntityId()) {
if (entity instanceof Player) { if (entity instanceof Player) {
if (GeneralMethods.isRegionProtectedFromBuild(this, entity.getLocation()) || Commands.invincible.contains(((Player) entity).getName())){ if (GeneralMethods.isRegionProtectedFromBuild(this, entity.getLocation()) || Commands.invincible.contains(((Player) entity).getName())){
continue; continue;
@ -204,7 +202,7 @@ public class AirSuction extends AirAbility {
final Vector push = this.direction.clone(); final Vector push = this.direction.clone();
double factor = this.pushFactor; double factor = this.pushFactor;
if (Math.abs(push.getY()) > max && entity.getEntityId() != this.player.getEntityId()) { if (Math.abs(push.getY()) > max) {
if (push.getY() < 0) { if (push.getY() < 0) {
push.setY(-max); push.setY(-max);
} else { } else {
@ -226,16 +224,10 @@ public class AirSuction extends AirAbility {
velocity.add(push.clone().multiply(factor * .5)); velocity.add(push.clone().multiply(factor * .5));
} }
if (entity instanceof Player) {
if (Commands.invincible.contains(((Player) entity).getName())) {
continue;
}
}
GeneralMethods.setVelocity(entity, velocity); GeneralMethods.setVelocity(entity, velocity);
new HorizontalVelocityTracker(entity, this.player, 200l, this); new HorizontalVelocityTracker(entity, this.player, 200l, this);
entity.setFallDistance(0); entity.setFallDistance(0);
if (entity.getEntityId() != this.player.getEntityId() && entity instanceof Player) { if (entity instanceof Player) {
flightHandler.createInstance((Player) entity, this.player, 5000L, this.getName()); flightHandler.createInstance((Player) entity, this.player, 5000L, this.getName());
} }
@ -245,7 +237,6 @@ public class AirSuction extends AirAbility {
entity.setFireTicks(0); entity.setFireTicks(0);
breakBreathbendingHold(entity); breakBreathbendingHold(entity);
} }
}
this.advanceLocation(); this.advanceLocation();
} else { } else {