| 1 | package net.minecraft.client.particle;
|
| 2 |
|
| 3 | import net.fabricmc.api.EnvType;
|
| 4 | import net.fabricmc.api.Environment;
|
| 5 | import net.minecraft.client.multiplayer.ClientLevel;
|
| 6 | import net.minecraft.core.particles.ParticleTypes;
|
| 7 | import net.minecraft.core.particles.SimpleParticleType;
|
| 8 | import net.minecraft.util.RandomSource;
|
| 9 |
|
| 10 | @Environment(EnvType.CLIENT)
|
| 11 | public class GustSeedParticle extends NoRenderParticle {
|
| 12 | private final double scale;
|
| 13 | private final int tickDelayInBetween;
|
| 14 |
|
| 15 | private GustSeedParticle(
|
| 16 | final ClientLevel level, final double x, final double y, final double z, final double scale, final int lifetime, final int tickDelayInBetween
|
| 17 | ) {
|
| 18 | super(level, x, y, z, 0.0, 0.0, 0.0);
|
| 19 | this.scale = scale;
|
| 20 | this.lifetime = lifetime;
|
| 21 | this.tickDelayInBetween = tickDelayInBetween;
|
| 22 | }
|
| 23 |
|
| 24 | @Override
|
| 25 | public void tick() {
|
| 26 | if (this.age % (this.tickDelayInBetween + 1) == 0) {
|
| 27 | for (int i = 0; i < 3; i++) {
|
| 28 | double x = this.x + (this.random.nextDouble() - this.random.nextDouble()) * this.scale;
|
| 29 | double y = this.y + (this.random.nextDouble() - this.random.nextDouble()) * this.scale;
|
| 30 | double z = this.z + (this.random.nextDouble() - this.random.nextDouble()) * this.scale;
|
| 31 | this.level.addParticle(ParticleTypes.GUST, x, y, z, (float)this.age / this.lifetime, 0.0, 0.0);
|
| 32 | }
|
| 33 | }
|
| 34 |
|
| 35 | if (this.age++ == this.lifetime) {
|
| 36 | this.remove();
|
| 37 | }
|
| 38 | }
|
| 39 |
|
| 40 | @Environment(EnvType.CLIENT)
|
| 41 | public static class Provider implements ParticleProvider<SimpleParticleType> {
|
| 42 | private final double scale;
|
| 43 | private final int lifetime;
|
| 44 | private final int tickDelayInBetween;
|
| 45 |
|
| 46 | public Provider(final double scale, final int lifetime, final int tickDelayInBetween) {
|
| 47 | this.scale = scale;
|
| 48 | this.lifetime = lifetime;
|
| 49 | this.tickDelayInBetween = tickDelayInBetween;
|
| 50 | }
|
| 51 |
|
| 52 | public Particle createParticle(
|
| 53 | final SimpleParticleType options,
|
| 54 | final ClientLevel level,
|
| 55 | final double x,
|
| 56 | final double y,
|
| 57 | final double z,
|
| 58 | final double xAux,
|
| 59 | final double yAux,
|
| 60 | final double zAux,
|
| 61 | final RandomSource random
|
| 62 | ) {
|
| 63 | return new GustSeedParticle(level, x, y, z, this.scale, this.lifetime, this.tickDelayInBetween);
|
| 64 | }
|
| 65 | }
|
| 66 | }
|
| 67 |
|