2025-11-24 22:52:51 +03:00

67 lines
2.2 KiB
Java

/*
* Decompiled with CFR 0.152.
*/
package net.minecraft.client.renderer;
import net.minecraft.util.Mth;
import net.minecraft.util.RandomSource;
public class EndFlashState {
public static final int SOUND_DELAY_IN_TICKS = 30;
private static final int FLASH_INTERVAL_IN_TICKS = 600;
private static final int MAX_FLASH_OFFSET_IN_TICKS = 200;
private static final int MIN_FLASH_DURATION_IN_TICKS = 100;
private static final int MAX_FLASH_DURATION_IN_TICKS = 380;
private long flashSeed;
private int offset;
private int duration;
private float intensity;
private float oldIntensity;
private float xAngle;
private float yAngle;
public void tick(long gameTime) {
this.calculateFlashParameters(gameTime);
this.oldIntensity = this.intensity;
this.intensity = this.calculateIntensity(gameTime);
}
private void calculateFlashParameters(long gameTime) {
long newSeed = gameTime / 600L;
if (newSeed != this.flashSeed) {
RandomSource randomSource = RandomSource.create(newSeed);
randomSource.nextFloat();
this.offset = Mth.randomBetweenInclusive(randomSource, 0, 200);
this.duration = Mth.randomBetweenInclusive(randomSource, 100, Math.min(380, 600 - this.offset));
this.xAngle = Mth.randomBetween(randomSource, -60.0f, 10.0f);
this.yAngle = Mth.randomBetween(randomSource, -180.0f, 180.0f);
this.flashSeed = newSeed;
}
}
private float calculateIntensity(long gameTime) {
long gameTimeWithinInterval = gameTime % 600L;
if (gameTimeWithinInterval < (long)this.offset || gameTimeWithinInterval > (long)(this.offset + this.duration)) {
return 0.0f;
}
return Mth.sin((float)(gameTimeWithinInterval - (long)this.offset) * (float)Math.PI / (float)this.duration);
}
public float getXAngle() {
return this.xAngle;
}
public float getYAngle() {
return this.yAngle;
}
public float getIntensity(float partialTicks) {
return Mth.lerp(partialTicks, this.oldIntensity, this.intensity);
}
public boolean flashStartedThisTick() {
return this.intensity > 0.0f && this.oldIntensity <= 0.0f;
}
}