Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit b2b77a0

Browse files
committed
changes that shoulda happened earlier
1 parent 9474ca1 commit b2b77a0

File tree

8 files changed

+105
-121
lines changed

8 files changed

+105
-121
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>me.simplicitee</groupId>
44
<artifactId>projectaddons</artifactId>
5-
<version>1.2.0</version>
5+
<version>1.2.1</version>
66
<name>ProjectAddons</name>
77

88
<repositories>

src/me/simplicitee/project/addons/Util.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ private Util() {}
1010

1111
private static String[] lightning = {"e6efef", "03d2d2", "33e6ff", "03d2d2", "03d2d2", "33e6ff", "03d2d2", "33e6ff", "33e6ff"};
1212

13+
public static final String LEAF_COLOR = "48B518";
14+
1315
public static void playLightningParticles(Location loc, int amount, double xOff, double yOff, double zOff) {
1416
int i = (int) Math.round(Math.random() * (lightning.length - 1));
1517
GeneralMethods.displayColoredParticle(lightning[i], loc, amount, xOff, yOff, zOff);

src/me/simplicitee/project/addons/ability/air/Deafen.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import org.bukkit.Instrument;
44
import org.bukkit.Location;
55
import org.bukkit.Note;
6-
import org.bukkit.Sound;
76
import org.bukkit.Note.Tone;
87
import org.bukkit.entity.Entity;
98
import org.bukkit.entity.Player;
@@ -66,8 +65,6 @@ public void progress() {
6665

6766
for (int i = 0; i < 2; i++) {
6867
target.playNote(target.getEyeLocation().add(new Vector(Math.random(), Math.random(), Math.random())), Instrument.BASS_GUITAR, Note.sharp(i, Tone.F));
69-
target.playNote(target.getEyeLocation().add(new Vector(Math.random(), Math.random(), Math.random())), Instrument.PLING, Note.sharp(i, Tone.F));
70-
target.playNote(target.getEyeLocation().add(new Vector(Math.random(), Math.random(), Math.random())), Instrument.FLUTE, Note.sharp(i, Tone.F));
7168
}
7269

7370
}

src/me/simplicitee/project/addons/ability/fire/ArcSpark.java

Lines changed: 79 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class ArcSpark extends LightningAbility implements AddonAbility {
3434
private long cooldown;
3535

3636
private long charge, chargedTill;
37-
private boolean shoot, charged;
37+
private boolean shoot, charged, left;
3838
private List<String> attractive;
3939

4040
public ArcSpark(Player player) {
@@ -72,7 +72,7 @@ public void progress() {
7272
chargedTill = System.currentTimeMillis();
7373
player.getWorld().playSound(player.getEyeLocation(), Sound.ENTITY_CREEPER_PRIMED, 0.05f, 0.5f);
7474
} else if (charged && !shoot) {
75-
Util.playLightningParticles(GeneralMethods.getMainHandLocation(player), 1, 0.001, 0.001, 0.001);
75+
Util.playLightningParticles(player.getEyeLocation().add(player.getLocation().getDirection().multiply(1.3)), 1, 0.001, 0.001, 0.001);
7676
chargedTill = System.currentTimeMillis();
7777
player.getWorld().playSound(player.getEyeLocation(), Sound.ENTITY_CREEPER_PRIMED, 0.05f, 0.5f);
7878
} else if (charged && shoot) {
@@ -81,16 +81,89 @@ public void progress() {
8181
return;
8282
}
8383

84-
Location hand = GeneralMethods.getMainHandLocation(player);
84+
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);
85+
left = !left;
8586
hand.setDirection(player.getEyeLocation().getDirection());
86-
Arc arc = new Arc(hand);
8787

88-
for (int i = 0; i < speed*length; i++) {
89-
arc.run(this);
88+
boolean persist = true;
89+
for (int i = 0; i < speed*length && persist; ++i) {
90+
persist = arc(hand);
9091
}
9192
}
9293
}
9394

95+
private boolean arc(Location loc) {
96+
double shortest = Double.MAX_VALUE;
97+
Entity closest = null;
98+
Location to = null;
99+
for (Entity e : GeneralMethods.getEntitiesAroundPoint(loc, 3)) {
100+
if (!(e instanceof LivingEntity) || e.getEntityId() == player.getEntityId()) {
101+
continue;
102+
}
103+
104+
double dist = loc.distance(e.getLocation().clone().add(0, 1, 0));
105+
106+
if (dist <= 1) {
107+
DamageHandler.damageEntity(e, damage, this);
108+
return false;
109+
} else {
110+
if (dist < shortest || closest == null) {
111+
shortest = dist;
112+
closest = e;
113+
to = e.getLocation().clone().add(0, 1, 0);
114+
}
115+
}
116+
}
117+
118+
if (closest == null) {
119+
for (Block b : GeneralMethods.getBlocksAroundPoint(loc, 2)) {
120+
if (b.isPassable() || !attractive.contains(b.getType().toString())) {
121+
continue;
122+
}
123+
124+
Location center = b.getLocation().add(0.5, 0.5, 0.5);
125+
double dist = loc.distance(center);
126+
127+
if (dist < shortest) {
128+
shortest = dist;
129+
to = center;
130+
}
131+
}
132+
}
133+
134+
Vector movement = null;
135+
136+
if (to != null) {
137+
movement = GeneralMethods.getDirection(loc, to);
138+
} else {
139+
movement = new Vector(Math.random() / 5 - 0.1, Math.random() / 5 - 0.1, Math.random() / 5 - 0.1);
140+
}
141+
142+
double angle = movement.angle(loc.getDirection());
143+
if (angle < 60 && angle > -60) {
144+
loc.setDirection(loc.getDirection().add(movement));
145+
}
146+
147+
loc.getDirection().normalize();
148+
loc.add(loc.getDirection().multiply(0.3));
149+
150+
if (loc.getBlock().getType() == Material.WATER || attractive.contains(loc.getBlock().getType().toString())) {
151+
if (Math.random() > 0.55) {
152+
new Electrify(player, loc.getBlock(), false);
153+
}
154+
return false;
155+
} else if (!loc.getBlock().isPassable()) {
156+
return false;
157+
}
158+
159+
Util.playLightningParticles(loc, 1, 0, 0, 0);
160+
if (Math.random() < 0.15) {
161+
playLightningbendingSound(loc);
162+
}
163+
164+
return true;
165+
}
166+
94167
@Override
95168
public void remove() {
96169
super.remove();
@@ -160,91 +233,4 @@ public String getInstructions() {
160233
public String getDescription() {
161234
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!";
162235
}
163-
164-
class Arc {
165-
166-
private boolean progressing = true;
167-
private Location loc;
168-
169-
public Arc(Location loc) {
170-
this.loc = loc;
171-
}
172-
173-
public void run(ArcSpark a) {
174-
if (!progressing) {
175-
return;
176-
}
177-
178-
double shortest = Double.MAX_VALUE;
179-
Entity closest = null;
180-
Location to = null;
181-
for (Entity e : GeneralMethods.getEntitiesAroundPoint(loc, 3)) {
182-
if (!(e instanceof LivingEntity) || e.getEntityId() == player.getEntityId()) {
183-
continue;
184-
}
185-
186-
double dist = loc.distance(e.getLocation().clone().add(0, 1, 0));
187-
188-
if (dist <= 1) {
189-
DamageHandler.damageEntity(e, damage, a);
190-
progressing = false;
191-
return;
192-
} else {
193-
if (dist < shortest || closest == null) {
194-
shortest = dist;
195-
closest = e;
196-
to = e.getLocation().clone().add(0, 1, 0);
197-
}
198-
}
199-
}
200-
201-
if (closest == null) {
202-
for (Block b : GeneralMethods.getBlocksAroundPoint(loc, 2)) {
203-
if (b.isPassable() || !attractive.contains(b.getType().toString())) {
204-
continue;
205-
}
206-
207-
Location center = b.getLocation().add(0.5, 0.5, 0.5);
208-
double dist = loc.distance(center);
209-
210-
if (dist < shortest) {
211-
shortest = dist;
212-
to = center;
213-
}
214-
}
215-
}
216-
217-
Vector movement = null;
218-
219-
if (to != null) {
220-
movement = GeneralMethods.getDirection(loc, to);
221-
} else {
222-
movement = new Vector(Math.random() / 5 - 0.1, Math.random() / 5 - 0.1, Math.random() / 5 - 0.1);
223-
}
224-
225-
double angle = movement.angle(loc.getDirection());
226-
if (angle < 60 && angle > -60) {
227-
loc.setDirection(loc.getDirection().add(movement));
228-
}
229-
230-
loc.getDirection().normalize();
231-
loc.add(loc.getDirection().multiply(0.3));
232-
233-
if (loc.getBlock().getType() == Material.WATER || attractive.contains(loc.getBlock().getType().toString())) {
234-
if (Math.random() > 0.55) {
235-
new Electrify(player, loc.getBlock(), false);
236-
}
237-
progressing = false;
238-
return;
239-
} else if (!loc.getBlock().isPassable()) {
240-
progressing = false;
241-
return;
242-
}
243-
244-
Util.playLightningParticles(loc, 1, 0, 0, 0);
245-
if (Math.random() < 0.15) {
246-
playLightningbendingSound(loc);
247-
}
248-
}
249-
}
250236
}

src/me/simplicitee/project/addons/ability/fire/CombustBeam.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public void progress() {
137137
Vector to = player.getEyeLocation().getDirection().clone().normalize().multiply(0.3);
138138

139139
if (Math.abs(direction.angle(to)) < angleCheck) {
140-
direction.add(to);
140+
direction.add(to.multiply(1.0 / 20));
141141
}
142142
}
143143

@@ -217,6 +217,7 @@ public void explode() {
217217
for (Entity e : GeneralMethods.getEntitiesAroundPoint(curr, power)) {
218218
if (e instanceof LivingEntity) {
219219
double knockback = power / (0.3 + e.getLocation().distance(curr));
220+
DamageHandler.damageEntity(e, power, this);
220221
e.setVelocity(GeneralMethods.getDirection(curr, e.getLocation().add(0, 1, 0)).normalize().multiply(knockback));
221222
}
222223
}

src/me/simplicitee/project/addons/ability/water/PlantArmor.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import com.projectkorra.projectkorra.util.TempBlock;
4545

4646
import me.simplicitee.project.addons.ProjectAddons;
47+
import me.simplicitee.project.addons.Util;
4748
import net.md_5.bungee.api.ChatColor;
4849

4950
public class PlantArmor extends PlantAbility implements AddonAbility, MultiAbility {
@@ -426,7 +427,7 @@ private void progressForming() {
426427

427428
display.add(x, dy, z);
428429

429-
GeneralMethods.displayColoredParticle("3D9970", display);
430+
GeneralMethods.displayColoredParticle(Util.LEAF_COLOR, display);
430431

431432
display.subtract(x, dy, z);
432433
}
@@ -466,7 +467,7 @@ private void progressVineWhip() {
466467
return;
467468
}
468469

469-
GeneralMethods.displayColoredParticle("3D9970", last, 1, 0.1, 0.1, 0.1);
470+
GeneralMethods.displayColoredParticle(Util.LEAF_COLOR, last, 1, 0.1, 0.1, 0.1);
470471

471472
for (Entity e : GeneralMethods.getEntitiesAroundPoint(last, 1)) {
472473
if (e instanceof LivingEntity && e.getEntityId() != player.getEntityId()) {
@@ -493,7 +494,7 @@ private void progressLeafShield() {
493494
}
494495

495496
Vector direction = player.getEyeLocation().getDirection();
496-
Location center = player.getEyeLocation().add(direction.multiply(3));
497+
Location center = GeneralMethods.getTargetedLocation(player, 3.5);
497498
addShieldBlock(center.getBlock());
498499

499500
for (int i = 1; i <= radius; ++i) {
@@ -539,7 +540,7 @@ private void progressTangle() {
539540
for (int i = 0; i < 3; ++i) {
540541
Vector ov = GeneralMethods.getOrthogonalVector(direction, (double) (angle + (120 * i)), tRadius);
541542
current.add(ov);
542-
GeneralMethods.displayColoredParticle("3D9970", current);
543+
GeneralMethods.displayColoredParticle(Util.LEAF_COLOR, current);
543544
current.subtract(ov);
544545
}
545546

@@ -556,7 +557,7 @@ private void leap() {
556557

557558
ground.add(x, i, z);
558559

559-
GeneralMethods.displayColoredParticle("3D9970", ground);
560+
GeneralMethods.displayColoredParticle(Util.LEAF_COLOR, ground);
560561

561562
ground.subtract(x, i, z);
562563
}
@@ -590,7 +591,7 @@ private void progressGrapple() {
590591
for (int i = 0; i < gRange; ++i) {
591592
current.add(direction);
592593

593-
GeneralMethods.displayColoredParticle("3D9970", current);
594+
GeneralMethods.displayColoredParticle(Util.LEAF_COLOR, current);
594595

595596
if (!current.getBlock().isPassable() && !pulling) {
596597
if (current.distance(target) < 1) {

src/me/simplicitee/project/addons/ability/water/RazorLeaf.java

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import com.projectkorra.projectkorra.util.TempBlock;
1717

1818
import me.simplicitee.project.addons.ProjectAddons;
19+
import me.simplicitee.project.addons.Util;
1920

2021
public class RazorLeaf extends PlantAbility implements AddonAbility {
2122

@@ -48,10 +49,10 @@ public RazorLeaf(Player player, boolean sourced) {
4849
}
4950

5051
this.source = new TempBlock(source, Material.AIR);
51-
this.center = source.getLocation().clone().add(0.5, 0.5, 0.5);
52+
this.center = source.getLocation().add(0.5, 0.5, 0.5);
5253
} else {
5354
this.source = null;
54-
this.center = player.getEyeLocation().clone().add(player.getEyeLocation().getDirection().clone().normalize().multiply(1.5));
55+
this.center = player.getEyeLocation().add(player.getEyeLocation().getDirection().multiply(1.5));
5556
}
5657

5758
this.cooldown = ProjectAddons.instance.getConfig().getLong("Abilities.Water.RazorLeaf.Cooldown");
@@ -83,8 +84,7 @@ public void progress() {
8384

8485
if (player.isSneaking() && uses < maxUses) {
8586
counted = true;
86-
Location holding = player.getEyeLocation().clone().add(player.getEyeLocation().getDirection().clone().normalize().multiply(1.5));
87-
direction = GeneralMethods.getDirection(center, holding);
87+
direction = GeneralMethods.getDirection(center, player.getEyeLocation().add(player.getEyeLocation().getDirection().multiply(radius + 0.5)));
8888
} else {
8989
if (counted) {
9090
counted = false;
@@ -95,9 +95,9 @@ public void progress() {
9595
Entity e = GeneralMethods.getTargetedEntity(player, range);
9696

9797
if (e == null || !(e instanceof LivingEntity)) {
98-
target = GeneralMethods.getTargetedLocation(player, range);
98+
target = GeneralMethods.getTargetedLocation(player, range).add(player.getEyeLocation().getDirection());
9999
} else {
100-
target = e.getLocation().clone().add(0, 1, 0);
100+
target = e.getLocation().add(0, 1, 0);
101101
}
102102

103103
direction = GeneralMethods.getDirection(center, target);
@@ -114,22 +114,19 @@ public void progress() {
114114
return;
115115
}
116116

117-
playPlantbendingSound(center);
117+
if (Math.random() < 0.13) {
118+
playPlantbendingSound(center);
119+
}
118120

119-
for (int n = 0; n < particles; n++) {
120-
Location current, start = center.clone();
121-
double c = 0.075;
121+
for (int n = 0; n < particles; ++n) {
122122
double phi = n * 137.5;
123-
double r = c * Math.sqrt(n);
124-
double x = r * Math.cos(Math.toRadians(phi));
125-
double z = r * Math.sin(Math.toRadians(phi));
126-
current = start.clone().add(x, 0, z);
123+
double r = 0.075 * Math.sqrt(n);
127124

128-
if (current.distance(start) > radius) {
125+
if (r > radius) {
129126
break;
130127
}
131128

132-
GeneralMethods.displayColoredParticle("3D9970", current);
129+
GeneralMethods.displayColoredParticle(Util.LEAF_COLOR, center.clone().add(r * Math.cos(Math.toRadians(phi)), 0, r * Math.sin(Math.toRadians(phi))));
133130
}
134131

135132
for (Entity e : GeneralMethods.getEntitiesAroundPoint(center, radius + 1)) {

src/plugin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: ProjectAddons
22
author: Simplicitee
33
api-version: 1.16
4-
version: 1.2.0
4+
version: 1.2.1
55
main: me.simplicitee.project.addons.ProjectAddons
66
depend: [ProjectKorra]
77
commands:

0 commit comments

Comments
 (0)