| 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.client.particle.SuspendedParticle.SporeBlossomAirProvider.1;
|
| 7 | import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
| 8 | import net.minecraft.core.particles.SimpleParticleType;
|
| 9 | import net.minecraft.util.Mth;
|
| 10 | import net.minecraft.util.RandomSource;
|
| 11 |
|
| 12 | @Environment(EnvType.CLIENT)
|
| 13 | public class SuspendedParticle extends SingleQuadParticle {
|
| 14 | private SuspendedParticle(final ClientLevel level, final double x, final double y, final double z, final TextureAtlasSprite sprite) {
|
| 15 | super(level, x, y - 0.125, z, sprite);
|
| 16 | this.setSize(0.01F, 0.01F);
|
| 17 | this.quadSize = this.quadSize * (this.random.nextFloat() * 0.6F + 0.2F);
|
| 18 | this.lifetime = (int)(16.0 / (this.random.nextFloat() * 0.8 + 0.2));
|
| 19 | this.hasPhysics = false;
|
| 20 | this.friction = 1.0F;
|
| 21 | this.gravity = 0.0F;
|
| 22 | }
|
| 23 |
|
| 24 | private SuspendedParticle(
|
| 25 | final ClientLevel level, final double x, final double y, final double z, final double xd, final double yd, final double zd, final TextureAtlasSprite sprite
|
| 26 | ) {
|
| 27 | super(level, x, y - 0.125, z, xd, yd, zd, sprite);
|
| 28 | this.setSize(0.01F, 0.01F);
|
| 29 | this.quadSize = this.quadSize * (this.random.nextFloat() * 0.6F + 0.6F);
|
| 30 | this.lifetime = (int)(16.0 / (this.random.nextFloat() * 0.8 + 0.2));
|
| 31 | this.hasPhysics = false;
|
| 32 | this.friction = 1.0F;
|
| 33 | this.gravity = 0.0F;
|
| 34 | }
|
| 35 |
|
| 36 | @Override
|
| 37 | public SingleQuadParticle.Layer getLayer() {
|
| 38 | return SingleQuadParticle.Layer.OPAQUE;
|
| 39 | }
|
| 40 |
|
| 41 | @Environment(EnvType.CLIENT)
|
| 42 | public static class CrimsonSporeProvider implements ParticleProvider<SimpleParticleType> {
|
| 43 | private final SpriteSet sprite;
|
| 44 |
|
| 45 | public CrimsonSporeProvider(final SpriteSet sprite) {
|
| 46 | this.sprite = sprite;
|
| 47 | }
|
| 48 |
|
| 49 | public Particle createParticle(
|
| 50 | final SimpleParticleType options,
|
| 51 | final ClientLevel level,
|
| 52 | final double x,
|
| 53 | final double y,
|
| 54 | final double z,
|
| 55 | final double xAux,
|
| 56 | final double yAux,
|
| 57 | final double zAux,
|
| 58 | final RandomSource random
|
| 59 | ) {
|
| 60 | double xa = random.nextGaussian() * 1.0E-6F;
|
| 61 | double ya = random.nextGaussian() * 1.0E-4F;
|
| 62 | double za = random.nextGaussian() * 1.0E-6F;
|
| 63 | SuspendedParticle particle = new SuspendedParticle(level, x, y, z, xa, ya, za, this.sprite.get(random));
|
| 64 | particle.setColor(0.9F, 0.4F, 0.5F);
|
| 65 | return particle;
|
| 66 | }
|
| 67 | }
|
| 68 |
|
| 69 | @Environment(EnvType.CLIENT)
|
| 70 | public static class SporeBlossomAirProvider implements ParticleProvider<SimpleParticleType> {
|
| 71 | private final SpriteSet sprite;
|
| 72 |
|
| 73 | public SporeBlossomAirProvider(final SpriteSet sprite) {
|
| 74 | this.sprite = sprite;
|
| 75 | }
|
| 76 |
|
| 77 | public Particle createParticle(
|
| 78 | final SimpleParticleType options,
|
| 79 | final ClientLevel level,
|
| 80 | final double x,
|
| 81 | final double y,
|
| 82 | final double z,
|
| 83 | final double xAux,
|
| 84 | final double yAux,
|
| 85 | final double zAux,
|
| 86 | final RandomSource random
|
| 87 | ) {
|
| 88 | SuspendedParticle particle = new 1(this, level, x, y, z, 0.0, -0.8F, 0.0, this.sprite.get(random));
|
| 89 | particle.lifetime = Mth.randomBetweenInclusive(random, 500, 1000);
|
| 90 | particle.gravity = 0.01F;
|
| 91 | particle.setColor(0.32F, 0.5F, 0.22F);
|
| 92 | return particle;
|
| 93 | }
|
| 94 | }
|
| 95 |
|
| 96 | @Environment(EnvType.CLIENT)
|
| 97 | public static class UnderwaterProvider implements ParticleProvider<SimpleParticleType> {
|
| 98 | private final SpriteSet sprite;
|
| 99 |
|
| 100 | public UnderwaterProvider(final SpriteSet sprite) {
|
| 101 | this.sprite = sprite;
|
| 102 | }
|
| 103 |
|
| 104 | public Particle createParticle(
|
| 105 | final SimpleParticleType options,
|
| 106 | final ClientLevel level,
|
| 107 | final double x,
|
| 108 | final double y,
|
| 109 | final double z,
|
| 110 | final double xAux,
|
| 111 | final double yAux,
|
| 112 | final double zAux,
|
| 113 | final RandomSource random
|
| 114 | ) {
|
| 115 | SuspendedParticle particle = new SuspendedParticle(level, x, y, z, this.sprite.get(random));
|
| 116 | particle.setColor(0.4F, 0.4F, 0.7F);
|
| 117 | return particle;
|
| 118 | }
|
| 119 | }
|
| 120 |
|
| 121 | @Environment(EnvType.CLIENT)
|
| 122 | public static class WarpedSporeProvider implements ParticleProvider<SimpleParticleType> {
|
| 123 | private final SpriteSet sprite;
|
| 124 |
|
| 125 | public WarpedSporeProvider(final SpriteSet sprite) {
|
| 126 | this.sprite = sprite;
|
| 127 | }
|
| 128 |
|
| 129 | public Particle createParticle(
|
| 130 | final SimpleParticleType options,
|
| 131 | final ClientLevel level,
|
| 132 | final double x,
|
| 133 | final double y,
|
| 134 | final double z,
|
| 135 | final double xAux,
|
| 136 | final double yAux,
|
| 137 | final double zAux,
|
| 138 | final RandomSource random
|
| 139 | ) {
|
| 140 | double ya = random.nextFloat() * -1.9 * random.nextFloat() * 0.1;
|
| 141 | SuspendedParticle particle = new SuspendedParticle(level, x, y, z, 0.0, ya, 0.0, this.sprite.get(random));
|
| 142 | particle.setColor(0.1F, 0.1F, 0.3F);
|
| 143 | particle.setSize(0.001F, 0.001F);
|
| 144 | return particle;
|
| 145 | }
|
| 146 | }
|
| 147 | }
|
| 148 |
|