Skip to main content

Particles.ParticleEmitter

Particle emitter allows to change their position after spawn. It represents a coordinate system, where created particles are located and which you can move however you want.

More about capabilities

Emitter can be moved only while being in world, and it works ONLY for custom particles, not for vanilla!

Index

Constructors

constructor

  • Constructs new particle emitter with origin in given coords.


    Parameters

    • x: number
    • y: number
    • z: number

    Returns ParticleEmitter

Methods

attachTo

  • attachTo(entity: number): void
  • attachTo(entity: number, x: number, y: number, z: number): void
  • Binds the origin to the given entity's position, resets the coordinate system's speed.


    Parameters

    • entity: number

    Returns void

detach

  • detach(): void
  • Detaches the coords system from the entity and leaves it on the current position.


    Returns void

emit

  • emit(type: number, data: number, x: number, y: number, z: number): void
  • emit(type: number, data: number, x: number, y: number, z: number, vx: number, vy: number, vz: number): void
  • emit(type: number, data: number, x: number, y: number, z: number, vx: number, vy: number, vz: number, ax: number, ay: number, az: number): void
  • Spawns particle of given and data on given coords, without specified velocity and acceleration.


    Parameters

    • type: number
    • data: number
    • x: number
    • y: number
    • z: number

    Returns void

getPosition

getPositionArray

  • getPositionArray(): [number, number, number]
  • Returns [number, number, number]

    Origin's coords in float array of 3 elements.

move

  • move(x: number, y: number, z: number): void
  • Moves the coordinate system to given coords, it will cause all particles' transfer.


    Parameters

    • x: number
    • y: number
    • z: number

    Returns void

moveTo

  • moveTo(x: number, y: number, z: number): void
  • Moves the ORIGIN of the coordinate system to given coords.


    Parameters

    • x: number
    • y: number
    • z: number

    Returns void

release

  • release(): void
  • Performs the finalization of the native object of the following emitter. It means that you will no longer be able to use the following emitter after calling this method, and the object itself will be removed from the memory. Can be used for optimization purposes.


    Returns void

setEmitRelatively

  • setEmitRelatively(enable: boolean): void
  • Default is false. It means that the coords of the particles for the following emitter. will be specified in the absolute coordinate system, if enabled, they will need to be set relative to the current position of the emitter. This can be very convenient if you need to make a system of particles completely isolated from the movement of the emitter.


    Parameters

    • enable: boolean

    Returns void

setVelocity

  • setVelocity(x: number, y: number, z: number): void
  • Sets the speed of the coordinate system by each axis in blocks per tick, it can be stopped with emitter.stop() or emitter.setVelocity(0, 0, 0).


    Parameters

    • x: number
    • y: number
    • z: number

    Returns void

stop

  • stop(): void
  • Terminates any movement of the coordinate system.


    Returns void