Skip to content

Commit

Permalink
changes that shoulda happened earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
Simplicitee committed May 2, 2021
1 parent 9474ca1 commit b2b77a0
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 121 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>me.simplicitee</groupId>
<artifactId>projectaddons</artifactId>
<version>1.2.0</version>
<version>1.2.1</version>
<name>ProjectAddons</name>

<repositories>
Expand Down
2 changes: 2 additions & 0 deletions src/me/simplicitee/project/addons/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 0 additions & 3 deletions src/me/simplicitee/project/addons/ability/air/Deafen.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}

}
Expand Down
172 changes: 79 additions & 93 deletions src/me/simplicitee/project/addons/ability/fire/ArcSpark.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> attractive;

public ArcSpark(Player player) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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();
Expand Down Expand Up @@ -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);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

Expand Down Expand Up @@ -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));
}
}
Expand Down
13 changes: 7 additions & 6 deletions src/me/simplicitee/project/addons/ability/water/PlantArmor.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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()) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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);
}

Expand All @@ -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);
}
Expand Down Expand Up @@ -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) {
Expand Down
29 changes: 13 additions & 16 deletions src/me/simplicitee/project/addons/ability/water/RazorLeaf.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion src/plugin.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down

0 comments on commit b2b77a0

Please sign in to comment.