# ParticleBuilder and ParticleWizardry

{% hint style="warning" %}
This page has is code related, important for addon developers.
{% endhint %}

Electroblob's Wizardry don't use the usual system of particles to spawn them, in change, use a custom and "chained" system to spawn them and register all the particles.

You will see this change by searching in the particle command one of the custom particles:&#x20;

\[Insert GIF of any particle with white texture or something]

But... Why is this happening?... Simple, This mod register (mostly) white textures in their particles to change them later using the ParticleBuilder class, and now you're saying, what's ParticleBuilder class?&#x20;

ParticleBuilder is a utility class used by Ebwizardry that simplifies the creation of the particles in Minecraft. This class provides a chained system to spawn a particle in just one line of code and setting new various properties to this particle such as color, scale, lifetime, fade, and more.

This is supported thanks to ParticleWizardry, but we don't need to know about how is works, if you're interested to add particles to use in this system, see it below.

Simple example using the ParticleBuilder:

Start building a Particle calling any `create(DefaultParticleType particle)` method. This method takes a DefaultParticleType object as an argument, which represents the type of particle to be created. (This particle needs to extend ParticleWizardry)

```
ParticleBuilder.create(WizardryParticles.LEAF)
```

And now we need to set the position.

```
ParticleBuilder.create(WizardryParticles.LEAF).pos(this.getX(), this.getY(), this.getZ())
```

Now we could just spawn the particle:

```
            ParticleBuilder.create(WizardryParticles.LEAF).pos(this.getX(), this.getY(), this.getZ()).spawn(getWorld());
```

And this is the result:

\[Gif for reference]

This was just a simple example about what ParticleBuilder can do, but you can see more cases that work very well!

Some examples:

Poison Spell

```
ParticleBuilder.create(WizardryParticles.DARK_MAGIC).pos(x, y, z).color(0.3f, 0.7f, 0).spawn(world);
ParticleBuilder.create(WizardryParticles.SPARKLE).pos(x, y, z).time(12 + world.random.nextInt(8)).color(0.1f, 0.4f, 0).spawn(world);
```

\[Spell GIF]

Frost Ray

```
ParticleBuilder.create(WizardryParticles.SPARKLE).pos(x, y, z).velocity(vx, vy, vz).time(8 + world.random.nextInt(12)).color(0.4f + 0.6f * brightness, 0.6f + 0.4f * brightness, 1).collide(true).spawn(world);
ParticleBuilder.create(WizardryParticles.SNOW).pos(x, y, z).velocity(vx, vy, vz).time(8 + world.random.nextInt(12)).collide(true).spawn(world);
```

\[Spell GIF]

Magic Missile

```
ParticleBuilder.create(WizardryParticles.SPARKLE, random, prevX, prevY, prevZ, 0.03, true).color(1, 1, 0.65f).time(20 + random.nextInt(10)).fade(0.7f, 0, 1).spawn(getWorld());

double x = prevX - getVelocity().getX() / 2;
double y = prevY - getVelocity().getY() / 2;
double z = prevZ - getVelocity().getZ() / 2;

ParticleBuilder.create(WizardryParticles.SPARKLE, random, x, y, z, 0.03, true).color(1, 1, 0.65f).time(20 + random.nextInt(10)).fade(0.7f, 0, 1).spawn(getWorld());
```

\[Spell GIF]


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://electroblobs-wizardry.gitbook.io/home/dev/particlebuilder-and-particlewizardry.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
