mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2024-12-22 16:05:01 +00:00
Fix Spout movement and Multiability/Combo loading (#588)
* Fix Spout movement and Multiability/Combo loading * Fix Spout movement * Fix Spout movement
This commit is contained in:
parent
aa2f4f51fa
commit
df273dce6e
3 changed files with 47 additions and 44 deletions
|
@ -300,8 +300,7 @@ public class PKListener implements Listener {
|
|||
|
||||
Block block = event.getBlock();
|
||||
|
||||
if (!WaterManipulation.canPhysicsChange(block) || !EarthPassive.canPhysicsChange(block)
|
||||
|| Illumination.getBlocks().containsKey(block) || EarthAbility.getPreventPhysicsBlocks().contains(block)) {
|
||||
if (!WaterManipulation.canPhysicsChange(block) || !EarthPassive.canPhysicsChange(block) || Illumination.getBlocks().containsKey(block) || EarthAbility.getPreventPhysicsBlocks().contains(block)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
@ -1089,22 +1088,22 @@ public class PKListener implements Listener {
|
|||
return;
|
||||
}
|
||||
|
||||
else if (CoreAbility.hasAbility(player, WaterSpout.class) || CoreAbility.hasAbility(player, AirSpout.class) || CoreAbility.hasAbility(player, SandSpout.class)) {
|
||||
Vector vel = new Vector();
|
||||
vel.setX(event.getTo().getX() - event.getFrom().getX());
|
||||
vel.setY(event.getTo().getY() - event.getFrom().getY());
|
||||
vel.setZ(event.getTo().getZ() - event.getFrom().getZ());
|
||||
// You now know the old velocity. Set to match recommended velocity
|
||||
double currspeed = vel.length();
|
||||
double maxspeed = .15;
|
||||
if (currspeed > maxspeed) {
|
||||
// only if moving set a factor
|
||||
vel = vel.normalize().multiply(maxspeed);
|
||||
// apply the new velocity (MAY REQUIRE A SCHEDULED TASK
|
||||
// INSTEAD!)
|
||||
event.getPlayer().setVelocity(vel);
|
||||
}
|
||||
}
|
||||
// else if (CoreAbility.hasAbility(player, WaterSpout.class) || CoreAbility.hasAbility(player, AirSpout.class) || CoreAbility.hasAbility(player, SandSpout.class)) {
|
||||
// Vector vel = new Vector();
|
||||
// vel.setX(event.getTo().getX() - event.getFrom().getX());
|
||||
// vel.setY(event.getTo().getY() - event.getFrom().getY());
|
||||
// vel.setZ(event.getTo().getZ() - event.getFrom().getZ());
|
||||
// // You now know the old velocity. Set to match recommended velocity
|
||||
// double currspeed = vel.length();
|
||||
// double maxspeed = .15;
|
||||
// if (currspeed > maxspeed) {
|
||||
// // only if moving set a factor
|
||||
// vel = vel.normalize().multiply(maxspeed);
|
||||
// // apply the new velocity (MAY REQUIRE A SCHEDULED TASK
|
||||
// // INSTEAD!)
|
||||
// event.getPlayer().setVelocity(vel);
|
||||
// }
|
||||
// }
|
||||
|
||||
else if (Bloodbending.isBloodbent(player)) {
|
||||
double distance1, distance2;
|
||||
|
|
|
@ -54,11 +54,11 @@ public class ProjectKorra extends JavaPlugin {
|
|||
|
||||
new ConfigManager();
|
||||
new GeneralMethods(this);
|
||||
CoreAbility.registerAbilities();
|
||||
updater = new Updater(this, "http://projectkorra.com/forum/forums/dev-builds.16/index.rss");
|
||||
new Commands(this);
|
||||
new MultiAbilityManager();
|
||||
new ComboManager();
|
||||
CoreAbility.registerAbilities();
|
||||
|
||||
Preset.loadExternalPresets();
|
||||
|
||||
|
|
|
@ -36,22 +36,22 @@ public class WaterSpout extends WaterAbility {
|
|||
private TempBlock baseBlock;
|
||||
private boolean canFly;
|
||||
private boolean hadFly;
|
||||
|
||||
|
||||
public WaterSpout(Player player) {
|
||||
super(player);
|
||||
|
||||
|
||||
WaterSpout oldSpout = getAbility(player, WaterSpout.class);
|
||||
if (oldSpout != null) {
|
||||
oldSpout.remove();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
this.canBendOnPackedIce = getConfig().getBoolean("Properties.Water.CanBendPackedIce");
|
||||
this.useParticles = getConfig().getBoolean("Abilities.Water.WaterSpout.Particles");
|
||||
this.useBlockSpiral = getConfig().getBoolean("Abilities.Water.WaterSpout.BlockSpiral");
|
||||
this.height = getConfig().getDouble("Abilities.Water.WaterSpout.Height");
|
||||
this.interval = getConfig().getLong("Abilities.Water.WaterSpout.Interval");
|
||||
|
||||
|
||||
hadFly = player.isFlying();
|
||||
canFly = player.getAllowFlight();
|
||||
maxHeight = getNightFactor(height);
|
||||
|
@ -60,22 +60,22 @@ public class WaterSpout extends WaterAbility {
|
|||
return;
|
||||
}
|
||||
|
||||
Block topBlock = GeneralMethods.getTopBlock(player.getLocation(), (int)-getNightFactor(height), (int)-getNightFactor(height));
|
||||
Block topBlock = GeneralMethods.getTopBlock(player.getLocation(), (int) -getNightFactor(height), (int) -getNightFactor(height));
|
||||
if (topBlock == null) {
|
||||
topBlock = player.getLocation().getBlock();
|
||||
}
|
||||
|
||||
|
||||
if (!isWater(topBlock) && !isIcebendable(topBlock) && !isSnow(topBlock)) {
|
||||
return;
|
||||
} 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();
|
||||
|
@ -90,13 +90,14 @@ public class WaterSpout extends WaterAbility {
|
|||
double height = 0;
|
||||
rotation += .4;
|
||||
int i = 0;
|
||||
|
||||
|
||||
while (height < maxHeight) {
|
||||
i += 20;
|
||||
height += .4;
|
||||
double angle = (i * Math.PI / 180);
|
||||
double x = 1 * Math.cos(angle + rotation);
|
||||
double z = 1 * Math.sin(angle + rotation);
|
||||
|
||||
Location loc = location.clone().getBlock().getLocation().add(.5, .5, .5);
|
||||
loc.add(x, height, z);
|
||||
|
||||
|
@ -121,11 +122,12 @@ public class WaterSpout extends WaterAbility {
|
|||
blocks.clear();
|
||||
player.setFallDistance(0);
|
||||
player.setSprinting(false);
|
||||
if ((new Random()).nextInt(4) == 0) {
|
||||
if ((new Random()).nextInt(10) == 0) {
|
||||
playWaterbendingSound(player.getLocation());
|
||||
}
|
||||
|
||||
player.removePotionEffect(PotionEffectType.SPEED);
|
||||
|
||||
Location location = player.getLocation().clone().add(0, .2, 0);
|
||||
Block block = location.clone().getBlock();
|
||||
double height = spoutableWaterHeight(location);
|
||||
|
@ -137,17 +139,17 @@ public class WaterSpout extends WaterAbility {
|
|||
remove();
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 1; i <= height; i++) {
|
||||
|
||||
block = location.clone().add(0, i, 0).getBlock();
|
||||
|
||||
|
||||
if (!TempBlock.isTempBlock(block)) {
|
||||
blocks.add(new TempBlock(block, Material.STATIONARY_WATER, (byte) 8));
|
||||
AFFECTED_BLOCKS.put(block, block);
|
||||
}
|
||||
rotateParticles(block);
|
||||
}
|
||||
|
||||
|
||||
displayWaterSpiral(location.clone().add(.5, 0, .5));
|
||||
if (player.getLocation().getBlockY() > block.getY()) {
|
||||
player.setFlying(false);
|
||||
|
@ -174,14 +176,14 @@ 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;
|
||||
|
@ -203,13 +205,14 @@ public class WaterSpout extends WaterAbility {
|
|||
|
||||
Location location = block.getLocation();
|
||||
Location playerLoc = player.getLocation();
|
||||
|
||||
location = new Location(location.getWorld(), playerLoc.getX(), location.getY(), playerLoc.getZ());
|
||||
|
||||
double dy = playerLoc.getY() - block.getY();
|
||||
if (dy > height) {
|
||||
dy = height;
|
||||
}
|
||||
|
||||
|
||||
float[] directions = { -0.5f, 0.325f, 0.25f, 0.125f, 0.f, 0.125f, 0.25f, 0.325f, 0.5f };
|
||||
int index = angle;
|
||||
angle++;
|
||||
|
@ -233,29 +236,30 @@ public class WaterSpout extends WaterAbility {
|
|||
if (isNight(player.getWorld())) {
|
||||
newHeight = getNightFactor(newHeight);
|
||||
}
|
||||
|
||||
|
||||
this.maxHeight = newHeight + 5;
|
||||
Block blocki;
|
||||
|
||||
|
||||
for (int i = 0; i < maxHeight; i++) {
|
||||
|
||||
blocki = location.clone().add(0, -i, 0).getBlock();
|
||||
if (GeneralMethods.isRegionProtectedFromBuild(this, blocki.getLocation())) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
if (!blocks.contains(blocki)) {
|
||||
if (isWater(blocki)) {
|
||||
if (!TempBlock.isTempBlock(blocki)) {
|
||||
revertBaseBlock();
|
||||
}
|
||||
|
||||
|
||||
base = blocki;
|
||||
if (i > newHeight) {
|
||||
return newHeight;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
if (isIcebendable(blocki) || isSnow(blocki)) {
|
||||
if (isIcebendable(blocki)) {
|
||||
if (blocki.getType() == Material.PACKED_ICE && !canBendOnPackedIce) {
|
||||
|
@ -263,19 +267,19 @@ public class WaterSpout extends WaterAbility {
|
|||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!TempBlock.isTempBlock(blocki)) {
|
||||
revertBaseBlock();
|
||||
baseBlock = new TempBlock(blocki, Material.STATIONARY_WATER, (byte) 8);
|
||||
}
|
||||
|
||||
|
||||
base = blocki;
|
||||
if (i > newHeight) {
|
||||
return newHeight;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
if ((blocki.getType() != Material.AIR && (!isPlant(blocki) || !bPlayer.canPlantbend()))) {
|
||||
revertBaseBlock();
|
||||
return -1;
|
||||
|
@ -328,7 +332,7 @@ public class WaterSpout extends WaterAbility {
|
|||
public boolean isHarmlessAbility() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public boolean isCanBendOnPackedIce() {
|
||||
return canBendOnPackedIce;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue