Solved Problems with particles generating at each block location

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Omanoctoa

New Member
Feb 4, 2025
5
0
1
Hello!

New to Skript but learning fast. Running Spigot 1.21.1
I've created a relatively simple skript from tutorials, examples and helpful replies but I'm coming up short on 2 areas:

2025-02-02_12.53.35.png


1. When I place a Cauldron, it generates particles until the Cauldron is broken. This will be greatly expanded on later but for now it has a major flaw - when I place 3 Cauldrons, the number of particles being generated at each location triples, and more particles generate each iteration with every additional Cauldron placed. How can I prevent this? I want a set number of particles at each location. I assume it has to do with {cauldron::%event-player%::*} which I'm not very familiar with, but I'm trying to be forward thinking in how the Cauldron is being used.

2. How do I create coloured potion swirl particles of a specific colour, direction, size, spread and offset? I've seen a few examples but they either don't work for me or require a specific addon. Is there no way to do this with Skript and SkBee. I see this problem plaguing many people, but can't find a solution without massively over-complicating things.

Code:
# Check if a Cauldron is placed and add it to the list registered to that player. Start ticker (failsafe).
# Assign variables for Cauldron's location (for particles and other uses). Then, generate some particles, etc...
on place:
    if event-block is cauldron:
        add location of event-block to {cauldron::%event-player%::*}
        set {cauldron.ticker} to true
        set {Caul_location} to location of targeted block
        set {Caul_x} to {Caul_location}'s x-coord
        set {Caul_y} to {Caul_location}'s y-coord
        set {Caul_z} to {Caul_location}'s z-coord
        while event-block is cauldron:
            draw 1 of dust_color_transition using dustTransition(light blue, blue, 3) at {cauldron::%event-player%::*}
            draw 1 of dust_color_transition using dustTransition(light blue, blue, 2) 0.4 block above {cauldron::%event-player%::*}
            wait 1 second

# Check for Cauldron at location, check if a player placed that Cauldron (and broadcast it was broken); set ticker to false (failsafe);
# Then remove location from list.
on break:
    if event-block is cauldron:
        loop all players:
            if {cauldron::%loop-player%::*} contains location of event-block:
                broadcast "%loop-player%`s Cauldron was broken by %event-player%"
                set {cauldron.ticker} to false
                remove location of event-block from {cauldron::%loop-player%::*}

3. Also, does anyone have a list of particle_names that Skript understands? I've had trouble getting the particles to work because Skript doesn't understand the name or syntax (because of the name).

Thanks for your help and guidance!
 
Whatsup. Iv helped fix your cauldron particle script and made it much more reliable. Let me explain what was causing your issues and how the new version works better.
First, the particle multiplication problem was happening because of how the while loop was structured. Instead of using a while loop with wait (which can stack up and cause more and more particles), the new version uses a simple timer that checks all cauldrons every second. This means each cauldron gets exactly the same number of particles, no matter how many you place!
For the particle positioning, I've added precise center calculations so the particles appear right in the middle of the cauldron (to make sure they dont go to one side).
The script now calculates the exact center like this:


set {_center} to loop-value
set x-coord of {_center} to (floor(x-coord of {_center}) + 0.5)
set y-coord of {_center} to (floor(y-coord of {_center}) + 0.3)
set z-coord of {_center} to (floor(z-coord of {_center}) + 0.5)


The particles now have three distinct effects that you can easily customize:
A base swirl inside the cauldron:
make 3 of dragon_breath at {_center} with offset vector(0.1, 0.1, 0.1) with extra 0.01
An upper effect above the water level:
make 2 of end_rod at {_above} with offset vector(0.1, 0.1, 0.1) with extra 0.02
Some ambient particles that float around it:
make 1 of portal at {_ambient} with offset vector(0.05, 0.05, 0.05) with extra 0.1

I also made it so the script handles cleanup better now - it automatically removes broken cauldrons from the list and clears old data when the server reloads. This keeps everything running smoothly even after long periods of use.
You can use any of these particle types in your effects:
dragon_breath (purple swirl)
end_rod (white sparkle)
portal (purple void)
flame (fire)
heart
smoke
large_smoke
enchanted_hit
witch (purple magic)
spell (general magic)
spell_witch (colored magic)
Just try any combos you want! You might try changing the timing (every 1 second), adjusting how high the particles float, or mixing different particle types. The script is pretty flexible, so you can really make it your own.
Let me know if you want to try any specific effects - I'd be happy to help you customize it further!
 

Attachments

  • magical_cauldron.sk
    2.5 KB · Views: 18
Whatsup. Iv helped fix your cauldron particle script and made it much more reliable. Let me explain what was causing your issues and how the new version works better.
First, the particle multiplication problem was happening because of how the while loop was structured. Instead of using a while loop with wait (which can stack up and cause more and more particles), the new version uses a simple timer that checks all cauldrons every second. This means each cauldron gets exactly the same number of particles, no matter how many you place!
For the particle positioning, I've added precise center calculations so the particles appear right in the middle of the cauldron (to make sure they dont go to one side).
The script now calculates the exact center like this:


set {_center} to loop-value
set x-coord of {_center} to (floor(x-coord of {_center}) + 0.5)
set y-coord of {_center} to (floor(y-coord of {_center}) + 0.3)
set z-coord of {_center} to (floor(z-coord of {_center}) + 0.5)


The particles now have three distinct effects that you can easily customize:
A base swirl inside the cauldron:
make 3 of dragon_breath at {_center} with offset vector(0.1, 0.1, 0.1) with extra 0.01
An upper effect above the water level:
make 2 of end_rod at {_above} with offset vector(0.1, 0.1, 0.1) with extra 0.02
Some ambient particles that float around it:
make 1 of portal at {_ambient} with offset vector(0.05, 0.05, 0.05) with extra 0.1

I also made it so the script handles cleanup better now - it automatically removes broken cauldrons from the list and clears old data when the server reloads. This keeps everything running smoothly even after long periods of use.
You can use any of these particle types in your effects:
dragon_breath (purple swirl)
end_rod (white sparkle)
portal (purple void)
flame (fire)
heart
smoke
large_smoke
enchanted_hit
witch (purple magic)
spell (general magic)
spell_witch (colored magic)
Just try any combos you want! You might try changing the timing (every 1 second), adjusting how high the particles float, or mixing different particle types. The script is pretty flexible, so you can really make it your own.
Let me know if you want to try any specific effects - I'd be happy to help you customize it further!
Wow! Thank you! This answers a lot of questions for other issues I had too.
I think I was misunderstanding that variables (_ambient, for instance) could have multiple values added to it to create specific coordinates. Does this operate like "coordinate" + "x-value" + "y-value" + "z-value" + "oops I added something extra" together as one string? > "coord x y z oops"

To make coloured potion swirls, is spell_witch what I use? I've tried this and other aliases many times, and modified other examples too but haven't had much luck. Sometimes I can get colours particles to display (like my original version) but can't customize them much without running into errors that don't make sense to me.
 
Hey, First, about location variables: When you see something like {_ambient} in the code, it's not actually creating a string of coordinates - it's storing a complete location object. Think of it like a container that holds all the coordinate information together. When you do operations like:

set {_ambient} to {_center}
add 0.2 to y-coord of {_ambient}

You're directly modifying specific parts of that location object. It's more like adjusting individual dials on a control panel rather than building a string of text.
Now, for your question about colored potion swirls - you have several options with SkBee! Instead of spell_witch, you can create pretty cool colored particles using either:
Dust particles (most flexible):
make 5 of dust using dustOption(rgb(255, 0, 255), 1) at {_center}
This will create magenta dust particles. The first number in rgb() is red (0-255), second is green, third is blue.
Entity effect particles (potion swirl look):
make 1 of entity_effect using rgb(51, 255, 187) at {_center}
This creates a cyan-colored potion swirl effect.
You can even create transitioning colors using:
make 5 of dust_color_transition using dustTransition(rgb(255, 0, 0), rgb(0, 0, 255), 1) at {_center}
This creates particles that transition from red to blue.

Hope this helps, Let me know if you have any other questions or skripts you need help with!

I attached the file I sent in the last response, but changed it to use rgb instead!
 

Attachments

  • magical_cauldron.sk
    3 KB · Views: 17
Hey, First, about location variables: When you see something like {_ambient} in the code, it's not actually creating a string of coordinates - it's storing a complete location object. Think of it like a container that holds all the coordinate information together. When you do operations like:

set {_ambient} to {_center}
add 0.2 to y-coord of {_ambient}

You're directly modifying specific parts of that location object. It's more like adjusting individual dials on a control panel rather than building a string of text.
Now, for your question about colored potion swirls - you have several options with SkBee! Instead of spell_witch, you can create pretty cool colored particles using either:
Dust particles (most flexible):
make 5 of dust using dustOption(rgb(255, 0, 255), 1) at {_center}
This will create magenta dust particles. The first number in rgb() is red (0-255), second is green, third is blue.
Entity effect particles (potion swirl look):
make 1 of entity_effect using rgb(51, 255, 187) at {_center}
This creates a cyan-colored potion swirl effect.
You can even create transitioning colors using:
make 5 of dust_color_transition using dustTransition(rgb(255, 0, 0), rgb(0, 0, 255), 1) at {_center}
This creates particles that transition from red to blue.

Hope this helps, Let me know if you have any other questions or skripts you need help with!

I attached the file I sent in the last response, but changed it to use rgb instead!
Oh yeah, look through SkBee's docs, its pretty useful.
Docs: https://github.com/ShaneBeee/SkBee/wiki
Particle Docs: https://github.com/ShaneBeee/SkBee/wiki/Particles
 
Hey, First, about location variables: When you see something like {_ambient} in the code, it's not actually creating a string of coordinates - it's storing a complete location object. Think of it like a container that holds all the coordinate information together. When you do operations like:

set {_ambient} to {_center}
add 0.2 to y-coord of {_ambient}

You're directly modifying specific parts of that location object. It's more like adjusting individual dials on a control panel rather than building a string of text.
Now, for your question about colored potion swirls - you have several options with SkBee! Instead of spell_witch, you can create pretty cool colored particles using either:
Dust particles (most flexible):
make 5 of dust using dustOption(rgb(255, 0, 255), 1) at {_center}
This will create magenta dust particles. The first number in rgb() is red (0-255), second is green, third is blue.
Entity effect particles (potion swirl look):
make 1 of entity_effect using rgb(51, 255, 187) at {_center}
This creates a cyan-colored potion swirl effect.
You can even create transitioning colors using:
make 5 of dust_color_transition using dustTransition(rgb(255, 0, 0), rgb(0, 0, 255), 1) at {_center}
This creates particles that transition from red to blue.

Hope this helps, Let me know if you have any other questions or skripts you need help with!

I attached the file I sent in the last response, but changed it to use rgb instead!
That's fantastic!
Thank you for explaining the location variable. I didn't think about it like a complete location, I was expecting it was an empty container that I had to manually define each part of the location. This really explains a lot of difficulty I was having...

My hope is to use the entity_effect particles. I tried them before but kept getting errors upon errors that made no sense - I would copy the code directly from other working examples (other particles) but they would fail for entity_effect.

I really appreciate the amount of effort and detail you've put into your replies. They are pure gold in value to me and probably to others reading.
:emoji_star::emoji_star::emoji_star::emoji_star::emoji_star:

I'll have another read through the Docs. Some of the entries are helpful but only to a point, they assume a certain fluency with Skript. I'm used to using other plugins :emoji_grinning:
 
I have a new question based on the previous issue. I've tried multiple attempts at changing the particle type from a variable and keep hitting the same roadblock. Is there any way to set the particle type using a variable or function?

This is what I have so far for a simple example. In my head this should work, but it doesn't.
Code:
every 1 second:
    loop {cauldrons::*}:
        if block at loop-value is cauldron or water cauldron or lava cauldron:
            # Randomizes center coord each loop cycle so effects seem more natural
            set {_center} to loop-value
            set x-coord of {_center} to (floor(x-coord of {_center}) + random number between 0.3 and 0.7)
            set y-coord of {_center} to (floor(y-coord of {_center}) + 0.4) # Slightly above bottom
            set z-coord of {_center} to (floor(z-coord of {_center}) + random number between 0.3 and 0.7)

            set {_potionType} to "flame"
            make 1 of {_potionType} at {_center} with offset vector(0, 1, 0) with extra 5.8

On the more advanced side of things, I tried also to do this with a simple Function so in theory I could define the command once and just use the function to run potion effects based on different parameters... This however also did not work, though I didn't really get to the particle portion of the function, I think there is a problem with the overall execution.
Code:
function Cauldron-Particles(type: text, amount: number, Cauldronlocation: text; speed: number):
    make {_amount} of {_type} at {_Cauldronlocation} with offset vector(0, 0.4, 0) with extra {_speed}

Cauldron-Particles("flame", 5, "{_center}", 0.5)

Essentially, I want to be able to change the particle type based on different scenarios. I can change the effects based on the Cauldon being empty, having water or lava, etc, but not based on interaction from the player. I want to change the particles based on the type of POTION a player clicks the Cauldron with. Can you help with this or should I start a new thread?
 
OMG got it!
Code:
set {_potionType} to "flame" parsed as particle

This will make the particle parse from a variable! I've been searching google and skript docs for this for a week.