mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2024-12-23 00:15:05 +00:00
Fix for Distance Bug in EarthGrab
This commit is contained in:
parent
3c41c611b9
commit
d35ce755b0
1 changed files with 12 additions and 16 deletions
|
@ -30,7 +30,6 @@ public class EarthGrab extends EarthAbility {
|
|||
private Vector dir;
|
||||
private Block groundBlock;
|
||||
private Material blockType;
|
||||
private Byte blockByte;
|
||||
private Random random;
|
||||
|
||||
public EarthGrab(Player player) {
|
||||
|
@ -45,7 +44,7 @@ public class EarthGrab extends EarthAbility {
|
|||
this.closestEntity = null;
|
||||
this.startLoc = player.getLocation();
|
||||
this.loc = player.getLocation();
|
||||
this.dir = player.getLocation().getDirection().clone().normalize().multiply(1.5);
|
||||
this.dir = player.getLocation().getDirection();
|
||||
this.random = new Random();
|
||||
|
||||
if (!bPlayer.canBend(this)) {
|
||||
|
@ -53,15 +52,14 @@ public class EarthGrab extends EarthAbility {
|
|||
}
|
||||
if(player.isSneaking()) {
|
||||
start();
|
||||
} else {
|
||||
}
|
||||
Location targetLocation = GeneralMethods.getTargetedLocation(player, 1);
|
||||
Block block = GeneralMethods.getTopBlock(targetLocation, 1, 1);
|
||||
if(isEarthbendable(block) && block.getLocation().distance(player.getLocation()) <= 1.3) {
|
||||
Block block = GeneralMethods.getTopBlock(targetLocation, 1);
|
||||
if(isEarthbendable(block) && block.getWorld().equals(player.getWorld()) && block.getLocation().distance(player.getLocation()) <= 2) {
|
||||
earthGrabSelf();
|
||||
remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void formDome() {
|
||||
|
||||
|
@ -115,7 +113,7 @@ public class EarthGrab extends EarthAbility {
|
|||
closestEntity = player;
|
||||
getGround();
|
||||
ParticleEffect.BLOCK_CRACK.display(
|
||||
(ParticleEffect.ParticleData) new ParticleEffect.BlockData(blockType, blockByte), 1F, 1F, 1F,
|
||||
(ParticleEffect.ParticleData) new ParticleEffect.BlockData(blockType, (byte) 0), 1F, 1F, 1F,
|
||||
0.1F, 100, player.getLocation(), 500);
|
||||
if (closestEntity != null) {
|
||||
ArrayList<Block> blocks = new ArrayList<Block>();
|
||||
|
@ -168,14 +166,12 @@ public class EarthGrab extends EarthAbility {
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
@ -189,7 +185,7 @@ public class EarthGrab extends EarthAbility {
|
|||
remove();
|
||||
return;
|
||||
}
|
||||
dir = dir.clone().normalize().multiply(1.5);
|
||||
dir = player.getLocation().getDirection().clone().normalize().multiply(1.5);
|
||||
dir.setY(0);
|
||||
double distance = loc.getY() - (double) groundBlock.getY();
|
||||
double dx = Math.abs(distance - 2.4);
|
||||
|
@ -202,7 +198,7 @@ public class EarthGrab extends EarthAbility {
|
|||
}
|
||||
loc.add(dir);
|
||||
ParticleEffect.BLOCK_CRACK.display(
|
||||
(ParticleEffect.ParticleData) new ParticleEffect.BlockData(blockType, blockByte), 1F, 0.1F, 1F,
|
||||
(ParticleEffect.ParticleData) new ParticleEffect.BlockData(blockType, (byte) 0), 1F, 0.1F, 1F,
|
||||
0.1F, 100, loc.add(0, -1, 0), 500);
|
||||
if(player.isDead() || !player.isOnline()) {
|
||||
remove();
|
||||
|
@ -212,7 +208,7 @@ public class EarthGrab extends EarthAbility {
|
|||
remove();
|
||||
return;
|
||||
}
|
||||
if(loc.distance(startLoc) >= selectRange) {
|
||||
if(loc.getWorld().equals(startLoc.getWorld()) && loc.distance(startLoc) >= selectRange) {
|
||||
remove();
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue