-
-
Notifications
You must be signed in to change notification settings - Fork 265
feat(paper): 26.2 Particles #763
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
Privatech38
wants to merge
7
commits into
PaperMC:main
Choose a base branch
from
Privatech38:feat/particles-26-2
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.
+118
−1
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4a3dfc7
Document geyser base and poof particles
Privatech38 5966f10
Document plume and emitter particles
Privatech38 2665edd
feat: Add data types for geyser particles and hyperlink them to JavaDoc
Privatech38 41a7d1d
feat: Mention particle size definition for geyser base particles
Privatech38 6c3b454
feat(particles): Add examples for geyser base/poof and plume particles
Privatech38 5ef12fb
feat(particles): Add an example for the geyser emitter particle
Privatech38 993a792
fix(particles): Fix note for Geyser emitter particle about data
Privatech38 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.1.1 | ||||||
| version: "26.2" | ||||||
| --- | ||||||
|
|
||||||
| import { Tabs, TabItem, Badge } from "@astrojs/starlight/components"; | ||||||
|
|
@@ -731,6 +731,123 @@ one with a scale of `4.0` right after: | |||||
|
|
||||||
|  | ||||||
|
|
||||||
| ## Geyser particles | ||||||
| There are four geyser particles: `GEYSER_BASE`, `GEYSER_POOF`, `GEYSER_PLUME` and `GEYSER`. | ||||||
|
|
||||||
| ### Base and poof | ||||||
| `GEYSER_BASE` and `GEYSER_POOF` particles function identically, differing only in appearance.They use | ||||||
| [`Particle.GeyserBase`](jd:paper:org.bukkit.Particle$GeyserBase) as their data. | ||||||
|
|
||||||
| The particle size is calculated as `3.0F + 0.125F * waterBlocks`. | ||||||
|
|
||||||
| The spawn position of these particles is slightly altered by adding a random offset to each coordinate. The x and z | ||||||
| coordinates are altered by a random value in the range `[-0.25, 0.25]`, while the y coordinate is altered by a random | ||||||
| value in the range `[-0.05, 0.45]`. | ||||||
|
|
||||||
| They are [directional particles](#directional-particles), but are also affected by the water blocks and burst impulse | ||||||
| parameters. The initial velocity is calculated as follows: | ||||||
| ```java | ||||||
| float burstImpulse = burstImpulseBase + 0.25F * waterBlocks; | ||||||
|
|
||||||
| // xd, yd and zd are the particle velocity's x, y and z components respectively | ||||||
| // xAux, yAux and zAux are the provided velocity vector's x, y and z components respectively | ||||||
| this.xd = this.xd * burstImpulse + xAux; | ||||||
| this.yd = this.yd * burstImpulse + yAux; | ||||||
| this.zd = this.zd * burstImpulse + zAux; | ||||||
|
|
||||||
| this.yd = Math.abs(this.yd); | ||||||
| ``` | ||||||
|
|
||||||
| :::note | ||||||
| Starting values of `xd` and `zd` are in the range [-0.1, 0.1], while `yd` is in the range [0.0, 0.2]. | ||||||
|
Member
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.
Suggested change
You put the other number ranges into code blocks too, so I'd repeat it here. |
||||||
| ::: | ||||||
|
|
||||||
| An example of spawning a geyser base particle at `someLocation` with a burst impulse of `1` and 1 water block: | ||||||
| <Tabs syncKey="spawn-type"> | ||||||
| <TabItem label="ParticleBuilder"> | ||||||
| ```java | ||||||
| ParticleBuilder particleBuilder = Particle.GEYSER_BASE.builder() | ||||||
| .location(someLocation) | ||||||
| .offset(0, 0, 0) | ||||||
| .count(0) | ||||||
| .receivers(32, true) | ||||||
| .data(new Particle.GeyserBase(1, 1)) | ||||||
| .spawn(); | ||||||
| ``` | ||||||
| </TabItem> | ||||||
| <TabItem label="spawnParticle"> | ||||||
| ```java | ||||||
| someWorld.spawnParticle(Particle.GEYSER_BASE, someLocation, 0, 0, 0, 0, new Particle.GeyserBase(1, 1)); | ||||||
| ``` | ||||||
| </TabItem> | ||||||
| </Tabs> | ||||||
|
|
||||||
|  | ||||||
|
|
||||||
| ### Plume | ||||||
| The `GEYSER_PLUME` particle uses [`Particle.Geyser`](jd:paper:org.bukkit.Particle$Geyser) as its data. | ||||||
|
|
||||||
| The spawn position of these particles is slightly altered by adding a random offset to each coordinate. The x and z | ||||||
| coordinates are altered by a random value in the range `[-0.1, 0.1]`, while the y coordinate is altered by a random | ||||||
| value in the range `[-0.5, 0.5]`. | ||||||
|
|
||||||
| While technically a [directional particle](#directional-particles), the vertical velocity of this particle is set to `0` | ||||||
| and the horizontal velocity is applied only on the first tick. | ||||||
|
|
||||||
| The height of the plume is calculated as `5 * waterBlocks`. | ||||||
|
|
||||||
| An example of spawning a geyser plume particle at `someLocation` with 1 water block: | ||||||
| <Tabs syncKey="spawn-type"> | ||||||
| <TabItem label="ParticleBuilder"> | ||||||
| ```java | ||||||
| ParticleBuilder particleBuilder = Particle.GEYSER_PLUME.builder() | ||||||
| .location(someLocation) | ||||||
| .offset(0, 0, 0) | ||||||
| .count(0) | ||||||
| .receivers(32, true) | ||||||
| .data(new Particle.Geyser(1)) | ||||||
| .spawn(); | ||||||
| ``` | ||||||
| </TabItem> | ||||||
| <TabItem label="spawnParticle"> | ||||||
| ```java | ||||||
| someWorld.spawnParticle(Particle.GEYSER_PLUME, someLocation, 0, 0, 0, 0, new Particle.Geyser(1)); | ||||||
| ``` | ||||||
| </TabItem> | ||||||
| </Tabs> | ||||||
|
|
||||||
|  | ||||||
|
|
||||||
| ### Emitter | ||||||
| The `GEYSER` particle is an emitter particle, meaning it spawns other particles. In this case, it spawns all the previously | ||||||
| mentioned geyser particles. The provided velocity vector is passed to the spawned particles and used as described above. | ||||||
|
|
||||||
| This particle uses [`Particle.Geyser`](jd:paper:org.bukkit.Particle$Geyser) as its data. | ||||||
|
|
||||||
| The geyser base particle's burst impulse base is set to `1.5` and the poof particle's burst impulse base is set to `2.0`. | ||||||
|
|
||||||
| An example of spawning a geyser particle at `someLocation` with 1 water block: | ||||||
| <Tabs syncKey="spawn-type"> | ||||||
| <TabItem label="ParticleBuilder"> | ||||||
| ```java | ||||||
| ParticleBuilder particleBuilder = Particle.GEYSER.builder() | ||||||
| .location(someLocation) | ||||||
| .offset(0, 0, 0) | ||||||
| .count(0) | ||||||
| .receivers(32, true) | ||||||
| .data(new Particle.Geyser(1)) | ||||||
| .spawn(); | ||||||
| ``` | ||||||
| </TabItem> | ||||||
| <TabItem label="spawnParticle"> | ||||||
| ```java | ||||||
| someWorld.spawnParticle(Particle.GEYSER, someLocation, 0, 0, 0, 0, new Particle.Geyser(1)); | ||||||
| ``` | ||||||
| </TabItem> | ||||||
| </Tabs> | ||||||
|
|
||||||
|  | ||||||
|
|
||||||
| ## Miscellaneous behaviors | ||||||
| This chapter covers particles that have unique behaviors when spawning. | ||||||
|
|
||||||
|
|
||||||
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.