mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2024-12-22 16:05:01 +00:00
Spout Max Height, RaiseEarth Config Options (#507)
* Fix NPE in OctopusForm * Spouts now cannot be created above max height * Improve RaiseEarth width config option
This commit is contained in:
parent
2907952ca2
commit
2d648641f1
4 changed files with 80 additions and 9 deletions
|
@ -39,6 +39,11 @@ public class AirSpout extends AirAbility {
|
|||
this.interval = getConfig().getLong("Abilities.Air.AirSpout.Interval");
|
||||
this.height = getConfig().getDouble("Abilities.Air.AirSpout.Height");
|
||||
|
||||
double heightRemoveThreshold = 2;
|
||||
if (!isWithinMaxSpoutHeight(heightRemoveThreshold)) {
|
||||
return;
|
||||
}
|
||||
|
||||
new Flight(player);
|
||||
start();
|
||||
bPlayer.addCooldown(this);
|
||||
|
@ -69,6 +74,18 @@ public class AirSpout extends AirAbility {
|
|||
player.setAllowFlight(true);
|
||||
player.setFlying(true);
|
||||
}
|
||||
|
||||
private boolean isWithinMaxSpoutHeight(double threshold) {
|
||||
Block ground = getGround();
|
||||
if (ground == null) {
|
||||
return false;
|
||||
}
|
||||
double playerHeight = player.getLocation().getY();
|
||||
if (playerHeight > ground.getLocation().getY() + height + threshold) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private Block getGround() {
|
||||
Block standingblock = player.getLocation().getBlock();
|
||||
|
@ -83,12 +100,16 @@ public class AirSpout extends AirAbility {
|
|||
|
||||
@Override
|
||||
public void progress() {
|
||||
if (player.isDead() || !player.isOnline() || !bPlayer.canBendIgnoreBindsCooldowns(this)) {
|
||||
if (player.isDead()
|
||||
|| !player.isOnline()
|
||||
|| !bPlayer.canBendIgnoreBindsCooldowns(this)
|
||||
|| !bPlayer.canBind(this)) {
|
||||
remove();
|
||||
return;
|
||||
}
|
||||
|
||||
if(!bPlayer.canBind(this)) {
|
||||
|
||||
double heightRemoveThreshold = 2;
|
||||
if (!isWithinMaxSpoutHeight(heightRemoveThreshold)) {
|
||||
remove();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -38,12 +38,14 @@ public class RaiseEarthWall extends EarthAbility {
|
|||
|
||||
Vector direction = player.getEyeLocation().getDirection().normalize();
|
||||
double ox, oy, oz;
|
||||
direction.setY(0);
|
||||
ox = -direction.getZ();
|
||||
oy = 0;
|
||||
oz = direction.getX();
|
||||
|
||||
|
||||
Vector orth = new Vector(ox, oy, oz);
|
||||
orth = orth.normalize();
|
||||
orth = getDegreeRoundedVector(orth, 0.25);
|
||||
|
||||
Block sblock = BlockSource.getEarthSourceBlock(player, selectRange, ClickType.SHIFT_DOWN);
|
||||
|
||||
|
@ -56,8 +58,9 @@ public class RaiseEarthWall extends EarthAbility {
|
|||
World world = location.getWorld();
|
||||
boolean shouldAddCooldown = false;
|
||||
|
||||
for (int i = -width / 2; i <= width / 2; i++) {
|
||||
Block block = world.getBlockAt(location.clone().add(orth.clone().multiply((double) i)));
|
||||
for (int i = 0; i < width; i++) {
|
||||
double adjustedI = i - width / 2.0;
|
||||
Block block = world.getBlockAt(location.clone().add(orth.clone().multiply(adjustedI)));
|
||||
|
||||
if (isTransparent(block)) {
|
||||
for (int j = 1; j < height; j++) {
|
||||
|
@ -89,6 +92,30 @@ public class RaiseEarthWall extends EarthAbility {
|
|||
bPlayer.addCooldown("RaiseEarthWall", cooldown);
|
||||
}
|
||||
}
|
||||
|
||||
private static Vector getDegreeRoundedVector(Vector vec, double degreeIncrement) {
|
||||
if (vec == null) {
|
||||
return null;
|
||||
}
|
||||
vec = vec.normalize();
|
||||
double[] dims = {vec.getX(), vec.getY(), vec.getZ()};
|
||||
|
||||
for (int i = 0; i < dims.length; i++) {
|
||||
double dim = dims[i];
|
||||
int sign = dim >= 0 ? 1 : -1;
|
||||
int dimDivIncr = (int)(dim / degreeIncrement);
|
||||
|
||||
double lowerBound = dimDivIncr * degreeIncrement;
|
||||
double upperBound = (dimDivIncr + (1 * sign)) * degreeIncrement;
|
||||
|
||||
if (Math.abs(dim - lowerBound) < Math.abs(dim - upperBound)) {
|
||||
dims[i] = lowerBound;
|
||||
} else {
|
||||
dims[i] = upperBound;
|
||||
}
|
||||
}
|
||||
return new Vector(dims[0], dims[1], dims[2]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
|
|
|
@ -53,7 +53,7 @@ public class TempBlock {
|
|||
}
|
||||
|
||||
public static boolean isTempBlock(Block block) {
|
||||
return instances.containsKey(block);
|
||||
return block != null ? instances.containsKey(block) : false;
|
||||
}
|
||||
|
||||
public static boolean isTouchingTempBlock(Block block) {
|
||||
|
|
|
@ -67,7 +67,12 @@ public class WaterSpout extends WaterAbility {
|
|||
} else if (topBlock.getType() == Material.PACKED_ICE && !canBendOnPackedIce) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
double heightRemoveThreshold = 2;
|
||||
if (!isWithinMaxSpoutHeight(topBlock.getLocation(), heightRemoveThreshold)) {
|
||||
return;
|
||||
}
|
||||
|
||||
new Flight(player);
|
||||
player.setAllowFlight(true);
|
||||
start();
|
||||
|
@ -124,6 +129,12 @@ public class WaterSpout extends WaterAbility {
|
|||
|
||||
if (height != -1) {
|
||||
location = base.getLocation();
|
||||
double heightRemoveThreshold = 2;
|
||||
if (!isWithinMaxSpoutHeight(location, heightRemoveThreshold)) {
|
||||
remove();
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 1; i <= height; i++) {
|
||||
block = location.clone().add(0, i, 0).getBlock();
|
||||
|
||||
|
@ -160,13 +171,25 @@ public class WaterSpout extends WaterAbility {
|
|||
player.setAllowFlight(canFly);
|
||||
player.setFlying(hadFly);
|
||||
}
|
||||
|
||||
|
||||
public void revertBaseBlock() {
|
||||
if (baseBlock != null) {
|
||||
baseBlock.revertBlock();
|
||||
baseBlock = null;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isWithinMaxSpoutHeight(Location baseBlockLocation, double threshold) {
|
||||
if (baseBlockLocation == null) {
|
||||
return false;
|
||||
}
|
||||
double playerHeight = player.getLocation().getY();
|
||||
double maxHeight = isNight(player.getWorld()) ? getNightFactor(height) : height;
|
||||
if (playerHeight > baseBlockLocation.getY() + maxHeight + threshold) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void rotateParticles(Block block) {
|
||||
if (!useParticles) {
|
||||
|
|
Loading…
Reference in a new issue