Repository navigation
chore(paper/particles): update for 26.3 #814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
spa77k
wants to merge
2
commits into
PaperMC:main
Choose a base branch
from
spa77k:docs/particles-26.3
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+34
−12
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |
| title: Particles | ||
| description: A comprehensive guide to particle spawning. | ||
| slug: paper/dev/particles | ||
| version: "26.2" | ||
| version: "26.3" | ||
| --- | ||
|
|
||
| import { Tabs, TabItem, Badge } from "@astrojs/starlight/components"; | ||
|
|
@@ -41,12 +41,34 @@ The second way is using the `spawnParticle()` methods in `World` and `Player` cl | |
| ## `count` argument behavior <Badge variant="danger" text="Important" size="large" /> | ||
| When spawning particles, the Minecraft client behaves differently based on the `count` argument: | ||
| - If `count = 0`, a singular particle spawns and the client uses the provided location without modification. | ||
| The offset values are multiplied by the `extra` argument and passed to the particle constructor. The way these values are | ||
| used may vary between particle types. | ||
| The offset values are multiplied by the `speed` argument on each axis and passed to the particle constructor. | ||
| The way these values are used may vary between particle types. | ||
|
|
||
| - If `count > 0`, the client spawns `count` number of particles. For each particle, it generates new offset | ||
| values using a Gaussian (normal) distribution, multiplies them by the `extra` argument, and passes | ||
| them to the particle constructor. | ||
| values, applies them to the location, and uses the `speed` argument to calculate its initial velocity. How the | ||
| offset and speed values are randomized depends on the [randomization type](#randomization-types). | ||
|
|
||
| ### Randomization types | ||
| When `count` is greater than `0`, the client uses the selected randomization type to determine how the offset and | ||
| speed values of each particle are randomized. The type is a | ||
| [](jd:paper:org.bukkit.Particle$RandomizationType), and can be selected with | ||
| [`ParticleBuilder.randomizationType(...)`](jd:paper:com.destroystokyo.paper.ParticleBuilder#randomizationType(org.bukkit.Particle.RandomizationType)), | ||
| or by using the `spawnParticle(...)` overload that takes `speedX`, `speedY`, `speedZ` and a randomization type. | ||
| The following types are available: | ||
|
|
||
| - `DEFAULT`: multiplies each offset axis and each speed axis independently by its own Gaussian random value | ||
| (similar to `Random.nextGaussian()`, with a mean of `0` and a standard deviation of `1`). | ||
| - `ALTERNATIVE`: multiplies each offset axis independently by its own uniform random value in the range `[0, 1)`. | ||
| The speed is left unmodified. | ||
| - `ALTERNATIVE_WITH_SPEED`: multiplies each offset axis and each speed axis independently by its own uniform random | ||
| value in the range `[0, 1)`. | ||
|
|
||
| :::note | ||
| Minecraft 26.3 renamed the particle `extra` value to `speed` and split it into three axes. Use | ||
| [`ParticleBuilder.speed(double)`](jd:paper:com.destroystokyo.paper.ParticleBuilder#speed(double)) to set all axes at | ||
| once, or [`ParticleBuilder.speed(double, double, double)`](jd:paper:com.destroystokyo.paper.ParticleBuilder#speed(double,double,double)) | ||
| to set each axis individually. | ||
| ::: | ||
|
Comment on lines
+66
to
+71
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think mentioning |
||
|
|
||
| ## Directional particles | ||
| This type of particle has an initial velocity when spawned. | ||
|
|
@@ -56,15 +78,15 @@ Effective speed varies between particles. | |
| ::: | ||
|
|
||
| In the following example 8 `FLAME` particles are spawned in a 1x1x1 cube shape randomly. `someLocation` serves as its center. | ||
| The `extra` argument is set to 0, so the particles don't move. | ||
| The `speed` argument is set to 0, so the particles don't move. | ||
| <Tabs syncKey="spawn-type"> | ||
| <TabItem label="ParticleBuilder"> | ||
| ```java | ||
| Particle.FLAME.builder() | ||
| .location(someLocation) | ||
| .offset(0.5, 0.5, 0.5) | ||
| .count(8) | ||
| .extra(0) | ||
| .speed(0) | ||
| .receivers(32, true) | ||
| .spawn(); | ||
| ``` | ||
|
|
@@ -77,7 +99,7 @@ The `extra` argument is set to 0, so the particles don't move. | |
| </Tabs> | ||
|
|
||
| :::caution | ||
| Leaving the `extra` parameter unset will default it to `1`, likely resulting in unexpected behavior. | ||
| Leaving the `speed` parameter unset will default it to `1`, likely resulting in unexpected behavior. | ||
| ::: | ||
|
|
||
| ### Random direction | ||
|
|
@@ -91,7 +113,7 @@ An example of spawning 6 `CRIT` particles at a location, without offset, that wi | |
| Particle.CRIT.builder() | ||
| .location(someLocation) | ||
| .count(6) | ||
| .extra(0.6) | ||
| .speed(0.6) | ||
| .receivers(32, true) | ||
| .spawn(); | ||
| ``` | ||
|
|
@@ -117,7 +139,7 @@ An example of a repeating task spawning campfire smoke that slowly goes "up" (po | |
| .location(someLocation) | ||
| .offset(0, 1, 0) | ||
| .count(0) | ||
| .extra(0.1); | ||
| .speed(0.1); | ||
|
|
||
| Bukkit.getScheduler().runTaskTimer(plugin, () -> { | ||
| particleBuilder.receivers(32, true).spawn(); | ||
|
|
@@ -143,7 +165,7 @@ We could also make the smoke go down if we wanted to: | |
| .location(someLocation) | ||
| .offset(0, -1, 0) | ||
| .count(0) | ||
| .extra(0.1); | ||
| .speed(0.1); | ||
|
|
||
| Bukkit.getScheduler().runTaskTimer(plugin, () -> { | ||
| particleBuilder.receivers(32, true).spawn(); | ||
|
|
@@ -536,7 +558,7 @@ Example of spawning a sculk charge particle at 45° that doesn't move: | |
| Particle.SCULK_CHARGE.builder() | ||
| .location(someLocation) | ||
| .data((float) Math.toRadians(45)) | ||
| .extra(0) | ||
| .speed(0) | ||
| .receivers(32, true) | ||
| .spawn(); | ||
| ``` | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add a "The following types are available:"