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:
Christopher Martin 2016-10-04 16:29:01 -07:00 committed by GitHub
parent aa2f4f51fa
commit df273dce6e
3 changed files with 47 additions and 44 deletions

View file

@ -300,8 +300,7 @@ public class PKListener implements Listener {
Block block = event.getBlock(); Block block = event.getBlock();
if (!WaterManipulation.canPhysicsChange(block) || !EarthPassive.canPhysicsChange(block) if (!WaterManipulation.canPhysicsChange(block) || !EarthPassive.canPhysicsChange(block) || Illumination.getBlocks().containsKey(block) || EarthAbility.getPreventPhysicsBlocks().contains(block)) {
|| Illumination.getBlocks().containsKey(block) || EarthAbility.getPreventPhysicsBlocks().contains(block)) {
event.setCancelled(true); event.setCancelled(true);
} }
@ -1089,22 +1088,22 @@ public class PKListener implements Listener {
return; return;
} }
else if (CoreAbility.hasAbility(player, WaterSpout.class) || CoreAbility.hasAbility(player, AirSpout.class) || CoreAbility.hasAbility(player, SandSpout.class)) { // else if (CoreAbility.hasAbility(player, WaterSpout.class) || CoreAbility.hasAbility(player, AirSpout.class) || CoreAbility.hasAbility(player, SandSpout.class)) {
Vector vel = new Vector(); // Vector vel = new Vector();
vel.setX(event.getTo().getX() - event.getFrom().getX()); // vel.setX(event.getTo().getX() - event.getFrom().getX());
vel.setY(event.getTo().getY() - event.getFrom().getY()); // vel.setY(event.getTo().getY() - event.getFrom().getY());
vel.setZ(event.getTo().getZ() - event.getFrom().getZ()); // vel.setZ(event.getTo().getZ() - event.getFrom().getZ());
// You now know the old velocity. Set to match recommended velocity // // You now know the old velocity. Set to match recommended velocity
double currspeed = vel.length(); // double currspeed = vel.length();
double maxspeed = .15; // double maxspeed = .15;
if (currspeed > maxspeed) { // if (currspeed > maxspeed) {
// only if moving set a factor // // only if moving set a factor
vel = vel.normalize().multiply(maxspeed); // vel = vel.normalize().multiply(maxspeed);
// apply the new velocity (MAY REQUIRE A SCHEDULED TASK // // apply the new velocity (MAY REQUIRE A SCHEDULED TASK
// INSTEAD!) // // INSTEAD!)
event.getPlayer().setVelocity(vel); // event.getPlayer().setVelocity(vel);
} // }
} // }
else if (Bloodbending.isBloodbent(player)) { else if (Bloodbending.isBloodbent(player)) {
double distance1, distance2; double distance1, distance2;

View file

@ -54,11 +54,11 @@ public class ProjectKorra extends JavaPlugin {
new ConfigManager(); new ConfigManager();
new GeneralMethods(this); new GeneralMethods(this);
CoreAbility.registerAbilities();
updater = new Updater(this, "http://projectkorra.com/forum/forums/dev-builds.16/index.rss"); updater = new Updater(this, "http://projectkorra.com/forum/forums/dev-builds.16/index.rss");
new Commands(this); new Commands(this);
new MultiAbilityManager(); new MultiAbilityManager();
new ComboManager(); new ComboManager();
CoreAbility.registerAbilities();
Preset.loadExternalPresets(); Preset.loadExternalPresets();

View file

@ -36,22 +36,22 @@ public class WaterSpout extends WaterAbility {
private TempBlock baseBlock; private TempBlock baseBlock;
private boolean canFly; private boolean canFly;
private boolean hadFly; private boolean hadFly;
public WaterSpout(Player player) { public WaterSpout(Player player) {
super(player); super(player);
WaterSpout oldSpout = getAbility(player, WaterSpout.class); WaterSpout oldSpout = getAbility(player, WaterSpout.class);
if (oldSpout != null) { if (oldSpout != null) {
oldSpout.remove(); oldSpout.remove();
return; return;
} }
this.canBendOnPackedIce = getConfig().getBoolean("Properties.Water.CanBendPackedIce"); this.canBendOnPackedIce = getConfig().getBoolean("Properties.Water.CanBendPackedIce");
this.useParticles = getConfig().getBoolean("Abilities.Water.WaterSpout.Particles"); this.useParticles = getConfig().getBoolean("Abilities.Water.WaterSpout.Particles");
this.useBlockSpiral = getConfig().getBoolean("Abilities.Water.WaterSpout.BlockSpiral"); this.useBlockSpiral = getConfig().getBoolean("Abilities.Water.WaterSpout.BlockSpiral");
this.height = getConfig().getDouble("Abilities.Water.WaterSpout.Height"); this.height = getConfig().getDouble("Abilities.Water.WaterSpout.Height");
this.interval = getConfig().getLong("Abilities.Water.WaterSpout.Interval"); this.interval = getConfig().getLong("Abilities.Water.WaterSpout.Interval");
hadFly = player.isFlying(); hadFly = player.isFlying();
canFly = player.getAllowFlight(); canFly = player.getAllowFlight();
maxHeight = getNightFactor(height); maxHeight = getNightFactor(height);
@ -60,22 +60,22 @@ public class WaterSpout extends WaterAbility {
return; 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) { if (topBlock == null) {
topBlock = player.getLocation().getBlock(); topBlock = player.getLocation().getBlock();
} }
if (!isWater(topBlock) && !isIcebendable(topBlock) && !isSnow(topBlock)) { if (!isWater(topBlock) && !isIcebendable(topBlock) && !isSnow(topBlock)) {
return; return;
} else if (topBlock.getType() == Material.PACKED_ICE && !canBendOnPackedIce) { } else if (topBlock.getType() == Material.PACKED_ICE && !canBendOnPackedIce) {
return; return;
} }
double heightRemoveThreshold = 2; double heightRemoveThreshold = 2;
if (!isWithinMaxSpoutHeight(topBlock.getLocation(), heightRemoveThreshold)) { if (!isWithinMaxSpoutHeight(topBlock.getLocation(), heightRemoveThreshold)) {
return; return;
} }
new Flight(player); new Flight(player);
player.setAllowFlight(true); player.setAllowFlight(true);
start(); start();
@ -90,13 +90,14 @@ public class WaterSpout extends WaterAbility {
double height = 0; double height = 0;
rotation += .4; rotation += .4;
int i = 0; int i = 0;
while (height < maxHeight) { while (height < maxHeight) {
i += 20; i += 20;
height += .4; height += .4;
double angle = (i * Math.PI / 180); double angle = (i * Math.PI / 180);
double x = 1 * Math.cos(angle + rotation); double x = 1 * Math.cos(angle + rotation);
double z = 1 * Math.sin(angle + rotation); double z = 1 * Math.sin(angle + rotation);
Location loc = location.clone().getBlock().getLocation().add(.5, .5, .5); Location loc = location.clone().getBlock().getLocation().add(.5, .5, .5);
loc.add(x, height, z); loc.add(x, height, z);
@ -121,11 +122,12 @@ public class WaterSpout extends WaterAbility {
blocks.clear(); blocks.clear();
player.setFallDistance(0); player.setFallDistance(0);
player.setSprinting(false); player.setSprinting(false);
if ((new Random()).nextInt(4) == 0) { if ((new Random()).nextInt(10) == 0) {
playWaterbendingSound(player.getLocation()); playWaterbendingSound(player.getLocation());
} }
player.removePotionEffect(PotionEffectType.SPEED); player.removePotionEffect(PotionEffectType.SPEED);
Location location = player.getLocation().clone().add(0, .2, 0); Location location = player.getLocation().clone().add(0, .2, 0);
Block block = location.clone().getBlock(); Block block = location.clone().getBlock();
double height = spoutableWaterHeight(location); double height = spoutableWaterHeight(location);
@ -137,17 +139,17 @@ public class WaterSpout extends WaterAbility {
remove(); remove();
return; return;
} }
for (int i = 1; i <= height; i++) { for (int i = 1; i <= height; i++) {
block = location.clone().add(0, i, 0).getBlock(); block = location.clone().add(0, i, 0).getBlock();
if (!TempBlock.isTempBlock(block)) { if (!TempBlock.isTempBlock(block)) {
blocks.add(new TempBlock(block, Material.STATIONARY_WATER, (byte) 8)); blocks.add(new TempBlock(block, Material.STATIONARY_WATER, (byte) 8));
AFFECTED_BLOCKS.put(block, block); AFFECTED_BLOCKS.put(block, block);
} }
rotateParticles(block); rotateParticles(block);
} }
displayWaterSpiral(location.clone().add(.5, 0, .5)); displayWaterSpiral(location.clone().add(.5, 0, .5));
if (player.getLocation().getBlockY() > block.getY()) { if (player.getLocation().getBlockY() > block.getY()) {
player.setFlying(false); player.setFlying(false);
@ -174,14 +176,14 @@ public class WaterSpout extends WaterAbility {
player.setAllowFlight(canFly); player.setAllowFlight(canFly);
player.setFlying(hadFly); player.setFlying(hadFly);
} }
public void revertBaseBlock() { public void revertBaseBlock() {
if (baseBlock != null) { if (baseBlock != null) {
baseBlock.revertBlock(); baseBlock.revertBlock();
baseBlock = null; baseBlock = null;
} }
} }
private boolean isWithinMaxSpoutHeight(Location baseBlockLocation, double threshold) { private boolean isWithinMaxSpoutHeight(Location baseBlockLocation, double threshold) {
if (baseBlockLocation == null) { if (baseBlockLocation == null) {
return false; return false;
@ -203,13 +205,14 @@ public class WaterSpout extends WaterAbility {
Location location = block.getLocation(); Location location = block.getLocation();
Location playerLoc = player.getLocation(); Location playerLoc = player.getLocation();
location = new Location(location.getWorld(), playerLoc.getX(), location.getY(), playerLoc.getZ()); location = new Location(location.getWorld(), playerLoc.getX(), location.getY(), playerLoc.getZ());
double dy = playerLoc.getY() - block.getY(); double dy = playerLoc.getY() - block.getY();
if (dy > height) { if (dy > height) {
dy = height; dy = height;
} }
float[] directions = { -0.5f, 0.325f, 0.25f, 0.125f, 0.f, 0.125f, 0.25f, 0.325f, 0.5f }; float[] directions = { -0.5f, 0.325f, 0.25f, 0.125f, 0.f, 0.125f, 0.25f, 0.325f, 0.5f };
int index = angle; int index = angle;
angle++; angle++;
@ -233,29 +236,30 @@ public class WaterSpout extends WaterAbility {
if (isNight(player.getWorld())) { if (isNight(player.getWorld())) {
newHeight = getNightFactor(newHeight); newHeight = getNightFactor(newHeight);
} }
this.maxHeight = newHeight + 5; this.maxHeight = newHeight + 5;
Block blocki; Block blocki;
for (int i = 0; i < maxHeight; i++) { for (int i = 0; i < maxHeight; i++) {
blocki = location.clone().add(0, -i, 0).getBlock(); blocki = location.clone().add(0, -i, 0).getBlock();
if (GeneralMethods.isRegionProtectedFromBuild(this, blocki.getLocation())) { if (GeneralMethods.isRegionProtectedFromBuild(this, blocki.getLocation())) {
return -1; return -1;
} }
if (!blocks.contains(blocki)) { if (!blocks.contains(blocki)) {
if (isWater(blocki)) { if (isWater(blocki)) {
if (!TempBlock.isTempBlock(blocki)) { if (!TempBlock.isTempBlock(blocki)) {
revertBaseBlock(); revertBaseBlock();
} }
base = blocki; base = blocki;
if (i > newHeight) { if (i > newHeight) {
return newHeight; return newHeight;
} }
return i; return i;
} }
if (isIcebendable(blocki) || isSnow(blocki)) { if (isIcebendable(blocki) || isSnow(blocki)) {
if (isIcebendable(blocki)) { if (isIcebendable(blocki)) {
if (blocki.getType() == Material.PACKED_ICE && !canBendOnPackedIce) { if (blocki.getType() == Material.PACKED_ICE && !canBendOnPackedIce) {
@ -263,19 +267,19 @@ public class WaterSpout extends WaterAbility {
return -1; return -1;
} }
} }
if (!TempBlock.isTempBlock(blocki)) { if (!TempBlock.isTempBlock(blocki)) {
revertBaseBlock(); revertBaseBlock();
baseBlock = new TempBlock(blocki, Material.STATIONARY_WATER, (byte) 8); baseBlock = new TempBlock(blocki, Material.STATIONARY_WATER, (byte) 8);
} }
base = blocki; base = blocki;
if (i > newHeight) { if (i > newHeight) {
return newHeight; return newHeight;
} }
return i; return i;
} }
if ((blocki.getType() != Material.AIR && (!isPlant(blocki) || !bPlayer.canPlantbend()))) { if ((blocki.getType() != Material.AIR && (!isPlant(blocki) || !bPlayer.canPlantbend()))) {
revertBaseBlock(); revertBaseBlock();
return -1; return -1;
@ -328,7 +332,7 @@ public class WaterSpout extends WaterAbility {
public boolean isHarmlessAbility() { public boolean isHarmlessAbility() {
return true; return true;
} }
public boolean isCanBendOnPackedIce() { public boolean isCanBendOnPackedIce() {
return canBendOnPackedIce; return canBendOnPackedIce;
} }