Skip to content

Particle Modifiers

MehVahdJukaar edited this page May 24, 2024 · 15 revisions

Particle Modifiers are a simple way to customize any particle in the game

While changing the behavior of a partice during its lifetime is not possible, these allow to change some simple properties of them on creation such as:

  • Color
  • Size
  • Speed
  • Lifetime

Json Format

To create one simply create a .json file in assets/[particle id namespace]/polytone/particle_modifiers/[particle id name].json will also work.

Explicit targeting

Alternatively, if you want to manually specify your targets particles, you can place this json in assets/[your pack namespace]/polytone/particle_modifiers/[some name].json (Any path will work but this is recommended to avoid overwriting Implicit defined targets). Useful if you want yo modify more than 1 target for the same json.

Then you can add the targets field containing a list of valid particle ids to the json as follows:

{
   "targets": ["minecraft:poof", "minecraft:smoke"]
}

Inside this file you'll be able to place a list of Math Expression (see Scripting Page), one for each of the values you would like to modify. Here's an example

{
   "red": "(GAMETIME % 1000)/1000",
   "size": "SIZE * 2",
   "speed": "sin(rand()*2*pi)",
   "lifetime": "20 + rand()*20"
}

Here are all the particle properties you can use to modify:

Field Name Function
colormap Particle Color (via colormap, same as block or fluid modifiers)
color Particle Color (packed color integer)
red Particle Color Red Channel (0 to 1 float)
green Particle Color Green Channel (0 to 1 float)
blue Particle Color Blue Channel (0 to 1 float)
alpha Particle Color Alpha Channel (0 to 1 float)
life Particle Lifetime in Ticks
speed Particle Initial Speed Magnitude

Filtering

Some particle types contain extra information when they are created. These include for example, terrain and item broke particleswhich, along side the before mentioned parameters, are also passed a BlockState or Itemstack of the block/item they belong to.

Filtering allows you to create a modifier that only targets particles of a certain type which have been given a certain parameter. These include BlockParticleOptions (given a BlockState) and ItemParticleOption (given an ItemStack)

To add a filter simply add the key filter to your modifier as follows. The filter object can then contain a block and/or an item field, both containing an ID for the specific block or item you want to target

{
   "filter": {
      "block": "minecraft:red_sand"
      "item": "minecraft:iron_pickaxe"
   }
}

Filtering is thus useful if you want to modify certain particle types such as dust or item break particles but dont want to change the colors and attributes of these for ALL blocks and items that these are spawned for