Implemented firefly provider.
This commit is contained in:
@ -1,12 +1,17 @@
|
|||||||
package dev.micle.firefly_bush_backport.particle;
|
package dev.micle.firefly_bush_backport.particle;
|
||||||
|
|
||||||
import net.minecraft.client.multiplayer.ClientLevel;
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
import net.minecraft.client.particle.ParticleRenderType;
|
import net.minecraft.client.particle.*;
|
||||||
import net.minecraft.client.particle.TextureSheetParticle;
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.core.particles.SimpleParticleType;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
public class FireflyParticle extends TextureSheetParticle {
|
public class FireflyParticle extends TextureSheetParticle {
|
||||||
private static final float PARTICLE_FADE_OUT_LIGHT_TIME = 0.3F;
|
private static final float PARTICLE_FADE_OUT_LIGHT_TIME = 0.3F;
|
||||||
private static final float PARTICLE_FADE_IN_LIGHT_TIME = 0.1F;
|
private static final float PARTICLE_FADE_IN_LIGHT_TIME = 0.1F;
|
||||||
@ -59,4 +64,41 @@ public class FireflyParticle extends TextureSheetParticle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
public static class FireflyProvider implements ParticleProvider<SimpleParticleType> {
|
||||||
|
private final SpriteSet sprite;
|
||||||
|
|
||||||
|
public FireflyProvider(SpriteSet spriteSet) {
|
||||||
|
this.sprite = spriteSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ParametersAreNonnullByDefault
|
||||||
|
public Particle createParticle(
|
||||||
|
SimpleParticleType simpleParticleType,
|
||||||
|
ClientLevel clientLevel,
|
||||||
|
double x,
|
||||||
|
double y,
|
||||||
|
double z,
|
||||||
|
double xSpeed,
|
||||||
|
double ySpeed,
|
||||||
|
double zSpeed
|
||||||
|
) {
|
||||||
|
FireflyParticle fireflyParticle = new FireflyParticle(
|
||||||
|
clientLevel,
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
z,
|
||||||
|
0.5 - clientLevel.random.nextDouble(),
|
||||||
|
clientLevel.random.nextBoolean() ? ySpeed : -ySpeed,
|
||||||
|
0.5 - clientLevel.random.nextDouble()
|
||||||
|
);
|
||||||
|
fireflyParticle.setLifetime(clientLevel.random.nextIntBetweenInclusive(PARTICLE_MIN_LIFETIME, PARTICLE_MAX_LIFETIME));
|
||||||
|
fireflyParticle.scale(1.5F);
|
||||||
|
fireflyParticle.pickSprite(this.sprite);
|
||||||
|
fireflyParticle.setAlpha(0.0F);
|
||||||
|
|
||||||
|
return fireflyParticle;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user