Particles
Index
Classes
ParticleAnimator
Animators allow to change some properties of the specific particle depending on the time.
Mostly for internal use, put animators' descriptors into animators
parameter of custom particle type instead.
constructor
Constructs new Particles.ParticleAnimator object from given needed params.
Parameters
period: number
fadeInTime: number
fadeInValue: number
fadeOutTime: number
fadeOutValue: number
Returns ParticleAnimator
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.
constructor
Constructs new particle emitter with origin in given coords.
Parameters
x: number
y: number
z: number
Returns ParticleEmitter
attachTo
Binds the origin to the given entity's position, resets the coordinate system's speed.
Parameters
entity: number
Returns void
detach
Detaches the coords system from the entity and leaves it on the current position.
Returns void
emit
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
Returns [number, number, number]
Origin's coords in float array of 3 elements.
move
Moves the coordinate system to given coords, it will cause all particles' transfer.
Parameters
x: number
y: number
z: number
Returns void
moveTo
Moves the ORIGIN of the coordinate system to given coords.
Parameters
x: number
y: number
z: number
Returns void
release
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
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
Sets the speed of the coordinate system by each axis in blocks per tick, it can be stopped with
emitter.stop()
oremitter.setVelocity(0, 0, 0)
.Parameters
x: number
y: number
z: number
Returns void
stop
Terminates any movement of the coordinate system.
Returns void
ParticleSubEmitter
Sub-emitters describe how specific particle can emit other particles,
according to some events, that may happen to it.
Mostly for internal use, put sub-emitters descriptors into emitters
.
constructor
Constructs new Particles.ParticleSubEmitter object from given needed params.
Parameters
chance: number
count: number
type: number
data: number
Returns ParticleSubEmitter
setKeepEmitter
Parameters
keepEmitter: boolean
If true, the new particle will save the emitter that was used for it's creation if it had been.
Returns void
setKeepVelocity
Parameters
keepVelocity: boolean
If true, the new particle will have the velocity of the particle, that calls the sub-emitter, at the time of invocation; default is false
Returns void
setRandomVelocity
Emitted particles will receive random initial speed.
Parameters
maxRandomVelocity: number
Returns void
ParticleType
Class to create custom particle types. Mostly for internal use, you can use Particles.registerParticleType instead.
constructor
Constructs new Particles.ParticleType object from given needed params.
Parameters
textureName: string
minU: number
minV: number
maxU: number
maxV: number
textureCountHorizontal: number
textureCountVertical: number
isUsingBlockLight: boolean
Returns ParticleType
getId
Returns number
Following particle type's numeric ID.
setAnimator
Parameters
name: size | icon | alpha | color
animator: ParticleAnimator
Returns void
setCollisionParams
Parameters
collision: boolean
keepVelocityAfterImpact: boolean
addLifetimeAfterImpact: number
Returns void
setColor
Parameters
r: number
g: number
b: number
a: number
Returns void
setDefaultAcceleration
Parameters
x: number
y: number
z: number
Returns void
setDefaultVelocity
Parameters
x: number
y: number
z: number
Returns void
setFriction
Parameters
air: number
block: number
Returns void
setLifetime
Parameters
min: number
max: number
Returns void
setRebuildDelay
Parameters
delay: number
Returns void
setRenderType
Parameters
renderType: 0 | 1 | 2
Returns void
setSize
Parameters
min: number
max: number
Returns void
setSubEmitter
Parameters
name: idle | impact | death
emitter: ParticleSubEmitter
Returns void
Interfaces
AnimatorDescription
Custom particle's animator params object.
optionalend
Ending value.
optionalfadeIn
Appearance moment in the proportions of the period.
optionalfadeOut
Disappearance moment in the proportions of the period.
optionalperiod
Animator's period in ticks, if it's less than zero or not listed, it'll be particle's lifetime.
optionalstart
Initial value.
ColorAnimatorDescription
Custom particle's animator params object.
optionalend
Ending value.
optionalfadeIn
Appearance moment in the proportions of the period.
optionalfadeOut
Disappearance moment in the proportions of the period.
optionalperiod
Animator's period in ticks, if it's less than zero or not listed, it'll be particle's lifetime.
optionalstart
Initial value.
IAnimatorDescription
Custom particle's animator params object.
optionalfadeIn
Appearance moment in the proportions of the period.
optionalfadeOut
Disappearance moment in the proportions of the period.
optionalperiod
Animator's period in ticks, if it's less than zero or not listed, it'll be particle's lifetime.
ParticleDescription
Custom particle type params object.
optionalacceleration
Particle's acceleration, if it's spawned without this parameter.
optionaladdLifetimeAfterImpact
Particle will lose given number of ticks from it's maximum lifetime, when touching a block.
optionalanimators
Animators allow to change some properties of the specific particle depending on the time, each animator is described as an object of definite format and can be not described, if it's not needed.
Type declaration
optionalalpha?: AnimatorDescription
Describes the particle's opacity, for the unit value the
alpha
in thecolor
parameter from the type's description is taken.optionalcolor?: ColorAnimatorDescription
Describes the animated color value, if particle supports it. Accepts values in RGBA ranges, like
color
property in descriptor.optionalicon?: AnimatorDescription
Describes the animation frame, if particle supports it. Must have the value between 0 and 1.
optionalsize?: AnimatorDescription
Describes the behavior of particle's size, for the unit size the size from the type's description is taken.
optionaltexture?: AnimatorDescription
Describes the animation frame, if particle supports it. Must have the value between 0 and 1.
optionalcollision
If true
, particle won't go through blocks. It reduces performance if
there are lots of these particles.
optionalcolor
Four component color of the particle (RGBA).
optionalcolor2
optionalemitters
Sub-emitters (don't confuse with emitters) describe how specific particle can emit other particles, according to some events, that may happen to it. Each sub-emitter is described as an object of definite format and can be not described if it's not needed.
Type declaration
optionaldeath?: SubEmitterDescription
Called at the end of particle's life.
optionalidle?: SubEmitterDescription
Called every tick.
optionalimpact?: SubEmitterDescription
Called when touching a block, makes sense only if collision parameter is
true
.
optionalframesX
Animation frame grid size around width.
optionalframesY
Animation frame grid size around height.
optionalfriction
Particle's speed modifier in the air and when touching a block. Usually it's a number between 0 and 1, close to 1, but in fact it can be any value. Both values are 1 by default.
Type declaration
optionalair?: number
optionalblock?: number
optionalisUsingBlockLight
If true
, the particle will be exposed to the world's lighting.
If false
, the particle will always have maximum brightness.
Enabling this parameter may reduce the performance when having lots of particles.
optionalkeepVelocityAfterImpact
If false
, particle's speed will be set to zero when touching a block.
If true
, the speed will be saved.
lifetime
Minimum and maximum particle's lifetime in ticks.
optionalrebuildDelay
Time in ticks between particle mesh updates.
optionalrender
Particle's render type:
- 0 - additive
- 1 - without blending
- 2 - with blending
size
Minimum and maximum size of the particle.
texture
Particle's texture name from /particle-atlas resource directory.
optionalvelocity
Particle's initial velocity, if it's spawned without initial speed parameter.
SubEmitterDescription
Custom particle's sub-emitter params object.
optionalchance
Triggering float chance from 0 to 1.
optionalcount
Particles count for the single emit time.
optionaldata
Additional data of the emitted particle.
optionalkeepEmitter
If true, the new particle will save the emitter that was used for it's creation if it had been.
optionalkeepVelocity
If true
, the new particle will have the velocity of the particle,
that calls the sub-emitter, at the time of invocation.
optionalrandomize
If this value is listed, emitted particles will receive random initial speed,
that isn't more than value * sqrt(3)
.
type
Emitted particle's type numeric ID.
Functions
addBreakingItemParticle
Spawns EParticleType.ITEM_BREAK particles at a given location with a given item in world.
Parameters
id: number
numeric item ID
data: number
item data
x: number
y: number
z: number
Returns void
addFarParticle
Same as Particles.addParticle, but applies
far
shader to the particle.Parameters
type: number
x: number
y: number
z: number
vx: number
vy: number
vz: number
optionaldata: number
Returns void
addParticle
Spawns particle of given type on given coords with given velocity and additional parameters in the world.
Parameters
type: number
particle type's numeric ID; if you want to spawn vanilla particles, see EParticleType enums
x: number
y: number
z: number
vx: number
velocity for the particle by X-axis
vy: number
velocity for the particle by Y-axis
vz: number
velocity for the particle by Z-axis
optionaldata: number
additional params, currently don't know how to use, just put 0
Returns void
getParticleTypeById
Parameters
id: number
Returns ParticleType
Object Particles.ParticleType of the particle by given ID, if it exists.
line
Spawnds particles in line with specified gapness.
Parameters
type: number
particle type's numeric ID; if you want to spawn vanilla particles, see EParticleType enums
coords1: Vector
start location of line
coords2: Vector
end location of line
optionalgap: number
gapness means step of particles, values more than 1 will increase offsets between particles; randomized
optionalvel: Vector
velocity of spawned particles
optionaldata: number
variant of spawned particles or properties
Returns void
registerParticleType
Registers new custom particle type of given params object.
Parameters
descriptor: ParticleDescription
Returns number
Created particle type's numeric ID.
Module to work with vanilla and custom particles.