Added random offset for particles

This commit is contained in:
Teriuihi 2022-02-17 02:02:48 +01:00
parent 40ab1dae99
commit 433688e813
5 changed files with 12 additions and 8 deletions

View File

@ -2,4 +2,4 @@ package com.alttd.objects;
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) {}

View File

@ -5,6 +5,7 @@ import org.bukkit.Bukkit;
import org.bukkit.Location;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
import java.util.stream.Collectors;
public class Frame {
@ -22,8 +23,11 @@ public class Frame {
public void spawn(Location location) {
Location tmpLocation = location.clone();
AParticles.forEach(AParticle -> {
ThreadLocalRandom current = ThreadLocalRandom.current();
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()
.filter(player -> {
PlayerSettings playerSettings = PlayerSettings.getPlayer(player.getUniqueId());

View File

@ -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};
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;
}

View File

@ -47,10 +47,10 @@ public class Test {
public List<AParticle> frameOne() {
List<AParticle> list = new ArrayList<>();
list.add(new AParticle(0, 2, 0, new ParticleBuilder(Particle.TOTEM)));
list.add(new AParticle(0, 2, 0, new ParticleBuilder(Particle.TOTEM)));
list.add(new AParticle(0, 2, 0, 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, 0.3, new ParticleBuilder(Particle.TOTEM)));
list.add(new AParticle(0, 2, 0, 0.3, new ParticleBuilder(Particle.TOTEM)));
list.add(new AParticle(0, 2, 0, 0.3, new ParticleBuilder(Particle.TOTEM)));
return list;
}
}

View File

@ -1,7 +1,7 @@
name: AltitudeParticles
version: ${project.version}
main: com.alttd.AltitudeParticles
api-version: 1.17
api-version: 1.18
commands:
apart:
permission: apart.use