Adds a cube particle option

This commit is contained in:
Kristian Knarvik 2023-07-04 19:31:52 +02:00
parent 2829a1af2b
commit 322cb804a7
4 changed files with 28 additions and 2 deletions

View File

@ -41,7 +41,7 @@ If you alter several launchpad values in succession, they'll all be applied to t
| launchpad.materialVelocities.\<MATERIAL>.horizontalVelocity | Decimal number | The horizontal (sideways) velocity applied to launchpads of type \<MATERIAL> if not overridden for the block. | | launchpad.materialVelocities.\<MATERIAL>.horizontalVelocity | Decimal number | The horizontal (sideways) velocity applied to launchpads of type \<MATERIAL> if not overridden for the block. |
| launchpad.materialVelocities.\<MATERIAL>.verticalVelocity | Decimal number | The vertical (sideways) velocity applied to launchpads of type \<MATERIAL> if not overridden for the block. | | launchpad.materialVelocities.\<MATERIAL>.verticalVelocity | Decimal number | The vertical (sideways) velocity applied to launchpads of type \<MATERIAL> if not overridden for the block. |
| launchpad.particles.enabled | True / False | Whether to display some kind of particle effect above manually added launchpads. | | launchpad.particles.enabled | True / False | Whether to display some kind of particle effect above manually added launchpads. |
| launchpad.particles.mode | SINGLE / SQUARE / PYRAMID / SPHERE / CIRCLE | The mode used for drawing particles. SINGLE directly spawns the particle(s) in one spot above the launchpad. The other ones spawn particles a bunch of times in a pattern. | | launchpad.particles.mode | SINGLE / SQUARE / PYRAMID / SPHERE / CIRCLE / CUBE | The mode used for drawing particles. SINGLE directly spawns the particle(s) in one spot above the launchpad. The other ones spawn particles a bunch of times in a pattern. |
| launchpad.particles.type | [Particle](https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Particle.html) | The type of particle to spawn above launchpads. | | launchpad.particles.type | [Particle](https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Particle.html) | The type of particle to spawn above launchpads. |
| launchpad.particles.amount | Positive integer | The amount of particles to spawn. Use 1 if mode is anything except SINGLE, unless you know what you are doing! | | launchpad.particles.amount | Positive integer | The amount of particles to spawn. Use 1 if mode is anything except SINGLE, unless you know what you are doing! |
| launchpad.particles.offsetX | Decimal number | The offset, or spread of the particles in the X direction, relative to the launchpad | | launchpad.particles.offsetX | Decimal number | The offset, or spread of the particles in the X direction, relative to the launchpad |

View File

@ -30,4 +30,9 @@ public enum ParticleMode {
*/ */
SPHERE, SPHERE,
/**
* Spawns the set amount of particles in a cube centered on the block
*/
CUBE,
} }

View File

@ -64,6 +64,7 @@ public class ParticleSpawner implements Runnable {
case CIRCLE -> drawCircle(world, location); case CIRCLE -> drawCircle(world, location);
case PYRAMID -> drawPyramid(world, location); case PYRAMID -> drawPyramid(world, location);
case SPHERE -> drawSphere(world, location); case SPHERE -> drawSphere(world, location);
case CUBE -> drawCube(world, location);
} }
} }
} }
@ -81,6 +82,26 @@ public class ParticleSpawner implements Runnable {
return this.particleConfig; return this.particleConfig;
} }
/**
* Spawns a cube of particles at the given location
*
* @param world <p>The world to spawn the particles in</p>
* @param location <p>The location of the block to spawn the particles at</p>
*/
private void drawCube(@NotNull World world, @NotNull Location location) {
// Draw the top and bottom of the cube
drawSquare(world, location);
drawSquare(world, location.clone().add(0, 1, 0));
for (float y = 0; y <= 1; y += getParticleConfig().getParticleDensity()) {
double height = getParticleConfig().getHeightOffset() + y;
spawnParticle(world, location.clone().add(0, height, 0));
spawnParticle(world, location.clone().add(0, height, 1));
spawnParticle(world, location.clone().add(1, height, 0));
spawnParticle(world, location.clone().add(1, height, 1));
}
}
/** /**
* Spawns a sphere of particles at the given location * Spawns a sphere of particles at the given location
* *

View File

@ -25,7 +25,7 @@ launchpad:
particles: particles:
# Whether to enable particles above launchpads # Whether to enable particles above launchpads
enabled: false enabled: false
# The mode used for spawning particles. Valid values are: SINGLE, SQUARE, PYRAMID, SPHERE and CIRCLE # The mode used for spawning particles. Valid values are: SINGLE, SQUARE, PYRAMID, SPHERE, CUBE and CIRCLE
mode: SQUARE mode: SQUARE
# The type of particle to spawn. See https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Particle.html # The type of particle to spawn. See https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Particle.html
type: DRIP_LAVA type: DRIP_LAVA