diff --git a/pom.xml b/pom.xml index 66c3f59..3b4999e 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 me.simplicitee projectaddons - 1.2.0 + 1.2.1 ProjectAddons diff --git a/src/me/simplicitee/project/addons/Util.java b/src/me/simplicitee/project/addons/Util.java index ff02870..6881354 100644 --- a/src/me/simplicitee/project/addons/Util.java +++ b/src/me/simplicitee/project/addons/Util.java @@ -10,6 +10,8 @@ private Util() {} private static String[] lightning = {"e6efef", "03d2d2", "33e6ff", "03d2d2", "03d2d2", "33e6ff", "03d2d2", "33e6ff", "33e6ff"}; + public static final String LEAF_COLOR = "48B518"; + public static void playLightningParticles(Location loc, int amount, double xOff, double yOff, double zOff) { int i = (int) Math.round(Math.random() * (lightning.length - 1)); GeneralMethods.displayColoredParticle(lightning[i], loc, amount, xOff, yOff, zOff); diff --git a/src/me/simplicitee/project/addons/ability/air/Deafen.java b/src/me/simplicitee/project/addons/ability/air/Deafen.java index e2a57be..87f030d 100644 --- a/src/me/simplicitee/project/addons/ability/air/Deafen.java +++ b/src/me/simplicitee/project/addons/ability/air/Deafen.java @@ -3,7 +3,6 @@ import org.bukkit.Instrument; import org.bukkit.Location; import org.bukkit.Note; -import org.bukkit.Sound; import org.bukkit.Note.Tone; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -66,8 +65,6 @@ public void progress() { for (int i = 0; i < 2; i++) { target.playNote(target.getEyeLocation().add(new Vector(Math.random(), Math.random(), Math.random())), Instrument.BASS_GUITAR, Note.sharp(i, Tone.F)); - target.playNote(target.getEyeLocation().add(new Vector(Math.random(), Math.random(), Math.random())), Instrument.PLING, Note.sharp(i, Tone.F)); - target.playNote(target.getEyeLocation().add(new Vector(Math.random(), Math.random(), Math.random())), Instrument.FLUTE, Note.sharp(i, Tone.F)); } } diff --git a/src/me/simplicitee/project/addons/ability/fire/ArcSpark.java b/src/me/simplicitee/project/addons/ability/fire/ArcSpark.java index 298be69..5c86b5e 100644 --- a/src/me/simplicitee/project/addons/ability/fire/ArcSpark.java +++ b/src/me/simplicitee/project/addons/ability/fire/ArcSpark.java @@ -34,7 +34,7 @@ public class ArcSpark extends LightningAbility implements AddonAbility { private long cooldown; private long charge, chargedTill; - private boolean shoot, charged; + private boolean shoot, charged, left; private List attractive; public ArcSpark(Player player) { @@ -72,7 +72,7 @@ public void progress() { chargedTill = System.currentTimeMillis(); player.getWorld().playSound(player.getEyeLocation(), Sound.ENTITY_CREEPER_PRIMED, 0.05f, 0.5f); } else if (charged && !shoot) { - Util.playLightningParticles(GeneralMethods.getMainHandLocation(player), 1, 0.001, 0.001, 0.001); + Util.playLightningParticles(player.getEyeLocation().add(player.getLocation().getDirection().multiply(1.3)), 1, 0.001, 0.001, 0.001); chargedTill = System.currentTimeMillis(); player.getWorld().playSound(player.getEyeLocation(), Sound.ENTITY_CREEPER_PRIMED, 0.05f, 0.5f); } else if (charged && shoot) { @@ -81,16 +81,89 @@ public void progress() { return; } - Location hand = GeneralMethods.getMainHandLocation(player); + Location hand = left ? GeneralMethods.getLeftSide(player.getLocation(), 0.55).add(0, 1.2, 0) : GeneralMethods.getRightSide(player.getLocation(), 0.55).add(0, 1.2, 0); + left = !left; hand.setDirection(player.getEyeLocation().getDirection()); - Arc arc = new Arc(hand); - for (int i = 0; i < speed*length; i++) { - arc.run(this); + boolean persist = true; + for (int i = 0; i < speed*length && persist; ++i) { + persist = arc(hand); } } } + private boolean arc(Location loc) { + double shortest = Double.MAX_VALUE; + Entity closest = null; + Location to = null; + for (Entity e : GeneralMethods.getEntitiesAroundPoint(loc, 3)) { + if (!(e instanceof LivingEntity) || e.getEntityId() == player.getEntityId()) { + continue; + } + + double dist = loc.distance(e.getLocation().clone().add(0, 1, 0)); + + if (dist <= 1) { + DamageHandler.damageEntity(e, damage, this); + return false; + } else { + if (dist < shortest || closest == null) { + shortest = dist; + closest = e; + to = e.getLocation().clone().add(0, 1, 0); + } + } + } + + if (closest == null) { + for (Block b : GeneralMethods.getBlocksAroundPoint(loc, 2)) { + if (b.isPassable() || !attractive.contains(b.getType().toString())) { + continue; + } + + Location center = b.getLocation().add(0.5, 0.5, 0.5); + double dist = loc.distance(center); + + if (dist < shortest) { + shortest = dist; + to = center; + } + } + } + + Vector movement = null; + + if (to != null) { + movement = GeneralMethods.getDirection(loc, to); + } else { + movement = new Vector(Math.random() / 5 - 0.1, Math.random() / 5 - 0.1, Math.random() / 5 - 0.1); + } + + double angle = movement.angle(loc.getDirection()); + if (angle < 60 && angle > -60) { + loc.setDirection(loc.getDirection().add(movement)); + } + + loc.getDirection().normalize(); + loc.add(loc.getDirection().multiply(0.3)); + + if (loc.getBlock().getType() == Material.WATER || attractive.contains(loc.getBlock().getType().toString())) { + if (Math.random() > 0.55) { + new Electrify(player, loc.getBlock(), false); + } + return false; + } else if (!loc.getBlock().isPassable()) { + return false; + } + + Util.playLightningParticles(loc, 1, 0, 0, 0); + if (Math.random() < 0.15) { + playLightningbendingSound(loc); + } + + return true; + } + @Override public void remove() { super.remove(); @@ -160,91 +233,4 @@ public String getInstructions() { public String getDescription() { return "Shoots arcs of electricity in the direction you are looking, and the arcs are attracted to some blocks and entities! Hitting a metallic block or water will cause it to become electrified!"; } - - class Arc { - - private boolean progressing = true; - private Location loc; - - public Arc(Location loc) { - this.loc = loc; - } - - public void run(ArcSpark a) { - if (!progressing) { - return; - } - - double shortest = Double.MAX_VALUE; - Entity closest = null; - Location to = null; - for (Entity e : GeneralMethods.getEntitiesAroundPoint(loc, 3)) { - if (!(e instanceof LivingEntity) || e.getEntityId() == player.getEntityId()) { - continue; - } - - double dist = loc.distance(e.getLocation().clone().add(0, 1, 0)); - - if (dist <= 1) { - DamageHandler.damageEntity(e, damage, a); - progressing = false; - return; - } else { - if (dist < shortest || closest == null) { - shortest = dist; - closest = e; - to = e.getLocation().clone().add(0, 1, 0); - } - } - } - - if (closest == null) { - for (Block b : GeneralMethods.getBlocksAroundPoint(loc, 2)) { - if (b.isPassable() || !attractive.contains(b.getType().toString())) { - continue; - } - - Location center = b.getLocation().add(0.5, 0.5, 0.5); - double dist = loc.distance(center); - - if (dist < shortest) { - shortest = dist; - to = center; - } - } - } - - Vector movement = null; - - if (to != null) { - movement = GeneralMethods.getDirection(loc, to); - } else { - movement = new Vector(Math.random() / 5 - 0.1, Math.random() / 5 - 0.1, Math.random() / 5 - 0.1); - } - - double angle = movement.angle(loc.getDirection()); - if (angle < 60 && angle > -60) { - loc.setDirection(loc.getDirection().add(movement)); - } - - loc.getDirection().normalize(); - loc.add(loc.getDirection().multiply(0.3)); - - if (loc.getBlock().getType() == Material.WATER || attractive.contains(loc.getBlock().getType().toString())) { - if (Math.random() > 0.55) { - new Electrify(player, loc.getBlock(), false); - } - progressing = false; - return; - } else if (!loc.getBlock().isPassable()) { - progressing = false; - return; - } - - Util.playLightningParticles(loc, 1, 0, 0, 0); - if (Math.random() < 0.15) { - playLightningbendingSound(loc); - } - } - } } diff --git a/src/me/simplicitee/project/addons/ability/fire/CombustBeam.java b/src/me/simplicitee/project/addons/ability/fire/CombustBeam.java index 50a43f4..f5a52f5 100644 --- a/src/me/simplicitee/project/addons/ability/fire/CombustBeam.java +++ b/src/me/simplicitee/project/addons/ability/fire/CombustBeam.java @@ -137,7 +137,7 @@ public void progress() { Vector to = player.getEyeLocation().getDirection().clone().normalize().multiply(0.3); if (Math.abs(direction.angle(to)) < angleCheck) { - direction.add(to); + direction.add(to.multiply(1.0 / 20)); } } @@ -217,6 +217,7 @@ public void explode() { for (Entity e : GeneralMethods.getEntitiesAroundPoint(curr, power)) { if (e instanceof LivingEntity) { double knockback = power / (0.3 + e.getLocation().distance(curr)); + DamageHandler.damageEntity(e, power, this); e.setVelocity(GeneralMethods.getDirection(curr, e.getLocation().add(0, 1, 0)).normalize().multiply(knockback)); } } diff --git a/src/me/simplicitee/project/addons/ability/water/PlantArmor.java b/src/me/simplicitee/project/addons/ability/water/PlantArmor.java index ae3dd18..b716410 100644 --- a/src/me/simplicitee/project/addons/ability/water/PlantArmor.java +++ b/src/me/simplicitee/project/addons/ability/water/PlantArmor.java @@ -44,6 +44,7 @@ import com.projectkorra.projectkorra.util.TempBlock; import me.simplicitee.project.addons.ProjectAddons; +import me.simplicitee.project.addons.Util; import net.md_5.bungee.api.ChatColor; public class PlantArmor extends PlantAbility implements AddonAbility, MultiAbility { @@ -426,7 +427,7 @@ private void progressForming() { display.add(x, dy, z); - GeneralMethods.displayColoredParticle("3D9970", display); + GeneralMethods.displayColoredParticle(Util.LEAF_COLOR, display); display.subtract(x, dy, z); } @@ -466,7 +467,7 @@ private void progressVineWhip() { return; } - GeneralMethods.displayColoredParticle("3D9970", last, 1, 0.1, 0.1, 0.1); + GeneralMethods.displayColoredParticle(Util.LEAF_COLOR, last, 1, 0.1, 0.1, 0.1); for (Entity e : GeneralMethods.getEntitiesAroundPoint(last, 1)) { if (e instanceof LivingEntity && e.getEntityId() != player.getEntityId()) { @@ -493,7 +494,7 @@ private void progressLeafShield() { } Vector direction = player.getEyeLocation().getDirection(); - Location center = player.getEyeLocation().add(direction.multiply(3)); + Location center = GeneralMethods.getTargetedLocation(player, 3.5); addShieldBlock(center.getBlock()); for (int i = 1; i <= radius; ++i) { @@ -539,7 +540,7 @@ private void progressTangle() { for (int i = 0; i < 3; ++i) { Vector ov = GeneralMethods.getOrthogonalVector(direction, (double) (angle + (120 * i)), tRadius); current.add(ov); - GeneralMethods.displayColoredParticle("3D9970", current); + GeneralMethods.displayColoredParticle(Util.LEAF_COLOR, current); current.subtract(ov); } @@ -556,7 +557,7 @@ private void leap() { ground.add(x, i, z); - GeneralMethods.displayColoredParticle("3D9970", ground); + GeneralMethods.displayColoredParticle(Util.LEAF_COLOR, ground); ground.subtract(x, i, z); } @@ -590,7 +591,7 @@ private void progressGrapple() { for (int i = 0; i < gRange; ++i) { current.add(direction); - GeneralMethods.displayColoredParticle("3D9970", current); + GeneralMethods.displayColoredParticle(Util.LEAF_COLOR, current); if (!current.getBlock().isPassable() && !pulling) { if (current.distance(target) < 1) { diff --git a/src/me/simplicitee/project/addons/ability/water/RazorLeaf.java b/src/me/simplicitee/project/addons/ability/water/RazorLeaf.java index 5a7372a..e220603 100644 --- a/src/me/simplicitee/project/addons/ability/water/RazorLeaf.java +++ b/src/me/simplicitee/project/addons/ability/water/RazorLeaf.java @@ -16,6 +16,7 @@ import com.projectkorra.projectkorra.util.TempBlock; import me.simplicitee.project.addons.ProjectAddons; +import me.simplicitee.project.addons.Util; public class RazorLeaf extends PlantAbility implements AddonAbility { @@ -48,10 +49,10 @@ public RazorLeaf(Player player, boolean sourced) { } this.source = new TempBlock(source, Material.AIR); - this.center = source.getLocation().clone().add(0.5, 0.5, 0.5); + this.center = source.getLocation().add(0.5, 0.5, 0.5); } else { this.source = null; - this.center = player.getEyeLocation().clone().add(player.getEyeLocation().getDirection().clone().normalize().multiply(1.5)); + this.center = player.getEyeLocation().add(player.getEyeLocation().getDirection().multiply(1.5)); } this.cooldown = ProjectAddons.instance.getConfig().getLong("Abilities.Water.RazorLeaf.Cooldown"); @@ -83,8 +84,7 @@ public void progress() { if (player.isSneaking() && uses < maxUses) { counted = true; - Location holding = player.getEyeLocation().clone().add(player.getEyeLocation().getDirection().clone().normalize().multiply(1.5)); - direction = GeneralMethods.getDirection(center, holding); + direction = GeneralMethods.getDirection(center, player.getEyeLocation().add(player.getEyeLocation().getDirection().multiply(radius + 0.5))); } else { if (counted) { counted = false; @@ -95,9 +95,9 @@ public void progress() { Entity e = GeneralMethods.getTargetedEntity(player, range); if (e == null || !(e instanceof LivingEntity)) { - target = GeneralMethods.getTargetedLocation(player, range); + target = GeneralMethods.getTargetedLocation(player, range).add(player.getEyeLocation().getDirection()); } else { - target = e.getLocation().clone().add(0, 1, 0); + target = e.getLocation().add(0, 1, 0); } direction = GeneralMethods.getDirection(center, target); @@ -114,22 +114,19 @@ public void progress() { return; } - playPlantbendingSound(center); + if (Math.random() < 0.13) { + playPlantbendingSound(center); + } - for (int n = 0; n < particles; n++) { - Location current, start = center.clone(); - double c = 0.075; + for (int n = 0; n < particles; ++n) { double phi = n * 137.5; - double r = c * Math.sqrt(n); - double x = r * Math.cos(Math.toRadians(phi)); - double z = r * Math.sin(Math.toRadians(phi)); - current = start.clone().add(x, 0, z); + double r = 0.075 * Math.sqrt(n); - if (current.distance(start) > radius) { + if (r > radius) { break; } - GeneralMethods.displayColoredParticle("3D9970", current); + GeneralMethods.displayColoredParticle(Util.LEAF_COLOR, center.clone().add(r * Math.cos(Math.toRadians(phi)), 0, r * Math.sin(Math.toRadians(phi)))); } for (Entity e : GeneralMethods.getEntitiesAroundPoint(center, radius + 1)) { diff --git a/src/plugin.yml b/src/plugin.yml index 5358670..e03f7ee 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,7 +1,7 @@ name: ProjectAddons author: Simplicitee api-version: 1.16 -version: 1.2.0 +version: 1.2.1 main: me.simplicitee.project.addons.ProjectAddons depend: [ProjectKorra] commands: