generated from MrSphay/codex-agent-repository-kit
This commit is contained in:
@@ -1,18 +1,78 @@
|
||||
package com.vinlanx.explosionoverhaul.client;
|
||||
|
||||
import com.vinlanx.explosionoverhaul.Config;
|
||||
import com.vinlanx.explosionoverhaul.CustomGlowParticleOptions;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.particle.ParticleRenderType;
|
||||
import net.minecraft.client.particle.SpriteSet;
|
||||
import net.minecraft.client.particle.TextureSheetParticle;
|
||||
import net.minecraft.util.Mth;
|
||||
|
||||
public class CustomGlowParticle extends TextureSheetParticle {
|
||||
public CustomGlowParticle(ClientLevel level, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed, CustomGlowParticleOptions options) {
|
||||
private final SpriteSet sprites;
|
||||
private final float baseSize;
|
||||
|
||||
public CustomGlowParticle(ClientLevel level, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed, CustomGlowParticleOptions options, SpriteSet sprites) {
|
||||
super(level, x, y, z, xSpeed, ySpeed, zSpeed);
|
||||
this.lifetime = 1;
|
||||
this.sprites = sprites;
|
||||
Config.Client.ParticleRenderMode mode = Config.CLIENT.particleRenderMode.get();
|
||||
float configScale = ((Double)Config.CLIENT.particleSizeScale.get()).floatValue();
|
||||
float powerScale = Mth.clamp(options.getPower() / 4.0f, 0.8f, 4.0f);
|
||||
this.baseSize = options.getScale() * configScale * powerScale * (0.85f + this.random.nextFloat() * 0.35f);
|
||||
this.lifetime = switch (mode) {
|
||||
case REALISTIC -> 34 + this.random.nextInt(15);
|
||||
case REALISTIC_2 -> 44 + this.random.nextInt(22);
|
||||
case VANILA -> 22 + this.random.nextInt(12);
|
||||
};
|
||||
this.quadSize = this.baseSize;
|
||||
this.friction = 0.88f;
|
||||
this.gravity = mode == Config.Client.ParticleRenderMode.VANILA ? -0.01f : -0.018f;
|
||||
this.hasPhysics = false;
|
||||
this.xd = xSpeed * 0.85;
|
||||
this.yd = ySpeed * 0.85 + 0.01;
|
||||
this.zd = zSpeed * 0.85;
|
||||
this.alpha = 0.92f;
|
||||
this.pickSprite(sprites);
|
||||
applyModeColor(mode, options.getZone());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParticleRenderType getRenderType() {
|
||||
return ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
if (this.age >= this.lifetime) {
|
||||
return;
|
||||
}
|
||||
float progress = this.age / (float)this.lifetime;
|
||||
this.setSpriteFromAge(this.sprites);
|
||||
this.alpha = Mth.clamp(1.0f - progress, 0.0f, 1.0f) * 0.92f;
|
||||
this.quadSize = this.baseSize * (0.8f + progress * 1.8f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCull() {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void applyModeColor(Config.Client.ParticleRenderMode mode, int zone) {
|
||||
if (mode == Config.Client.ParticleRenderMode.VANILA) {
|
||||
this.rCol = zone == 0 ? 1.0f : 0.95f;
|
||||
this.gCol = zone == 0 ? 0.55f : 0.72f;
|
||||
this.bCol = zone == 0 ? 0.15f : 0.3f;
|
||||
return;
|
||||
}
|
||||
if (mode == Config.Client.ParticleRenderMode.REALISTIC_2) {
|
||||
this.rCol = zone == 0 ? 1.0f : 0.82f;
|
||||
this.gCol = zone == 0 ? 0.76f : 0.92f;
|
||||
this.bCol = zone == 0 ? 0.42f : 1.0f;
|
||||
return;
|
||||
}
|
||||
this.rCol = zone == 0 ? 1.0f : 1.0f;
|
||||
this.gCol = zone == 0 ? 0.48f : 0.72f;
|
||||
this.bCol = zone == 0 ? 0.08f : 0.2f;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user