|
46 | 46 | import org.bukkit.util.Vector; |
47 | 47 |
|
48 | 48 | import javax.annotation.Nullable; |
49 | | -import java.util.ArrayList; |
50 | | -import java.util.Arrays; |
51 | | -import java.util.List; |
52 | | -import java.util.Set; |
| 49 | +import java.util.*; |
53 | 50 | import java.util.function.Predicate; |
54 | 51 |
|
| 52 | +import static xyz.xenondevs.particle.utils.MathUtils.RANDOM; |
| 53 | + |
55 | 54 | public interface Component { |
56 | 55 | default void wisdom(Player p, long w) { |
57 | 56 | XP.wisdom(p, w); |
@@ -267,6 +266,22 @@ default double getValue(Block block) { |
267 | 266 | return MaterialValue.getValue(block.getType()); |
268 | 267 | } |
269 | 268 |
|
| 269 | + default void vfxDome(Location center, double range, Color color, int particleCount) { |
| 270 | + Particle.DustOptions dustOptions = new Particle.DustOptions(color, 1); |
| 271 | + World world = center.getWorld(); |
| 272 | + |
| 273 | + for (int i = 0; i < particleCount; i++) { |
| 274 | + double theta = 2 * Math.PI * RANDOM.nextDouble(); |
| 275 | + double phi = Math.PI / 2 * RANDOM.nextDouble(); // Adjusted range of phi to create a dome |
| 276 | + double x = range * Math.sin(phi) * Math.cos(theta); |
| 277 | + double y = range * Math.sin(phi) * Math.sin(theta); |
| 278 | + double z = range * Math.cos(phi); |
| 279 | + |
| 280 | + Location particleLocation = center.clone().add(x, y, z); |
| 281 | + world.spawnParticle(Particle.REDSTONE, particleLocation, 0, 0, 0, 0, dustOptions); |
| 282 | + } |
| 283 | + } |
| 284 | + |
270 | 285 | default void vfxSphereV1(Player p, Location l, double radius, Particle particle, int verticalDensity, int radialDensity) { |
271 | 286 | for (double phi = 0; phi <= Math.PI; phi += Math.PI / verticalDensity) { |
272 | 287 | for (double theta = 0; theta <= 2 * Math.PI; theta += Math.PI / radialDensity) { |
@@ -428,6 +443,44 @@ default void vfxPrismOutline(Location placer, double outset, Particle particle, |
428 | 443 | } |
429 | 444 | } |
430 | 445 |
|
| 446 | + default void vfxCreateSphereAlt(Location center, double range, Color color, int particleCount) { |
| 447 | + Particle.DustOptions dustOptions = new Particle.DustOptions(color, 1); |
| 448 | + World world = center.getWorld(); |
| 449 | + |
| 450 | + for (int i = 0; i < particleCount; i++) { |
| 451 | + double x, y, z; |
| 452 | + do { |
| 453 | + x = RANDOM.nextDouble() * 2 - 1; |
| 454 | + y = RANDOM.nextDouble() * 2 - 1; |
| 455 | + z = RANDOM.nextDouble() * 2 - 1; |
| 456 | + } while (x * x + y * y + z * z > 1); |
| 457 | + |
| 458 | + double magnitude = Math.sqrt(x * x + y * y + z * z); |
| 459 | + x = x / magnitude * range; |
| 460 | + y = y / magnitude * range; |
| 461 | + z = z / magnitude * range; |
| 462 | + |
| 463 | + Location particleLocation = center.clone().add(x, y, z); |
| 464 | + world.spawnParticle(Particle.REDSTONE, particleLocation, 0, 0, 0, 0, dustOptions); |
| 465 | + } |
| 466 | + } |
| 467 | + |
| 468 | + default void vfxSphereV3(Location center, double range, Color color, int particleCount) { |
| 469 | + Particle.DustOptions dustOptions = new Particle.DustOptions(color, 1); |
| 470 | + World world = center.getWorld(); |
| 471 | + |
| 472 | + for (int i = 0; i < particleCount; i++) { |
| 473 | + double theta = 2 * Math.PI * RANDOM.nextDouble(); |
| 474 | + double phi = Math.acos(2 * RANDOM.nextDouble() - 1); |
| 475 | + double x = range * Math.sin(phi) * Math.cos(theta); |
| 476 | + double y = range * Math.sin(phi) * Math.sin(theta); |
| 477 | + double z = range * Math.cos(phi); |
| 478 | + |
| 479 | + Location particleLocation = center.clone().add(x, y, z); |
| 480 | + world.spawnParticle(Particle.REDSTONE, particleLocation, 0, 0, 0, 0, dustOptions); |
| 481 | + } |
| 482 | + } |
| 483 | + |
431 | 484 |
|
432 | 485 | default void vfxLevelUp(Player p) { |
433 | 486 | p.spawnParticle(Particle.REVERSE_PORTAL, p.getLocation().clone().add(0, 1.7, 0), 100, 0.1, 0.1, 0.1, 4.1); |
|
0 commit comments