-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add a native mineflayer event for particles #2813
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
Merged
Merged
Changes from 12 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
b7fe11a
Added particle stuff
NyxaYu 1545807
linting fix
NyxaYu 2ce8700
Changed from a class to a function
NyxaYu d1b88e8
Rename longDistance to forceRender, detail it more in api docs
NyxaYu cd6d9ad
Rename particleData to speed
NyxaYu a6dc0d4
Rename particles to count
NyxaYu 223145a
Bug fixes
NyxaYu 3aba1a0
Doctoc regen
NyxaYu 0f907ec
Revert back to class, change forceRender to longDistanceRender
NyxaYu 4888181
Improve class
NyxaYu c24c3f1
Update docs
NyxaYu b02cf26
Linting fix
NyxaYu 7dad1ac
Remove extraData
NyxaYu 79bf68b
Remove unused variable
NyxaYu ac1d811
Update definition
NyxaYu a65b5b9
Added internal test
NyxaYu f69e326
Better test
NyxaYu f185000
Linting fix
NyxaYu 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
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
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
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 |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| const { Vec3 } = require('vec3') | ||
|
|
||
| module.exports = loader | ||
|
|
||
| function loader (registry) { | ||
| class Particle { | ||
|
NyxaYu marked this conversation as resolved.
|
||
| constructor (id, position, offset, count = 1, movementSpeed = 0, longDistanceRender = false, extraData = {}) { | ||
| Object.assign(this, registry.particles[id]) | ||
| this.id = id | ||
| this.position = position | ||
| this.offset = offset | ||
| this.count = count | ||
| this.movementSpeed = movementSpeed | ||
| this.longDistanceRender = longDistanceRender | ||
| Object.assign(this, extraData) // Particle-specific data that can vary by version | ||
| } | ||
|
|
||
| static fromNetwork (packet) { | ||
| return new Particle( | ||
| packet.particleId, | ||
| new Vec3(packet.x, packet.y, packet.z), | ||
| new Vec3(packet.offsetX, packet.offsetY, packet.offsetZ), | ||
| packet.particles, | ||
| packet.particleData, | ||
| packet.longDistance, | ||
| packet.data | ||
|
NyxaYu marked this conversation as resolved.
Outdated
|
||
| ) | ||
| } | ||
| } | ||
|
|
||
| return Particle | ||
| } | ||
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 |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| module.exports = inject | ||
|
|
||
| function inject (bot, { version }) { | ||
| const Particle = require('../particle')(bot.registry) | ||
|
|
||
| bot._client.on('world_particles', (packet) => { | ||
| bot.emit('particle', Particle.fromNetwork(packet)) | ||
| }) | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.