| 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.renderer.texture.TextureAtlasSprite;
|
| 7 | import net.minecraft.core.particles.SimpleParticleType;
|
| 8 | import net.minecraft.util.RandomSource;
|
| 9 |
|
| 10 | @Environment(EnvType.CLIENT)
|
| 11 | public class SuspendedTownParticle extends SingleQuadParticle {
|
| 12 | private SuspendedTownParticle(
|
| 13 | final ClientLevel level, final double x, final double y, final double z, final double xa, final double ya, final double za, final TextureAtlasSprite sprite
|
| 14 | ) {
|
| 15 | super(level, x, y, z, xa, ya, za, sprite);
|
| 16 | float br = this.random.nextFloat() * 0.1F + 0.2F;
|
| 17 | this.rCol = br;
|
| 18 | this.gCol = br;
|
| 19 | this.bCol = br;
|
| 20 | this.setSize(0.02F, 0.02F);
|
| 21 | this.quadSize = this.quadSize * (this.random.nextFloat() * 0.6F + 0.5F);
|
| 22 | this.xd *= 0.02F;
|
| 23 | this.yd *= 0.02F;
|
| 24 | this.zd *= 0.02F;
|
| 25 | this.lifetime = (int)(20.0 / (this.random.nextFloat() * 0.8 + 0.2));
|
| 26 | }
|
| 27 |
|
| 28 | @Override
|
| 29 | public SingleQuadParticle.Layer getLayer() {
|
| 30 | return SingleQuadParticle.Layer.OPAQUE;
|
| 31 | }
|
| 32 |
|
| 33 | @Override
|
| 34 | public void move(final double xa, final double ya, final double za) {
|
| 35 | this.setBoundingBox(this.getBoundingBox().move(xa, ya, za));
|
| 36 | this.setLocationFromBoundingbox();
|
| 37 | }
|
| 38 |
|
| 39 | @Override
|
| 40 | public void tick() {
|
| 41 | this.xo = this.x;
|
| 42 | this.yo = this.y;
|
| 43 | this.zo = this.z;
|
| 44 | if (this.lifetime-- <= 0) {
|
| 45 | this.remove();
|
| 46 | } else {
|
| 47 | this.move(this.xd, this.yd, this.zd);
|
| 48 | this.xd *= 0.99;
|
| 49 | this.yd *= 0.99;
|
| 50 | this.zd *= 0.99;
|
| 51 | }
|
| 52 | }
|
| 53 |
|
| 54 | @Environment(EnvType.CLIENT)
|
| 55 | public static class ComposterFillProvider implements ParticleProvider<SimpleParticleType> {
|
| 56 | private final SpriteSet sprite;
|
| 57 |
|
| 58 | public ComposterFillProvider(final SpriteSet sprite) {
|
| 59 | this.sprite = sprite;
|
| 60 | }
|
| 61 |
|
| 62 | public Particle createParticle(
|
| 63 | final SimpleParticleType options,
|
| 64 | final ClientLevel level,
|
| 65 | final double x,
|
| 66 | final double y,
|
| 67 | final double z,
|
| 68 | final double xAux,
|
| 69 | final double yAux,
|
| 70 | final double zAux,
|
| 71 | final RandomSource random
|
| 72 | ) {
|
| 73 | SuspendedTownParticle particle = new SuspendedTownParticle(level, x, y, z, xAux, yAux, zAux, this.sprite.get(random));
|
| 74 | particle.setColor(1.0F, 1.0F, 1.0F);
|
| 75 | particle.setLifetime(3 + level.getRandom().nextInt(5));
|
| 76 | return particle;
|
| 77 | }
|
| 78 | }
|
| 79 |
|
| 80 | @Environment(EnvType.CLIENT)
|
| 81 | public static class DolphinSpeedProvider implements ParticleProvider<SimpleParticleType> {
|
| 82 | private final SpriteSet sprite;
|
| 83 |
|
| 84 | public DolphinSpeedProvider(final SpriteSet sprite) {
|
| 85 | this.sprite = sprite;
|
| 86 | }
|
| 87 |
|
| 88 | public Particle createParticle(
|
| 89 | final SimpleParticleType options,
|
| 90 | final ClientLevel level,
|
| 91 | final double x,
|
| 92 | final double y,
|
| 93 | final double z,
|
| 94 | final double xAux,
|
| 95 | final double yAux,
|
| 96 | final double zAux,
|
| 97 | final RandomSource random
|
| 98 | ) {
|
| 99 | SuspendedTownParticle particle = new SuspendedTownParticle(level, x, y, z, xAux, yAux, zAux, this.sprite.get(random));
|
| 100 | particle.setColor(0.3F, 0.5F, 1.0F);
|
| 101 | particle.setAlpha(1.0F - random.nextFloat() * 0.7F);
|
| 102 | particle.setLifetime(particle.getLifetime() / 2);
|
| 103 | return particle;
|
| 104 | }
|
| 105 | }
|
| 106 |
|
| 107 | @Environment(EnvType.CLIENT)
|
| 108 | public static class EggCrackProvider implements ParticleProvider<SimpleParticleType> {
|
| 109 | private final SpriteSet sprite;
|
| 110 |
|
| 111 | public EggCrackProvider(final SpriteSet sprite) {
|
| 112 | this.sprite = sprite;
|
| 113 | }
|
| 114 |
|
| 115 | public Particle createParticle(
|
| 116 | final SimpleParticleType options,
|
| 117 | final ClientLevel level,
|
| 118 | final double x,
|
| 119 | final double y,
|
| 120 | final double z,
|
| 121 | final double xAux,
|
| 122 | final double yAux,
|
| 123 | final double zAux,
|
| 124 | final RandomSource random
|
| 125 | ) {
|
| 126 | SuspendedTownParticle particle = new SuspendedTownParticle(level, x, y, z, xAux, yAux, zAux, this.sprite.get(random));
|
| 127 | particle.setColor(1.0F, 1.0F, 1.0F);
|
| 128 | return particle;
|
| 129 | }
|
| 130 | }
|
| 131 |
|
| 132 | @Environment(EnvType.CLIENT)
|
| 133 | public static class HappyVillagerProvider implements ParticleProvider<SimpleParticleType> {
|
| 134 | private final SpriteSet sprite;
|
| 135 |
|
| 136 | public HappyVillagerProvider(final SpriteSet sprite) {
|
| 137 | this.sprite = sprite;
|
| 138 | }
|
| 139 |
|
| 140 | public Particle createParticle(
|
| 141 | final SimpleParticleType options,
|
| 142 | final ClientLevel level,
|
| 143 | final double x,
|
| 144 | final double y,
|
| 145 | final double z,
|
| 146 | final double xAux,
|
| 147 | final double yAux,
|
| 148 | final double zAux,
|
| 149 | final RandomSource random
|
| 150 | ) {
|
| 151 | SuspendedTownParticle particle = new SuspendedTownParticle(level, x, y, z, xAux, yAux, zAux, this.sprite.get(random));
|
| 152 | particle.setColor(1.0F, 1.0F, 1.0F);
|
| 153 | return particle;
|
| 154 | }
|
| 155 | }
|
| 156 |
|
| 157 | @Environment(EnvType.CLIENT)
|
| 158 | public static class Provider implements ParticleProvider<SimpleParticleType> {
|
| 159 | private final SpriteSet sprite;
|
| 160 |
|
| 161 | public Provider(final SpriteSet sprite) {
|
| 162 | this.sprite = sprite;
|
| 163 | }
|
| 164 |
|
| 165 | public Particle createParticle(
|
| 166 | final SimpleParticleType options,
|
| 167 | final ClientLevel level,
|
| 168 | final double x,
|
| 169 | final double y,
|
| 170 | final double z,
|
| 171 | final double xAux,
|
| 172 | final double yAux,
|
| 173 | final double zAux,
|
| 174 | final RandomSource random
|
| 175 | ) {
|
| 176 | return new SuspendedTownParticle(level, x, y, z, xAux, yAux, zAux, this.sprite.get(random));
|
| 177 | }
|
| 178 | }
|
| 179 | }
|
| 180 |
|