Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PrismarineJS
GitHub Repository: PrismarineJS/mineflayer
Path: blob/master/lib/particle.js
9427 views
1
const { Vec3 } = require('vec3')
2
3
module.exports = loader
4
5
function loader (registry) {
6
class Particle {
7
constructor (id, position, offset, count = 1, movementSpeed = 0, longDistanceRender = false) {
8
this.id = id
9
Object.assign(this, registry.particles[id] || registry.particlesByName[id])
10
this.position = position
11
this.offset = offset
12
this.count = count
13
this.movementSpeed = movementSpeed
14
this.longDistanceRender = longDistanceRender
15
}
16
17
static fromNetwork (packet) {
18
if (registry.supportFeature('updatedParticlesPacket')) {
19
// TODO: We add extra data that's inside packet.particle.data that varies by the particle's .type
20
return new Particle(
21
packet.particle.type,
22
new Vec3(packet.x, packet.y, packet.z),
23
new Vec3(packet.offsetX, packet.offsetY, packet.offsetZ),
24
packet.amount,
25
packet.velocityOffset,
26
packet.longDistance
27
)
28
} else {
29
return new Particle(
30
packet.particleId,
31
new Vec3(packet.x, packet.y, packet.z),
32
new Vec3(packet.offsetX, packet.offsetY, packet.offsetZ),
33
packet.particles,
34
packet.particleData,
35
packet.longDistance
36
)
37
}
38
}
39
}
40
41
return Particle
42
}
43
44