Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -830,13 +830,21 @@ export class BossBar {
export class Particle {
id: number
name: string
longDistanceRender: boolean
position: Vec3
offset: Vec3
speed: number
count: number
data: Object | undefined
movementSpeed: number
longDistanceRender: boolean
static fromNetwork(packet: Object): Particle

constructor (
id: number,
position: Vec3,
offset: Vec3,
count?: number,
movementSpeed?: number,
longDistanceRender?: boolean
);
}

export let supportedVersions: string[]
Expand Down
2 changes: 1 addition & 1 deletion lib/particle.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = loader

function loader (registry) {
class Particle {
Comment thread
NyxaYu marked this conversation as resolved.
constructor (id, position, offset, count = 1, movementSpeed = 0, longDistanceRender = false, extraData = {}) {
constructor (id, position, offset, count = 1, movementSpeed = 0, longDistanceRender = false) {
Object.assign(this, registry.particles[id])
this.id = id
this.position = position
Expand Down
33 changes: 33 additions & 0 deletions test/internalTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -721,5 +721,38 @@ for (const supportedVersion of mineflayer.testedVersions) {
})
})
})

it('particles', (done) => {
Comment thread
NyxaYu marked this conversation as resolved.
Outdated
bot.on('particle', (particle) => {
assert.strictEqual(particle.id, 0)
assert.strictEqual(particle.name, bot.registry.particles[0].name)
assert.strictEqual(particle.position.x, 32)
assert.strictEqual(particle.position.y, 64)
assert.strictEqual(particle.position.z, 32)
assert.strictEqual(particle.offset.x, 5)
assert.strictEqual(particle.offset.y, 5)
assert.strictEqual(particle.offset.z, 5)
assert.strictEqual(particle.count, 100)
assert.strictEqual(particle.movementSpeed, 0.5)
assert.strictEqual(particle.longDistanceRender, true)

done()
})

server.on('login', (client) => {
client.write('world_particles', {
particleId: 0,
x: 32,
y: 64,
z: 32,
offsetX: 5,
offsetY: 5,
offsetZ: 5,
particles: 100,
particleData: 0.5,
longDistance: true
})
})
})
})
}