Changed from using offset to modifying location directly
This commit is contained in:
parent
5e44521ea9
commit
7318a8be96
5
src/main/java/com/alttd/objects/AParticle.java
Normal file
5
src/main/java/com/alttd/objects/AParticle.java
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
package com.alttd.objects;
|
||||
|
||||
import com.destroystokyo.paper.ParticleBuilder;
|
||||
|
||||
public record AParticle(double x, double y, double z, ParticleBuilder particleBuilder) {}
|
||||
|
|
@ -1,19 +1,17 @@
|
|||
package com.alttd.objects;
|
||||
|
||||
import com.alttd.storage.PlayerSettings;
|
||||
import com.destroystokyo.paper.ParticleBuilder;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Frame {
|
||||
List<ParticleBuilder> particles;
|
||||
List<AParticle> AParticles;
|
||||
|
||||
public Frame(List<ParticleBuilder> particles) {
|
||||
this.particles = particles;
|
||||
public Frame(List<AParticle> AParticles) {
|
||||
this.AParticles = AParticles;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -22,16 +20,21 @@ public class Frame {
|
|||
* @param location Location to spawn particles at
|
||||
*/
|
||||
public void spawn(Location location) {
|
||||
particles.forEach(particleBuilder -> particleBuilder
|
||||
.location(location)
|
||||
.receivers(Bukkit.getOnlinePlayers().stream()
|
||||
.filter(player -> {
|
||||
PlayerSettings playerSettings = PlayerSettings.getPlayer(player.getUniqueId());
|
||||
if (playerSettings == null)
|
||||
return false;
|
||||
return playerSettings.isSeeingParticles();
|
||||
}).collect(Collectors.toList())
|
||||
)
|
||||
.spawn());
|
||||
Location tmpLocation = location.clone();
|
||||
AParticles.forEach(AParticle -> {
|
||||
AParticle.particleBuilder()
|
||||
.location(tmpLocation.set(location.getX() + AParticle.x(), location.getY() + AParticle.y(), location.getZ() + AParticle.z()))
|
||||
.receivers(Bukkit.getOnlinePlayers().stream()
|
||||
.filter(player -> {
|
||||
PlayerSettings playerSettings = PlayerSettings.getPlayer(player.getUniqueId());
|
||||
if (playerSettings == null)
|
||||
return false;
|
||||
if (!playerSettings.isSeeingParticles())
|
||||
return false;
|
||||
return player.getLocation().distance(location) < 100;
|
||||
}).collect(Collectors.toList())
|
||||
)
|
||||
.spawn();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
package com.alttd.particles;
|
||||
|
||||
import com.alttd.objects.APartType;
|
||||
import com.alttd.objects.AParticle;
|
||||
import com.alttd.objects.Frame;
|
||||
import com.alttd.objects.ParticleSet;
|
||||
import com.alttd.storage.ParticleStorage;
|
||||
import com.destroystokyo.paper.ParticleBuilder;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
|
@ -39,13 +41,13 @@ public class Alpha {
|
|||
}
|
||||
|
||||
|
||||
public List<ParticleBuilder> frameOne() {
|
||||
List<ParticleBuilder> list = new ArrayList<>();
|
||||
double x_pts[] = {0.23, 0.21, 0.19, 0.17, 0.15, 0.13, 0.11, 0.09, 0.06, 0.02, -0.03, -0.08, -0.14, -0.19, -0.24, -0.26, -0.28, -0.28, -0.27, -0.25, -0.22, -0.18, -0.13, -0.08, -0.03, 0.00, 0.03, 0.06, 0.09, 0.11, 0.14, 0.15, 0.16, 0.18, 0.22, 0.26, 0.30, 0.32};
|
||||
double z_pts[] = {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};
|
||||
public List<AParticle> frameOne() {
|
||||
List<AParticle> list = new ArrayList<>();
|
||||
double[] xPts = {0.23, 0.21, 0.19, 0.17, 0.15, 0.13, 0.11, 0.09, 0.06, 0.02, -0.03, -0.08, -0.14, -0.19, -0.24, -0.26, -0.28, -0.28, -0.27, -0.25, -0.22, -0.18, -0.13, -0.08, -0.03, 0.00, 0.03, 0.06, 0.09, 0.11, 0.14, 0.15, 0.16, 0.18, 0.22, 0.26, 0.30, 0.32};
|
||||
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 < x_pts.length; i++) {
|
||||
list.add(new ParticleBuilder(Particle.ELECTRIC_SPARK).offset(x_pts[i], 2, z_pts[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)));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.alttd.particles;
|
||||
|
||||
import com.alttd.objects.APartType;
|
||||
import com.alttd.objects.AParticle;
|
||||
import com.alttd.objects.Frame;
|
||||
import com.alttd.objects.ParticleSet;
|
||||
import com.alttd.storage.ParticleStorage;
|
||||
|
|
@ -44,12 +45,12 @@ public class Test {
|
|||
}
|
||||
|
||||
|
||||
public List<ParticleBuilder> frameOne() {
|
||||
List<ParticleBuilder> list = new ArrayList<>();
|
||||
list.add(new ParticleBuilder(Particle.TOTEM).offset(0, 2, 0));
|
||||
list.add(new ParticleBuilder(Particle.TOTEM).offset(0, 2, 1));
|
||||
list.add(new ParticleBuilder(Particle.TOTEM).offset(0, 2, 2));
|
||||
list.add(new ParticleBuilder(Particle.TOTEM).offset(0, 2, 3));
|
||||
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)));
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user