Added random offset for particles
This commit is contained in:
parent
40ab1dae99
commit
433688e813
|
|
@ -2,4 +2,4 @@ package com.alttd.objects;
|
||||||
|
|
||||||
import com.destroystokyo.paper.ParticleBuilder;
|
import com.destroystokyo.paper.ParticleBuilder;
|
||||||
|
|
||||||
public record AParticle(double x, double y, double z, ParticleBuilder particleBuilder) {}
|
public record AParticle(double x, double y, double z, double offset_range, ParticleBuilder particleBuilder) {}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class Frame {
|
public class Frame {
|
||||||
|
|
@ -22,8 +23,11 @@ public class Frame {
|
||||||
public void spawn(Location location) {
|
public void spawn(Location location) {
|
||||||
Location tmpLocation = location.clone();
|
Location tmpLocation = location.clone();
|
||||||
AParticles.forEach(AParticle -> {
|
AParticles.forEach(AParticle -> {
|
||||||
|
ThreadLocalRandom current = ThreadLocalRandom.current();
|
||||||
AParticle.particleBuilder()
|
AParticle.particleBuilder()
|
||||||
.location(tmpLocation.set(location.getX() + AParticle.x(), location.getY() + AParticle.y(), location.getZ() + AParticle.z()))
|
.location(tmpLocation.set(location.getX() + AParticle.x() + current.nextDouble(-AParticle.offset_range(), AParticle.offset_range()),
|
||||||
|
location.getY() + AParticle.y() + current.nextDouble(-AParticle.offset_range(), AParticle.offset_range()),
|
||||||
|
location.getZ() + AParticle.z() + current.nextDouble(-AParticle.offset_range(), AParticle.offset_range())))
|
||||||
.receivers(Bukkit.getOnlinePlayers().stream()
|
.receivers(Bukkit.getOnlinePlayers().stream()
|
||||||
.filter(player -> {
|
.filter(player -> {
|
||||||
PlayerSettings playerSettings = PlayerSettings.getPlayer(player.getUniqueId());
|
PlayerSettings playerSettings = PlayerSettings.getPlayer(player.getUniqueId());
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ public class Alpha {
|
||||||
double[] zPts = {0.91, 0.86, 0.81, 0.76, 0.70, 0.63, 0.58, 0.52, 0.47, 0.42, 0.39, 0.38, 0.39, 0.42, 0.47, 0.52, 0.58, 0.63, 0.69, 0.75, 0.81, 0.86, 0.89, 0.90, 0.89, 0.87, 0.83, 0.79, 0.74, 0.69, 0.57, 0.51, 0.46, 0.42, 0.40, 0.40, 0.42, 0.47};
|
double[] zPts = {0.91, 0.86, 0.81, 0.76, 0.70, 0.63, 0.58, 0.52, 0.47, 0.42, 0.39, 0.38, 0.39, 0.42, 0.47, 0.52, 0.58, 0.63, 0.69, 0.75, 0.81, 0.86, 0.89, 0.90, 0.89, 0.87, 0.83, 0.79, 0.74, 0.69, 0.57, 0.51, 0.46, 0.42, 0.40, 0.40, 0.42, 0.47};
|
||||||
|
|
||||||
for(int i = 0; i < xPts.length; i++) {
|
for(int i = 0; i < xPts.length; i++) {
|
||||||
list.add(new AParticle(xPts[i] * 5, 2, zPts[i] * 5, new ParticleBuilder(Particle.REDSTONE).color(Color.GRAY).count(1)));
|
list.add(new AParticle(xPts[i] * 5, 2, zPts[i] * 5, 0.5, new ParticleBuilder(Particle.REDSTONE).color(Color.GRAY).count(1)));
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,10 +47,10 @@ public class Test {
|
||||||
|
|
||||||
public List<AParticle> frameOne() {
|
public List<AParticle> frameOne() {
|
||||||
List<AParticle> list = new ArrayList<>();
|
List<AParticle> list = new ArrayList<>();
|
||||||
list.add(new AParticle(0, 2, 0, new ParticleBuilder(Particle.TOTEM)));
|
list.add(new AParticle(0, 2, 0, 0.3, new ParticleBuilder(Particle.TOTEM)));
|
||||||
list.add(new AParticle(0, 2, 0, new ParticleBuilder(Particle.TOTEM)));
|
list.add(new AParticle(0, 2, 0, 0.3, new ParticleBuilder(Particle.TOTEM)));
|
||||||
list.add(new AParticle(0, 2, 0, new ParticleBuilder(Particle.TOTEM)));
|
list.add(new AParticle(0, 2, 0, 0.3, new ParticleBuilder(Particle.TOTEM)));
|
||||||
list.add(new AParticle(0, 2, 0, new ParticleBuilder(Particle.TOTEM)));
|
list.add(new AParticle(0, 2, 0, 0.3, new ParticleBuilder(Particle.TOTEM)));
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
name: AltitudeParticles
|
name: AltitudeParticles
|
||||||
version: ${project.version}
|
version: ${project.version}
|
||||||
main: com.alttd.AltitudeParticles
|
main: com.alttd.AltitudeParticles
|
||||||
api-version: 1.17
|
api-version: 1.18
|
||||||
commands:
|
commands:
|
||||||
apart:
|
apart:
|
||||||
permission: apart.use
|
permission: apart.use
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user