Skip to content

Commit 449afb8

Browse files
author
Slikey
committed
Added LineEffect
1 parent 1c568e2 commit 449afb8

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package de.slikey.effectlib.effect;
2+
3+
import org.bukkit.Location;
4+
import org.bukkit.util.Vector;
5+
6+
import de.slikey.effectlib.EffectManager;
7+
import de.slikey.effectlib.EffectType;
8+
import de.slikey.effectlib.util.ParticleEffect;
9+
10+
public class LineLocationEffect extends LocationEffect {
11+
12+
/**
13+
* ParticleType of spawned particle
14+
*/
15+
public ParticleEffect particle = ParticleEffect.FLAME;
16+
17+
/**
18+
* Particles per arc
19+
*/
20+
public int particles = 100;
21+
22+
protected final Vector link;
23+
protected final float lenght;
24+
25+
public LineLocationEffect(EffectManager effectManager, Location start, Location stop) {
26+
super(effectManager, start);
27+
link = stop.toVector().subtract(start.toVector());
28+
lenght = (float) link.length();
29+
link.normalize();
30+
31+
type = EffectType.INSTANT;
32+
period = 5;
33+
iterations = 200;
34+
}
35+
36+
@Override
37+
public void onRun() {
38+
for (int i = 0; i < particles; i++) {
39+
float ratio = (float) i * lenght / particles;
40+
Vector v = link.clone().multiply(ratio);
41+
location.add(v);
42+
particle.display(location, visibleRange);
43+
location.subtract(v);
44+
}
45+
}
46+
47+
}

0 commit comments

Comments
 (0)