| 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.GeyserBaseParticleOptions;
|
| 7 | import net.minecraft.core.particles.GeyserParticleOptions;
|
| 8 | import net.minecraft.core.particles.ParticleTypes;
|
| 9 | import net.minecraft.util.RandomSource;
|
| 10 | import org.jspecify.annotations.Nullable;
|
| 11 |
|
| 12 | @Environment(EnvType.CLIENT)
|
| 13 | public class GeyserEruptionParticle extends NoRenderParticle {
|
| 14 | public static final int BASE_PARTICLE_FREQUENCY = 2;
|
| 15 | public static final int BASE_PARTICLE_AMOUNT = 2;
|
| 16 | public static final int POOF_PARTICLE_FREQUENCY = 10;
|
| 17 | public static final int POOF_PARTICLE_AMOUNT = 20;
|
| 18 | private static final float BASE_BURST_IMPULSE = 1.5F;
|
| 19 | private static final float POOF_BURST_IMPULSE = 2.0F;
|
| 20 | private final int waterBlocks;
|
| 21 | private final double xa;
|
| 22 | private final double ya;
|
| 23 | private final double za;
|
| 24 | private final GeyserParticleOptions plumeParticle;
|
| 25 | private final GeyserBaseParticleOptions baseParticle;
|
| 26 | private final GeyserBaseParticleOptions poofParticle;
|
| 27 |
|
| 28 | protected GeyserEruptionParticle(
|
| 29 | final ClientLevel level,
|
| 30 | final double x,
|
| 31 | final double y,
|
| 32 | final double z,
|
| 33 | final double xAux,
|
| 34 | final double yAux,
|
| 35 | final double zAux,
|
| 36 | final GeyserParticleOptions options
|
| 37 | ) {
|
| 38 | super(level, x, y, z);
|
| 39 | this.xa = xAux;
|
| 40 | this.ya = yAux;
|
| 41 | this.za = zAux;
|
| 42 | this.waterBlocks = options.waterBlocks();
|
| 43 | this.lifetime = 20;
|
| 44 | this.plumeParticle = new GeyserParticleOptions(ParticleTypes.GEYSER_PLUME, this.waterBlocks);
|
| 45 | this.baseParticle = new GeyserBaseParticleOptions(ParticleTypes.GEYSER_BASE, this.waterBlocks, 1.5F);
|
| 46 | this.poofParticle = new GeyserBaseParticleOptions(ParticleTypes.GEYSER_POOF, this.waterBlocks, 2.0F);
|
| 47 | }
|
| 48 |
|
| 49 | @Override
|
| 50 | public void tick() {
|
| 51 | super.tick();
|
| 52 | if (this.age % 2 == 0) {
|
| 53 | for (int i = 0; i < 2; i++) {
|
| 54 | this.level.addParticle(this.baseParticle, this.x, this.y, this.z, this.xa, this.ya, this.za);
|
| 55 | }
|
| 56 | }
|
| 57 |
|
| 58 | for (int i = 0; i < this.waterBlocks + 2; i++) {
|
| 59 | this.level.addParticle(this.plumeParticle, this.x, this.y, this.z, this.xa, this.ya, this.za);
|
| 60 | }
|
| 61 |
|
| 62 | if (this.age % 10 == 0) {
|
| 63 | for (int i = 0; i < 20; i++) {
|
| 64 | this.level.addParticle(this.poofParticle, this.x, this.y, this.z, this.xa, this.ya, this.za);
|
| 65 | }
|
| 66 | }
|
| 67 | }
|
| 68 |
|
| 69 | @Environment(EnvType.CLIENT)
|
| 70 | public static class Provider implements ParticleProvider<GeyserParticleOptions> {
|
| 71 | public @Nullable Particle createParticle(
|
| 72 | final GeyserParticleOptions options,
|
| 73 | final ClientLevel level,
|
| 74 | final double x,
|
| 75 | final double y,
|
| 76 | final double z,
|
| 77 | final double xAux,
|
| 78 | final double yAux,
|
| 79 | final double zAux,
|
| 80 | final RandomSource random
|
| 81 | ) {
|
| 82 | return new GeyserEruptionParticle(level, x, y, z, xAux, yAux, zAux, options);
|
| 83 | }
|
| 84 | }
|
| 85 | }
|
| 86 |
|