generated from MrSphay/codex-agent-repository-kit
This commit is contained in:
@@ -1,124 +1,21 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.vinlanx.explosionoverhaul.client;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(value=Dist.CLIENT)
|
||||
public class CameraShakeConcussionEffect {
|
||||
private static final int FADE_IN_TICKS = 40;
|
||||
private static final int FADE_OUT_TICKS = 40;
|
||||
private static Phase phase = Phase.IDLE;
|
||||
private static int ticksInPhase = 0;
|
||||
private static int holdTicks = 0;
|
||||
private static float currentIntensity = 0.0f;
|
||||
private static float targetIntensity = 0.0f;
|
||||
private static float lastYawOffset = 0.0f;
|
||||
private static float lastPitchOffset = 0.0f;
|
||||
|
||||
public static boolean isActive() {
|
||||
return phase != Phase.IDLE;
|
||||
}
|
||||
|
||||
public static void start(int seconds, float intensity) {
|
||||
int newHoldTicks = Mth.m_14045_((int)seconds, (int)1, (int)100) * 20;
|
||||
float newIntensity = Math.max(0.0f, intensity);
|
||||
if (phase != Phase.IDLE) {
|
||||
targetIntensity += newIntensity;
|
||||
holdTicks = Math.min(2000, holdTicks + newHoldTicks);
|
||||
if (phase == Phase.FADE_OUT) {
|
||||
phase = Phase.HOLD;
|
||||
ticksInPhase = 0;
|
||||
}
|
||||
} else {
|
||||
targetIntensity = newIntensity;
|
||||
holdTicks = newHoldTicks;
|
||||
ticksInPhase = 0;
|
||||
phase = Phase.FADE_IN;
|
||||
currentIntensity = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
public static void onClientTick() {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
if (mc.m_91104_()) {
|
||||
return;
|
||||
}
|
||||
LocalPlayer player = mc.player;
|
||||
if (player == null) {
|
||||
CameraShakeConcussionEffect.stop();
|
||||
return;
|
||||
}
|
||||
player.m_19884_((double)(-lastYawOffset), (double)(-lastPitchOffset));
|
||||
lastYawOffset = 0.0f;
|
||||
lastPitchOffset = 0.0f;
|
||||
if (phase == Phase.IDLE) {
|
||||
return;
|
||||
}
|
||||
++ticksInPhase;
|
||||
switch (phase) {
|
||||
case FADE_IN: {
|
||||
float t = (float)ticksInPhase / 40.0f;
|
||||
currentIntensity = CameraShakeConcussionEffect.easeInOutCubic(t) * targetIntensity;
|
||||
if (ticksInPhase < 40) break;
|
||||
phase = Phase.HOLD;
|
||||
ticksInPhase = 0;
|
||||
break;
|
||||
}
|
||||
case HOLD: {
|
||||
currentIntensity = targetIntensity;
|
||||
if (ticksInPhase < holdTicks) break;
|
||||
phase = Phase.FADE_OUT;
|
||||
ticksInPhase = 0;
|
||||
break;
|
||||
}
|
||||
case FADE_OUT: {
|
||||
float t = (float)ticksInPhase / 40.0f;
|
||||
currentIntensity = targetIntensity * CameraShakeConcussionEffect.easeInOutCubic(1.0f - t);
|
||||
if (ticksInPhase < 40) break;
|
||||
CameraShakeConcussionEffect.stop();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (currentIntensity > 0.0f) {
|
||||
CameraShakeConcussionEffect.applySway(player, (float)player.f_19797_ + mc.m_91296_());
|
||||
}
|
||||
}
|
||||
|
||||
private static void applySway(LocalPlayer player, float totalTicks) {
|
||||
float horizontalSway = Mth.m_14031_((float)(totalTicks * 0.04f)) * 1.5f + Mth.m_14031_((float)(totalTicks * 0.025f)) * 1.0f;
|
||||
float verticalSway = Mth.m_14089_((float)(totalTicks * 0.035f)) * 0.8f + Mth.m_14031_((float)(totalTicks * 0.015f)) * 0.5f;
|
||||
float yawChange = horizontalSway * currentIntensity * 50.0f;
|
||||
float pitchChange = verticalSway * currentIntensity * 30.0f;
|
||||
player.m_19884_((double)yawChange, (double)pitchChange);
|
||||
lastYawOffset = yawChange;
|
||||
lastPitchOffset = pitchChange;
|
||||
}
|
||||
|
||||
public static void stop() {
|
||||
phase = Phase.IDLE;
|
||||
ticksInPhase = 0;
|
||||
holdTicks = 0;
|
||||
currentIntensity = 0.0f;
|
||||
targetIntensity = 0.0f;
|
||||
lastYawOffset = 0.0f;
|
||||
lastPitchOffset = 0.0f;
|
||||
}
|
||||
|
||||
private static float easeInOutCubic(float t) {
|
||||
public static void onClientTick() {
|
||||
}
|
||||
|
||||
public static void applySway(LocalPlayer player, float totalTicks) {
|
||||
}
|
||||
|
||||
public static float easeInOutCubic(float t) {
|
||||
return t < 0.5f ? 4.0f * t * t * t : 1.0f - (float)Math.pow(-2.0f * t + 2.0f, 3.0) / 2.0f;
|
||||
}
|
||||
|
||||
private static enum Phase {
|
||||
IDLE,
|
||||
FADE_IN,
|
||||
HOLD,
|
||||
FADE_OUT;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,102 +1,21 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.vinlanx.explosionoverhaul.client;
|
||||
|
||||
import com.mojang.blaze3d.platform.NativeImage;
|
||||
import com.mojang.logging.LogUtils;
|
||||
import com.vinlanx.explosionoverhaul.Config;
|
||||
import com.vinlanx.explosionoverhaul.ExplosionOverhaul;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.DynamicTexture;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.Resource;
|
||||
|
||||
public class ExplosionTextureManager {
|
||||
private static final LogUtils LOGGER_WRAPPER = null;
|
||||
private static final ExplosionTextureManager INSTANCE = new ExplosionTextureManager();
|
||||
private final Map<Integer, DynamicTexture> textures = new HashMap<Integer, DynamicTexture>();
|
||||
private final Map<Integer, ResourceLocation> resourceLocations = new HashMap<Integer, ResourceLocation>();
|
||||
public static final int INDEX_SOFT_GLOW = 0;
|
||||
public static final int INDEX_SOFT_GLOW_E = 1;
|
||||
public static final int GLOW_BASE_START = 2;
|
||||
public static final int GLOW_EMISSIVE_START = 6;
|
||||
public static final int GLOW2_BASE_START = 10;
|
||||
public static final int GLOW2_EMISSIVE_START = 14;
|
||||
public static final int SGLOW_BASE_START = 18;
|
||||
public static final int SGLOW_EMISSIVE_START = 22;
|
||||
private static final String BASE_PATH = "explosions/";
|
||||
|
||||
public static ExplosionTextureManager getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
private ExplosionTextureManager() {
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
this.clear();
|
||||
if (Minecraft.getInstance().m_91098_() == null) {
|
||||
return;
|
||||
}
|
||||
ExplosionOverhaul.LOGGER.info("Reloading Explosion Texture Manager...");
|
||||
this.loadTexture(0, "soft_glow.png");
|
||||
this.loadTexture(1, "soft_glow_e.png");
|
||||
Config.Client.ParticleRenderMode mode = (Config.Client.ParticleRenderMode)((Object)Config.CLIENT.particleRenderMode.get());
|
||||
if (mode == Config.Client.ParticleRenderMode.VANILA) {
|
||||
ExplosionOverhaul.LOGGER.info("Vanilla mode active - skipping high-res sheet loading to save VRAM.");
|
||||
return;
|
||||
}
|
||||
Config.Client.GlowTextureQuality quality = (Config.Client.GlowTextureQuality)((Object)Config.CLIENT.glowTextureQuality.get());
|
||||
boolean is64 = quality == Config.Client.GlowTextureQuality.QUALITY_64;
|
||||
this.loadSheetGroup(2, "glow/glow_sheet_", is64);
|
||||
this.loadSheetGroup(6, "glow/glow_e_sheet_", is64);
|
||||
this.loadSheetGroup(10, "glow_2/glow_2_sheet_", is64);
|
||||
this.loadSheetGroup(14, "glow_2/glow_2_e_sheet_", is64);
|
||||
this.loadSheetGroup(18, "sglow/sglow_sheet_", is64);
|
||||
this.loadSheetGroup(22, "sglow/sglow_e_sheet_", is64);
|
||||
ExplosionOverhaul.LOGGER.info("Explosion sheets loaded successfully (Quality: {}).", (Object)(is64 ? "64" : "256"));
|
||||
}
|
||||
|
||||
private void loadSheetGroup(int startIndex, String prefix, boolean is64) {
|
||||
String pathPrefix = is64 ? prefix.replace("/", "/64/") : prefix;
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
this.loadTexture(startIndex + i, pathPrefix + (i + 1) + ".png");
|
||||
}
|
||||
}
|
||||
|
||||
private void loadTexture(int index, String path) {
|
||||
ResourceLocation fullPath = new ResourceLocation("explosionoverhaul", BASE_PATH + path);
|
||||
try {
|
||||
InputStream is = ((Resource)Minecraft.getInstance().m_91098_().m_213713_(fullPath).get()).m_215507_();
|
||||
NativeImage image = NativeImage.m_85058_((InputStream)is);
|
||||
DynamicTexture texture = new DynamicTexture(image);
|
||||
ResourceLocation loc = Minecraft.getInstance().m_91097_().m_118490_("explosion_sheet_" + index, texture);
|
||||
this.textures.put(index, texture);
|
||||
this.resourceLocations.put(index, loc);
|
||||
}
|
||||
catch (Exception e) {
|
||||
ExplosionOverhaul.LOGGER.error("Failed to load explosion sheet from {}: {}", (Object)fullPath, (Object)e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public ResourceLocation getTexture(int index) {
|
||||
ResourceLocation loc = this.resourceLocations.get(index);
|
||||
if (loc == null) {
|
||||
loc = this.resourceLocations.get(0);
|
||||
}
|
||||
if (loc == null) {
|
||||
return new ResourceLocation("minecraft", "textures/particle/generic_0.png");
|
||||
}
|
||||
return loc;
|
||||
return ResourceLocation.fromNamespaceAndPath("minecraft", "textures/particle/generic_0.png");
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
this.textures.values().forEach(DynamicTexture::close);
|
||||
this.textures.clear();
|
||||
this.resourceLocations.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,751 +1,16 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.vinlanx.explosionoverhaul.client;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.vinlanx.explosionoverhaul.Config;
|
||||
import com.vinlanx.explosionoverhaul.ExplosionOverhaul;
|
||||
import com.vinlanx.explosionoverhaul.ModSounds;
|
||||
import com.vinlanx.explosionoverhaul.client.BackgroundParticle;
|
||||
import com.vinlanx.explosionoverhaul.client.ExplosionTextureManager;
|
||||
import com.vinlanx.explosionoverhaul.client.IntroMusicManager;
|
||||
import com.vinlanx.explosionoverhaul.client.SpriteSheetAnimator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
|
||||
import net.minecraft.client.resources.sounds.SoundInstance;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.util.RandomSource;
|
||||
|
||||
public class FirstTimeScreen
|
||||
extends Screen {
|
||||
private static final ResourceLocation SPRITE_REALISTIC = ResourceLocation.fromNamespaceAndPath((String)"explosionoverhaul", (String)"intro_gui/gui_screen_1.png");
|
||||
private static final ResourceLocation SPRITE_VANILLA = ResourceLocation.fromNamespaceAndPath((String)"explosionoverhaul", (String)"intro_gui/gui_screen_2.png");
|
||||
private static final ResourceLocation SPRITE_REALISTIC_2 = ResourceLocation.fromNamespaceAndPath((String)"explosionoverhaul", (String)"intro_gui/gui_screen_3.png");
|
||||
private static final ResourceLocation SPRITE_STYLE_256 = ResourceLocation.fromNamespaceAndPath((String)"explosionoverhaul", (String)"intro_gui/gui_screen_1.png");
|
||||
private static final ResourceLocation SPRITE_STYLE_64 = ResourceLocation.fromNamespaceAndPath((String)"explosionoverhaul", (String)"intro_gui/gui_screen_4.png");
|
||||
private static final int FRAME_WIDTH = 854;
|
||||
private static final int FRAME_HEIGHT = 480;
|
||||
private static final int COLUMNS = 10;
|
||||
private static final int ROWS = 10;
|
||||
private static final int TOTAL_FRAMES = 61;
|
||||
private static final int FPS = 15;
|
||||
private static final int COLOR_BG = -15921907;
|
||||
private static final int COLOR_ACCENT_ORANGE = -881908;
|
||||
private static final int COLOR_ACCENT_RED = -4250588;
|
||||
private static final int COLOR_ACCENT_ROSE = -2529701;
|
||||
private static final int COLOR_ACCENT_DARK_RED = -10939115;
|
||||
private ScreenState currentState = ScreenState.CHOOSING_MODE;
|
||||
private Config.Client.ParticleRenderMode selectedRenderMode = null;
|
||||
private SpriteSheetAnimator realisticAnimator;
|
||||
private SpriteSheetAnimator vanillaAnimator;
|
||||
private SpriteSheetAnimator realistic2Animator;
|
||||
private SpriteSheetAnimator style256Animator;
|
||||
private SpriteSheetAnimator style64Animator;
|
||||
private boolean shouldSwitchState = false;
|
||||
private ScreenState nextState = ScreenState.CHOOSING_MODE;
|
||||
private int leftBoxX;
|
||||
private int leftBoxY;
|
||||
private int leftBoxW;
|
||||
private int leftBoxH;
|
||||
private int rightBoxX;
|
||||
private int rightBoxY;
|
||||
private int rightBoxW;
|
||||
private int rightBoxH;
|
||||
private int bottomBoxX;
|
||||
private int bottomBoxY;
|
||||
private int bottomBoxW;
|
||||
private int bottomBoxH;
|
||||
private int backButtonX;
|
||||
private int backButtonY;
|
||||
private int backButtonW;
|
||||
private int backButtonH;
|
||||
private boolean backButtonHovered = false;
|
||||
private float backButtonScale = 1.0f;
|
||||
private float leftHoverScale = 1.0f;
|
||||
private float rightHoverScale = 1.0f;
|
||||
private float bottomHoverScale = 1.0f;
|
||||
private static final float HOVER_SCALE_TARGET = 1.05f;
|
||||
private static final float SCALE_SPEED = 0.15f;
|
||||
private boolean leftHovered = false;
|
||||
private boolean rightHovered = false;
|
||||
private boolean bottomHovered = false;
|
||||
private long lastFrameTime = System.currentTimeMillis();
|
||||
private float transitionAlpha = 1.0f;
|
||||
private boolean isTransitioning = false;
|
||||
private static final float TRANSITION_DURATION = 0.8f;
|
||||
private float transitionTime = 0.0f;
|
||||
private List<BackgroundParticle> particles = new ArrayList<BackgroundParticle>();
|
||||
private RandomSource random = RandomSource.m_216327_();
|
||||
private float backgroundTime = 0.0f;
|
||||
private IntroMusicManager musicManager;
|
||||
private static final float FADE_IN_DURATION = 5.0f;
|
||||
private static final float FADE_OUT_DURATION = 3.0f;
|
||||
private float fadeTime = 0.0f;
|
||||
private boolean fadingIn = true;
|
||||
private boolean fadingOut = false;
|
||||
private float screenAlpha = 0.0f;
|
||||
private float fadeOutStartAlpha = 1.0f;
|
||||
private long fadeOutStartMillis = -1L;
|
||||
private static final long FORCE_CLOSE_BUFFER_MS = 2000L;
|
||||
|
||||
public class FirstTimeScreen extends Screen {
|
||||
public FirstTimeScreen() {
|
||||
super((Component)Component.literal((String)"First Time Setup"));
|
||||
super(Component.empty());
|
||||
}
|
||||
|
||||
protected void m_7856_() {
|
||||
int i;
|
||||
int displayHeight;
|
||||
int displayWidth;
|
||||
super.m_7856_();
|
||||
this.fadingIn = true;
|
||||
this.fadingOut = false;
|
||||
this.fadeTime = 0.0f;
|
||||
this.screenAlpha = 0.0f;
|
||||
this.lastFrameTime = System.currentTimeMillis();
|
||||
this.leftHovered = false;
|
||||
this.rightHovered = false;
|
||||
this.bottomHovered = false;
|
||||
this.backButtonHovered = false;
|
||||
this.backButtonScale = 1.0f;
|
||||
this.musicManager = IntroMusicManager.getInstance();
|
||||
if (this.currentState == ScreenState.CHOOSING_MODE) {
|
||||
this.realisticAnimator = new SpriteSheetAnimator(SPRITE_REALISTIC, 854, 480, 10, 10, 61, 15);
|
||||
this.vanillaAnimator = new SpriteSheetAnimator(SPRITE_VANILLA, 854, 480, 10, 10, 61, 15);
|
||||
this.realistic2Animator = new SpriteSheetAnimator(SPRITE_REALISTIC_2, 854, 480, 10, 10, 61, 15);
|
||||
this.realisticAnimator.load();
|
||||
this.vanillaAnimator.load();
|
||||
this.realistic2Animator.load();
|
||||
} else if (this.currentState == ScreenState.CHOOSING_STYLE) {
|
||||
this.style256Animator = new SpriteSheetAnimator(SPRITE_STYLE_256, 854, 480, 10, 10, 61, 15);
|
||||
this.style64Animator = new SpriteSheetAnimator(SPRITE_STYLE_64, 854, 480, 10, 10, 61, 15);
|
||||
this.style256Animator.load();
|
||||
this.style64Animator.load();
|
||||
ExplosionOverhaul.LOGGER.warn("Style selection screen loaded. Ensure gui_screen_4.png and gui_screen_5.png exist in intro_gui folder for proper animations.");
|
||||
}
|
||||
int maxWidth = (int)((float)this.f_96543_ * 0.3f);
|
||||
int maxHeight = (int)((float)this.f_96544_ * 0.44f);
|
||||
float aspectRatio = 1.7777778f;
|
||||
if ((float)maxWidth / aspectRatio <= (float)maxHeight) {
|
||||
displayWidth = maxWidth;
|
||||
displayHeight = (int)((float)maxWidth / aspectRatio);
|
||||
} else {
|
||||
displayHeight = maxHeight;
|
||||
displayWidth = (int)((float)maxHeight * aspectRatio);
|
||||
}
|
||||
if (this.currentState == ScreenState.CHOOSING_MODE) {
|
||||
gap = (int)((float)this.f_96543_ * 0.03f);
|
||||
totalWidth = displayWidth * 2 + gap;
|
||||
startX = (this.f_96543_ - totalWidth) / 2;
|
||||
startY = (this.f_96544_ - displayHeight) / 2 - (int)((float)this.f_96544_ * 0.15f);
|
||||
this.leftBoxX = startX;
|
||||
this.leftBoxY = startY;
|
||||
this.leftBoxW = displayWidth;
|
||||
this.leftBoxH = displayHeight;
|
||||
this.rightBoxX = startX + displayWidth + gap;
|
||||
this.rightBoxY = startY;
|
||||
this.rightBoxW = displayWidth;
|
||||
this.rightBoxH = displayHeight;
|
||||
this.bottomBoxX = (this.f_96543_ - displayWidth) / 2;
|
||||
this.bottomBoxY = startY + displayHeight + (int)((float)this.f_96544_ * 0.08f);
|
||||
this.bottomBoxW = displayWidth;
|
||||
this.bottomBoxH = displayHeight;
|
||||
} else if (this.currentState == ScreenState.CHOOSING_STYLE) {
|
||||
gap = (int)((float)this.f_96543_ * 0.03f);
|
||||
totalWidth = displayWidth * 2 + gap;
|
||||
startX = (this.f_96543_ - totalWidth) / 2;
|
||||
startY = (this.f_96544_ - displayHeight) / 2;
|
||||
this.leftBoxX = startX;
|
||||
this.leftBoxY = startY;
|
||||
this.leftBoxW = displayWidth;
|
||||
this.leftBoxH = displayHeight;
|
||||
this.rightBoxX = startX + displayWidth + gap;
|
||||
this.rightBoxY = startY;
|
||||
this.rightBoxW = displayWidth;
|
||||
this.rightBoxH = displayHeight;
|
||||
this.bottomBoxX = 0;
|
||||
this.bottomBoxY = 0;
|
||||
this.bottomBoxW = 0;
|
||||
this.bottomBoxH = 0;
|
||||
this.backButtonW = (int)((float)this.f_96543_ * 0.1f);
|
||||
this.backButtonH = (int)((float)this.f_96544_ * 0.08f);
|
||||
this.backButtonX = (int)((float)this.f_96543_ * 0.02f);
|
||||
this.backButtonY = this.f_96544_ - this.backButtonH - (int)((float)this.f_96544_ * 0.02f);
|
||||
}
|
||||
for (i = 0; i < 40; ++i) {
|
||||
this.particles.add(BackgroundParticle.createSpark(this.random, this.f_96543_, this.f_96544_));
|
||||
}
|
||||
for (i = 0; i < 15; ++i) {
|
||||
this.particles.add(BackgroundParticle.createEmber(this.random, this.f_96543_, this.f_96544_));
|
||||
}
|
||||
for (i = 0; i < 8; ++i) {
|
||||
this.particles.add(BackgroundParticle.createSmoke(this.random, this.f_96543_, this.f_96544_));
|
||||
}
|
||||
}
|
||||
|
||||
public void m_86600_() {
|
||||
float progress;
|
||||
super.m_86600_();
|
||||
long currentTime = System.currentTimeMillis();
|
||||
float rawDeltaTime = (float)(currentTime - this.lastFrameTime) / 1000.0f;
|
||||
this.lastFrameTime = currentTime;
|
||||
float deltaTime = Math.min(rawDeltaTime, 0.1f);
|
||||
this.backgroundTime += deltaTime;
|
||||
if (this.isTransitioning) {
|
||||
this.transitionTime += deltaTime;
|
||||
progress = Math.min(1.0f, this.transitionTime / 0.8f);
|
||||
if (this.transitionTime < 0.4f) {
|
||||
this.transitionAlpha = 1.0f - progress * 2.0f;
|
||||
} else {
|
||||
this.transitionAlpha = (progress - 0.5f) * 2.0f;
|
||||
if (this.transitionTime >= 0.4f && !this.shouldSwitchState) {
|
||||
this.shouldSwitchState = true;
|
||||
if (this.currentState == ScreenState.CHOOSING_MODE) {
|
||||
if (this.realisticAnimator != null) {
|
||||
this.realisticAnimator.close();
|
||||
}
|
||||
if (this.vanillaAnimator != null) {
|
||||
this.vanillaAnimator.close();
|
||||
}
|
||||
if (this.realistic2Animator != null) {
|
||||
this.realistic2Animator.close();
|
||||
}
|
||||
this.nextState = ScreenState.CHOOSING_STYLE;
|
||||
} else if (this.currentState == ScreenState.CHOOSING_STYLE) {
|
||||
if (this.style256Animator != null) {
|
||||
this.style256Animator.close();
|
||||
}
|
||||
if (this.style64Animator != null) {
|
||||
this.style64Animator.close();
|
||||
}
|
||||
this.nextState = ScreenState.CHOOSING_MODE;
|
||||
}
|
||||
this.currentState = this.nextState;
|
||||
this.m_7856_();
|
||||
}
|
||||
}
|
||||
if (this.transitionTime >= 0.8f) {
|
||||
this.isTransitioning = false;
|
||||
this.transitionAlpha = 1.0f;
|
||||
this.transitionTime = 0.0f;
|
||||
this.shouldSwitchState = false;
|
||||
}
|
||||
}
|
||||
if (this.fadingIn) {
|
||||
this.fadeTime += deltaTime;
|
||||
progress = Math.min(1.0f, this.fadeTime / 5.0f);
|
||||
this.screenAlpha = this.easeOutCubic(progress);
|
||||
if (this.fadeTime >= 5.0f) {
|
||||
this.fadingIn = false;
|
||||
this.screenAlpha = 1.0f;
|
||||
}
|
||||
} else if (this.fadingOut) {
|
||||
long threshold;
|
||||
long elapsed;
|
||||
this.fadeTime += deltaTime;
|
||||
progress = Math.min(1.0f, this.fadeTime / 3.0f);
|
||||
this.screenAlpha = this.fadeOutStartAlpha * (1.0f - this.easeInCubic(progress));
|
||||
if (this.fadeTime >= 3.0f) {
|
||||
boolean musicStillFading;
|
||||
boolean bl = musicStillFading = this.musicManager != null && this.musicManager.isFadingOut();
|
||||
if (!musicStillFading) {
|
||||
ExplosionOverhaul.LOGGER.info("Screen and music fade out complete. Opening TitleScreen.");
|
||||
this.cleanupAnimators();
|
||||
Minecraft.getInstance().m_91152_((Screen)new TitleScreen());
|
||||
} else {
|
||||
ExplosionOverhaul.LOGGER.info("Waiting for music to finish fading...");
|
||||
}
|
||||
}
|
||||
if (this.fadeOutStartMillis > 0L && (elapsed = System.currentTimeMillis() - this.fadeOutStartMillis) > (threshold = 5000L)) {
|
||||
ExplosionOverhaul.LOGGER.warn("Fade out timeout exceeded ({} ms). Forcing close and opening TitleScreen.", (Object)elapsed);
|
||||
if (this.musicManager != null) {
|
||||
this.musicManager.stop();
|
||||
}
|
||||
this.cleanupAnimators();
|
||||
this.fadingOut = false;
|
||||
this.fadeOutStartMillis = -1L;
|
||||
Minecraft.getInstance().m_91152_((Screen)new TitleScreen());
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (this.musicManager != null) {
|
||||
this.musicManager.tick(deltaTime);
|
||||
}
|
||||
if (this.currentState == ScreenState.CHOOSING_MODE) {
|
||||
if (this.realisticAnimator != null) {
|
||||
this.realisticAnimator.tick(deltaTime);
|
||||
}
|
||||
if (this.vanillaAnimator != null) {
|
||||
this.vanillaAnimator.tick(deltaTime);
|
||||
}
|
||||
if (this.realistic2Animator != null) {
|
||||
this.realistic2Animator.tick(deltaTime);
|
||||
}
|
||||
} else if (this.currentState == ScreenState.CHOOSING_STYLE) {
|
||||
if (this.style256Animator != null) {
|
||||
this.style256Animator.tick(deltaTime);
|
||||
}
|
||||
if (this.style64Animator != null) {
|
||||
this.style64Animator.tick(deltaTime);
|
||||
}
|
||||
}
|
||||
this.leftHoverScale = Mth.m_14179_((float)0.15f, (float)this.leftHoverScale, (float)(this.leftHovered ? 1.05f : 1.0f));
|
||||
this.rightHoverScale = Mth.m_14179_((float)0.15f, (float)this.rightHoverScale, (float)(this.rightHovered ? 1.05f : 1.0f));
|
||||
this.bottomHoverScale = Mth.m_14179_((float)0.15f, (float)this.bottomHoverScale, (float)(this.bottomHovered ? 1.05f : 1.0f));
|
||||
this.particles.removeIf(p -> {
|
||||
p.tick(deltaTime);
|
||||
return p.isDead() || p.x < -50.0f || p.x > (float)(this.f_96543_ + 50) || p.y < -50.0f || p.y > (float)(this.f_96544_ + 50);
|
||||
});
|
||||
if (this.random.m_188501_() < 0.15f) {
|
||||
this.particles.add(BackgroundParticle.createSpark(this.random, this.f_96543_, this.f_96544_));
|
||||
}
|
||||
if (this.random.m_188501_() < 0.05f) {
|
||||
this.particles.add(BackgroundParticle.createEmber(this.random, this.f_96543_, this.f_96544_));
|
||||
}
|
||||
if (this.random.m_188501_() < 0.02f) {
|
||||
this.particles.add(BackgroundParticle.createSmoke(this.random, this.f_96543_, this.f_96544_));
|
||||
}
|
||||
if (this.random.m_188501_() < 0.01f) {
|
||||
this.particles.add(BackgroundParticle.createFlash(this.random, this.f_96543_, this.f_96544_));
|
||||
}
|
||||
}
|
||||
|
||||
private void cleanupAnimators() {
|
||||
if (this.realisticAnimator != null) {
|
||||
this.realisticAnimator.close();
|
||||
}
|
||||
if (this.vanillaAnimator != null) {
|
||||
this.vanillaAnimator.close();
|
||||
}
|
||||
if (this.realistic2Animator != null) {
|
||||
this.realistic2Animator.close();
|
||||
}
|
||||
if (this.style256Animator != null) {
|
||||
this.style256Animator.close();
|
||||
}
|
||||
if (this.style64Animator != null) {
|
||||
this.style64Animator.close();
|
||||
}
|
||||
}
|
||||
|
||||
public void m_88315_(GuiGraphics graphics, int mouseX, int mouseY, float partialTick) {
|
||||
graphics.fill(0, 0, this.f_96543_, this.f_96544_, -16777216);
|
||||
if (this.screenAlpha < 0.01f) {
|
||||
return;
|
||||
}
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.defaultBlendFunc();
|
||||
float renderAlpha = this.screenAlpha * this.transitionAlpha;
|
||||
RenderSystem.setShaderColor((float)1.0f, (float)1.0f, (float)1.0f, (float)renderAlpha);
|
||||
graphics.m_280168_().m_85836_();
|
||||
this.renderCinematicBackground(graphics, partialTick, renderAlpha);
|
||||
if (this.currentState == ScreenState.CHOOSING_MODE) {
|
||||
this.renderModeSelection(graphics, mouseX, mouseY, renderAlpha);
|
||||
} else if (this.currentState == ScreenState.CHOOSING_STYLE) {
|
||||
this.renderStyleSelection(graphics, mouseX, mouseY, renderAlpha);
|
||||
}
|
||||
graphics.m_280168_().m_85849_();
|
||||
RenderSystem.setShaderColor((float)1.0f, (float)1.0f, (float)1.0f, (float)1.0f);
|
||||
super.m_88315_(graphics, mouseX, mouseY, partialTick);
|
||||
}
|
||||
|
||||
private void renderModeSelection(GuiGraphics graphics, int mouseX, int mouseY, float renderAlpha) {
|
||||
String title = "Choose Your Explosion Style";
|
||||
int titleWidth = this.f_96547_.width(title);
|
||||
int titleX = (this.f_96543_ - titleWidth) / 2;
|
||||
int titleY = this.leftBoxY - 40;
|
||||
int titleAlpha = (int)(renderAlpha * 255.0f) << 24;
|
||||
graphics.m_280056_(this.f_96547_, title, titleX + 2, titleY + 2, 0xF28B0C | (int)(64.0f * renderAlpha) << 24, false);
|
||||
graphics.m_280056_(this.f_96547_, title, titleX + 1, titleY + 1, 0xF28B0C | (int)(128.0f * renderAlpha) << 24, false);
|
||||
graphics.m_280056_(this.f_96547_, title, titleX, titleY, 0xF28B0C | titleAlpha, true);
|
||||
String subtitle = "You can change this anytime in the config";
|
||||
int subtitleWidth = this.f_96547_.width(subtitle);
|
||||
graphics.m_280056_(this.f_96547_, subtitle, (this.f_96543_ - subtitleWidth) / 2, titleY + 15, 0xCCCCCC | titleAlpha, false);
|
||||
String psNote = "P.S. Colors in the game may differ from the animations because compression has altered the colors";
|
||||
int psWidth = this.f_96547_.width(psNote);
|
||||
int psColor = 0x999999 | titleAlpha;
|
||||
graphics.m_280056_(this.f_96547_, psNote, (this.f_96543_ - psWidth) / 2, titleY + 30, psColor, false);
|
||||
if (!this.isTransitioning) {
|
||||
boolean wasLeftHovered = this.leftHovered;
|
||||
boolean wasRightHovered = this.rightHovered;
|
||||
boolean wasBottomHovered = this.bottomHovered;
|
||||
this.leftHovered = this.isMouseOver(mouseX, mouseY, this.leftBoxX, this.leftBoxY, this.leftBoxW, this.leftBoxH);
|
||||
this.rightHovered = this.isMouseOver(mouseX, mouseY, this.rightBoxX, this.rightBoxY, this.rightBoxW, this.rightBoxH);
|
||||
this.bottomHovered = this.isMouseOver(mouseX, mouseY, this.bottomBoxX, this.bottomBoxY, this.bottomBoxW, this.bottomBoxH);
|
||||
if (this.leftHovered && !wasLeftHovered) {
|
||||
this.realisticAnimator.reset();
|
||||
this.realisticAnimator.play();
|
||||
} else if (!this.leftHovered && wasLeftHovered) {
|
||||
this.realisticAnimator.reset();
|
||||
}
|
||||
if (this.rightHovered && !wasRightHovered) {
|
||||
this.vanillaAnimator.reset();
|
||||
this.vanillaAnimator.play();
|
||||
} else if (!this.rightHovered && wasRightHovered) {
|
||||
this.vanillaAnimator.reset();
|
||||
}
|
||||
if (this.bottomHovered && !wasBottomHovered) {
|
||||
this.realistic2Animator.reset();
|
||||
this.realistic2Animator.play();
|
||||
} else if (!this.bottomHovered && wasBottomHovered) {
|
||||
this.realistic2Animator.reset();
|
||||
}
|
||||
}
|
||||
this.renderBox(graphics, this.leftBoxX, this.leftBoxY, this.leftBoxW, this.leftBoxH, this.leftHoverScale, this.realisticAnimator, "REALISTIC", this.leftHovered, -881908, renderAlpha);
|
||||
this.renderBox(graphics, this.rightBoxX, this.rightBoxY, this.rightBoxW, this.rightBoxH, this.rightHoverScale, this.vanillaAnimator, "VANILLA-LIKE", this.rightHovered, -4250588, renderAlpha);
|
||||
this.renderBox(graphics, this.bottomBoxX, this.bottomBoxY, this.bottomBoxW, this.bottomBoxH, this.bottomHoverScale, this.realistic2Animator, "REALISTIC 2", this.bottomHovered, -2529701, renderAlpha);
|
||||
}
|
||||
|
||||
private void renderStyleSelection(GuiGraphics graphics, int mouseX, int mouseY, float renderAlpha) {
|
||||
String title = "Choose Render Style";
|
||||
int titleWidth = this.f_96547_.width(title);
|
||||
int titleX = (this.f_96543_ - titleWidth) / 2;
|
||||
int titleY = this.leftBoxY - 40;
|
||||
int titleAlpha = (int)(renderAlpha * 255.0f) << 24;
|
||||
graphics.m_280056_(this.f_96547_, title, titleX + 2, titleY + 2, 0xF28B0C | (int)(64.0f * renderAlpha) << 24, false);
|
||||
graphics.m_280056_(this.f_96547_, title, titleX + 1, titleY + 1, 0xF28B0C | (int)(128.0f * renderAlpha) << 24, false);
|
||||
graphics.m_280056_(this.f_96547_, title, titleX, titleY, 0xF28B0C | titleAlpha, true);
|
||||
String subtitle = "Higher quality requires more VRAM";
|
||||
int subtitleWidth = this.f_96547_.width(subtitle);
|
||||
graphics.m_280056_(this.f_96547_, subtitle, (this.f_96543_ - subtitleWidth) / 2, titleY + 15, 0xCCCCCC | titleAlpha, false);
|
||||
if (!this.isTransitioning) {
|
||||
boolean wasLeftHovered = this.leftHovered;
|
||||
boolean wasRightHovered = this.rightHovered;
|
||||
boolean wasBackHovered = this.backButtonHovered;
|
||||
this.leftHovered = this.isMouseOver(mouseX, mouseY, this.leftBoxX, this.leftBoxY, this.leftBoxW, this.leftBoxH);
|
||||
this.rightHovered = this.isMouseOver(mouseX, mouseY, this.rightBoxX, this.rightBoxY, this.rightBoxW, this.rightBoxH);
|
||||
this.backButtonHovered = this.isMouseOver(mouseX, mouseY, this.backButtonX, this.backButtonY, this.backButtonW, this.backButtonH);
|
||||
this.bottomHovered = false;
|
||||
if (this.leftHovered && !wasLeftHovered) {
|
||||
this.style256Animator.reset();
|
||||
this.style256Animator.play();
|
||||
} else if (!this.leftHovered && wasLeftHovered) {
|
||||
this.style256Animator.reset();
|
||||
}
|
||||
if (this.rightHovered && !wasRightHovered) {
|
||||
this.style64Animator.reset();
|
||||
this.style64Animator.play();
|
||||
} else if (!this.rightHovered && wasRightHovered) {
|
||||
this.style64Animator.reset();
|
||||
}
|
||||
if (this.backButtonHovered && !wasBackHovered || this.backButtonHovered || wasBackHovered) {
|
||||
// empty if block
|
||||
}
|
||||
}
|
||||
this.backButtonScale = Mth.m_14179_((float)0.15f, (float)this.backButtonScale, (float)(this.backButtonHovered ? 1.05f : 1.0f));
|
||||
this.renderBox(graphics, this.leftBoxX, this.leftBoxY, this.leftBoxW, this.leftBoxH, this.leftHoverScale, this.style256Animator, "256 PIXELS", this.leftHovered, -881908, renderAlpha);
|
||||
this.renderBox(graphics, this.rightBoxX, this.rightBoxY, this.rightBoxW, this.rightBoxH, this.rightHoverScale, this.style64Animator, "64 PIXELS", this.rightHovered, -4250588, renderAlpha);
|
||||
this.renderBackButton(graphics, renderAlpha);
|
||||
}
|
||||
|
||||
private void renderBox(GuiGraphics graphics, int x, int y, int width, int height, float scale, SpriteSheetAnimator animator, String label, boolean hovered, int accentColor, float alpha) {
|
||||
graphics.m_280168_().m_85836_();
|
||||
int centerX = x + width / 2;
|
||||
int centerY = y + height / 2;
|
||||
graphics.m_280168_().m_252880_((float)centerX, (float)centerY, 0.0f);
|
||||
graphics.m_280168_().m_85841_(scale, scale, 1.0f);
|
||||
graphics.m_280168_().m_252880_((float)(-width / 2), (float)(-height / 2), 0.0f);
|
||||
if (hovered) {
|
||||
int glowSize = 4;
|
||||
int glowAlpha = (int)(128.0f * alpha) << 24;
|
||||
graphics.fill(-glowSize, -glowSize, width + glowSize, height + glowSize, accentColor & 0xFFFFFF | glowAlpha);
|
||||
}
|
||||
int bgAlpha = (int)(255.0f * alpha) << 24;
|
||||
graphics.fill(0, 0, width, height, 0x591515 | bgAlpha);
|
||||
if (animator != null && animator.getTextureLocation() != null) {
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.defaultBlendFunc();
|
||||
RenderSystem.setShaderColor((float)1.0f, (float)1.0f, (float)1.0f, (float)alpha);
|
||||
RenderSystem.setShaderTexture((int)0, (ResourceLocation)animator.getTextureLocation());
|
||||
graphics.m_280163_(animator.getTextureLocation(), 0, 0, 0.0f, 0.0f, width, height, width, height);
|
||||
RenderSystem.setShaderColor((float)1.0f, (float)1.0f, (float)1.0f, (float)1.0f);
|
||||
} else {
|
||||
int placeholderTextColor = (int)(150.0f * alpha) << 24 | 0xFFFFFFFF;
|
||||
String placeholder = "[Image not found]";
|
||||
int placeholderWidth = this.f_96547_.width(placeholder);
|
||||
graphics.m_280056_(this.f_96547_, placeholder, (width - placeholderWidth) / 2, height / 2 - 5, placeholderTextColor, false);
|
||||
}
|
||||
int borderColor = hovered ? accentColor : -2529701;
|
||||
int borderAlpha = (int)(255.0f * alpha) << 24;
|
||||
int fadedBorderColor = borderColor & 0xFFFFFF | borderAlpha;
|
||||
graphics.fill(0, 0, width, 2, fadedBorderColor);
|
||||
graphics.fill(0, height - 2, width, height, fadedBorderColor);
|
||||
graphics.fill(0, 0, 2, height, fadedBorderColor);
|
||||
graphics.fill(width - 2, 0, width, height, fadedBorderColor);
|
||||
graphics.m_280168_().m_85849_();
|
||||
int labelAlpha = (int)(255.0f * alpha) << 24;
|
||||
int labelColor = hovered ? accentColor : -1;
|
||||
int fadedLabelColor = labelColor & 0xFFFFFF | labelAlpha;
|
||||
int labelWidth = this.f_96547_.width(label);
|
||||
graphics.m_280056_(this.f_96547_, label, x + (width - labelWidth) / 2, y + height + 10, fadedLabelColor, true);
|
||||
}
|
||||
|
||||
public boolean m_6375_(double mouseX, double mouseY, int button) {
|
||||
if (this.fadingOut || this.isTransitioning) {
|
||||
return true;
|
||||
}
|
||||
if (button == 0) {
|
||||
if (this.currentState == ScreenState.CHOOSING_MODE) {
|
||||
if (this.isMouseOver((int)mouseX, (int)mouseY, this.leftBoxX, this.leftBoxY, this.leftBoxW, this.leftBoxH)) {
|
||||
this.selectRealisticMode();
|
||||
return true;
|
||||
}
|
||||
if (this.isMouseOver((int)mouseX, (int)mouseY, this.rightBoxX, this.rightBoxY, this.rightBoxW, this.rightBoxH)) {
|
||||
this.selectVanillaLike();
|
||||
return true;
|
||||
}
|
||||
if (this.isMouseOver((int)mouseX, (int)mouseY, this.bottomBoxX, this.bottomBoxY, this.bottomBoxW, this.bottomBoxH)) {
|
||||
this.selectRealistic2Mode();
|
||||
return true;
|
||||
}
|
||||
} else if (this.currentState == ScreenState.CHOOSING_STYLE) {
|
||||
if (this.isMouseOver((int)mouseX, (int)mouseY, this.leftBoxX, this.leftBoxY, this.leftBoxW, this.leftBoxH)) {
|
||||
this.selectStyle256();
|
||||
return true;
|
||||
}
|
||||
if (this.isMouseOver((int)mouseX, (int)mouseY, this.rightBoxX, this.rightBoxY, this.rightBoxW, this.rightBoxH)) {
|
||||
this.selectStyle64();
|
||||
return true;
|
||||
}
|
||||
if (this.isMouseOver((int)mouseX, (int)mouseY, this.backButtonX, this.backButtonY, this.backButtonW, this.backButtonH)) {
|
||||
this.goBack();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.m_6375_(mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
private void selectRealisticMode() {
|
||||
this.playButtonSound();
|
||||
this.selectedRenderMode = Config.Client.ParticleRenderMode.REALISTIC;
|
||||
this.isTransitioning = true;
|
||||
this.transitionTime = 0.0f;
|
||||
this.transitionAlpha = 1.0f;
|
||||
}
|
||||
|
||||
private void selectRealistic2Mode() {
|
||||
this.playButtonSound();
|
||||
this.selectedRenderMode = Config.Client.ParticleRenderMode.REALISTIC_2;
|
||||
this.isTransitioning = true;
|
||||
this.transitionTime = 0.0f;
|
||||
this.transitionAlpha = 1.0f;
|
||||
}
|
||||
|
||||
private void selectStyle256() {
|
||||
this.playButtonSound();
|
||||
Config.CLIENT.glowTextureQuality.set((Object)Config.Client.GlowTextureQuality.QUALITY_256);
|
||||
Config.CLIENT.particleRenderMode.set((Object)this.selectedRenderMode);
|
||||
this.saveAndClose();
|
||||
}
|
||||
|
||||
private void selectStyle64() {
|
||||
this.playButtonSound();
|
||||
Config.CLIENT.glowTextureQuality.set((Object)Config.Client.GlowTextureQuality.QUALITY_64);
|
||||
Config.CLIENT.particleRenderMode.set((Object)this.selectedRenderMode);
|
||||
this.saveAndClose();
|
||||
}
|
||||
|
||||
private boolean isMouseOver(int mouseX, int mouseY, int x, int y, int width, int height) {
|
||||
return mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + height;
|
||||
}
|
||||
|
||||
private void selectVanillaLike() {
|
||||
this.playButtonSound();
|
||||
Config.CLIENT.particleRenderMode.set((Object)Config.Client.ParticleRenderMode.VANILA);
|
||||
this.saveAndClose();
|
||||
}
|
||||
|
||||
private void goBack() {
|
||||
this.playButtonSound();
|
||||
this.isTransitioning = true;
|
||||
this.transitionTime = 0.0f;
|
||||
this.transitionAlpha = 1.0f;
|
||||
this.selectedRenderMode = null;
|
||||
}
|
||||
|
||||
private void saveAndClose() {
|
||||
Config.CLIENT.firstLaunchComplete.set((Object)true);
|
||||
Config.CLIENT_SPEC.save();
|
||||
ExplosionTextureManager.getInstance().reload();
|
||||
if (this.musicManager != null && this.musicManager.isPlaying()) {
|
||||
ExplosionOverhaul.LOGGER.info("Starting music and screen fade out (duration: {} seconds)", (Object)Float.valueOf(3.0f));
|
||||
this.musicManager.startFadeOut();
|
||||
}
|
||||
if (this.fadingIn) {
|
||||
this.fadingIn = false;
|
||||
ExplosionOverhaul.LOGGER.info("Interrupting fade in (was at {:.1f}%) to start fade out from current alpha", (Object)Float.valueOf(this.screenAlpha * 100.0f));
|
||||
}
|
||||
this.fadeOutStartAlpha = this.screenAlpha;
|
||||
this.fadingOut = true;
|
||||
this.fadeTime = 0.0f;
|
||||
this.fadeOutStartMillis = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
private void renderCinematicBackground(GuiGraphics graphics, float partialTick, float globalAlpha) {
|
||||
int i;
|
||||
int bgAlpha1;
|
||||
int bgColor1 = bgAlpha1 = (int)(255.0f * globalAlpha) << 24;
|
||||
int bgColor2 = 0xD0D0D | bgAlpha1;
|
||||
graphics.m_280024_(0, 0, this.f_96543_, this.f_96544_ / 2, bgColor1, bgColor2);
|
||||
graphics.m_280024_(0, this.f_96544_ / 2, this.f_96543_, this.f_96544_, bgColor2, bgColor1);
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.defaultBlendFunc();
|
||||
for (BackgroundParticle p : this.particles) {
|
||||
float particleAlpha = p.getAlpha();
|
||||
float finalAlpha = particleAlpha * globalAlpha;
|
||||
int colorWithAlpha = p.color & 0xFFFFFF | (int)(finalAlpha * 255.0f) << 24;
|
||||
switch (p.type) {
|
||||
case SPARK: {
|
||||
float sparkLen = p.size * 3.0f;
|
||||
float sparkAngle = (float)Math.atan2(p.vy, p.vx);
|
||||
int ex = (int)((double)p.x + Math.cos(sparkAngle) * (double)sparkLen);
|
||||
int ey = (int)((double)p.y + Math.sin(sparkAngle) * (double)sparkLen);
|
||||
this.drawLine(graphics, (int)p.x, (int)p.y, ex, ey, colorWithAlpha);
|
||||
break;
|
||||
}
|
||||
case EMBER: {
|
||||
int emberSize = (int)p.size;
|
||||
graphics.fill((int)p.x - emberSize, (int)p.y - emberSize, (int)p.x + emberSize, (int)p.y + emberSize, colorWithAlpha);
|
||||
break;
|
||||
}
|
||||
case FLASH: {
|
||||
int flashSize = (int)(p.size * 0.7f);
|
||||
int flashColor = colorWithAlpha & 0xFFFFFF | (int)(finalAlpha * 180.0f) << 24;
|
||||
graphics.fill((int)p.x - flashSize, (int)p.y - flashSize, (int)p.x + flashSize, (int)p.y + flashSize, flashColor);
|
||||
break;
|
||||
}
|
||||
case SMOKE: {
|
||||
int smokeSize = (int)p.size;
|
||||
int smokeColor = colorWithAlpha & 0xFFFFFF | (int)(finalAlpha * 60.0f) << 24;
|
||||
graphics.fill((int)p.x - smokeSize, (int)p.y - smokeSize, (int)p.x + smokeSize, (int)p.y + smokeSize, smokeColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
int vignetteSteps = 15;
|
||||
for (i = 0; i < vignetteSteps; ++i) {
|
||||
float ratio = (float)i / (float)vignetteSteps;
|
||||
int vignetteAlpha = (int)(ratio * ratio * 180.0f * globalAlpha);
|
||||
int vignetteColor = vignetteAlpha << 24;
|
||||
int thickness = 4;
|
||||
graphics.fill(0, i * thickness, this.f_96543_, (i + 1) * thickness, vignetteColor);
|
||||
graphics.fill(0, this.f_96544_ - (i + 1) * thickness, this.f_96543_, this.f_96544_ - i * thickness, vignetteColor);
|
||||
graphics.fill(i * thickness, 0, (i + 1) * thickness, this.f_96544_, vignetteColor);
|
||||
graphics.fill(this.f_96543_ - (i + 1) * thickness, 0, this.f_96543_ - i * thickness, this.f_96544_, vignetteColor);
|
||||
}
|
||||
for (i = 0; i < 150; ++i) {
|
||||
int gx = this.random.m_188503_(this.f_96543_);
|
||||
int gy = this.random.m_188503_(this.f_96544_);
|
||||
int grainAlpha = (int)((float)(20 + this.random.m_188503_(30)) * globalAlpha);
|
||||
int grainColor = grainAlpha << 24 | 0xFFFFFF;
|
||||
graphics.fill(gx, gy, gx + 1, gy + 1, grainColor);
|
||||
}
|
||||
for (int y = 0; y < this.f_96544_; y += 4) {
|
||||
graphics.fill(0, y, this.f_96543_, y + 1, 0x8000000);
|
||||
}
|
||||
RenderSystem.disableBlend();
|
||||
}
|
||||
|
||||
private void drawLine(GuiGraphics graphics, int x1, int y1, int x2, int y2, int color) {
|
||||
int dx = Math.abs(x2 - x1);
|
||||
int dy = Math.abs(y2 - y1);
|
||||
int sx = x1 < x2 ? 1 : -1;
|
||||
int sy = y1 < y2 ? 1 : -1;
|
||||
int err = dx - dy;
|
||||
for (int steps = 0; steps < 200; ++steps) {
|
||||
graphics.fill(x1, y1, x1 + 1, y1 + 1, color);
|
||||
if (x1 == x2 && y1 == y2) break;
|
||||
int e2 = 2 * err;
|
||||
if (e2 > -dy) {
|
||||
err -= dy;
|
||||
x1 += sx;
|
||||
}
|
||||
if (e2 >= dx) continue;
|
||||
err += dx;
|
||||
y1 += sy;
|
||||
}
|
||||
}
|
||||
|
||||
public void m_7379_() {
|
||||
if (!this.fadingOut) {
|
||||
this.cleanupAnimators();
|
||||
super.m_7379_();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean m_7933_(int keyCode, int scanCode, int modifiers) {
|
||||
if (keyCode == 256) {
|
||||
return true;
|
||||
}
|
||||
return super.m_7933_(keyCode, scanCode, modifiers);
|
||||
}
|
||||
|
||||
public boolean m_7043_() {
|
||||
return true;
|
||||
}
|
||||
|
||||
private float easeOutCubic(float x) {
|
||||
return 1.0f - (float)Math.pow(1.0f - x, 3.0);
|
||||
}
|
||||
|
||||
private float easeInCubic(float x) {
|
||||
return x * x * x;
|
||||
}
|
||||
|
||||
private void renderBackButton(GuiGraphics graphics, float alpha) {
|
||||
graphics.m_280168_().m_85836_();
|
||||
int centerX = this.backButtonX + this.backButtonW / 2;
|
||||
int centerY = this.backButtonY + this.backButtonH / 2;
|
||||
graphics.m_280168_().m_252880_((float)centerX, (float)centerY, 0.0f);
|
||||
graphics.m_280168_().m_85841_(this.backButtonScale, this.backButtonScale, 1.0f);
|
||||
graphics.m_280168_().m_252880_((float)(-this.backButtonW / 2), (float)(-this.backButtonH / 2), 0.0f);
|
||||
if (this.backButtonHovered) {
|
||||
int glowSize = 3;
|
||||
int glowAlpha = (int)(128.0f * alpha) << 24;
|
||||
graphics.fill(-glowSize, -glowSize, this.backButtonW + glowSize, this.backButtonH + glowSize, 0xF28B0C | glowAlpha);
|
||||
}
|
||||
int bgAlpha = (int)(255.0f * alpha) << 24;
|
||||
graphics.fill(0, 0, this.backButtonW, this.backButtonH, 0x591515 | bgAlpha);
|
||||
int borderColor = this.backButtonHovered ? -881908 : -2529701;
|
||||
int borderAlpha = (int)(255.0f * alpha) << 24;
|
||||
int fadedBorderColor = borderColor & 0xFFFFFF | borderAlpha;
|
||||
graphics.fill(0, 0, this.backButtonW, 2, fadedBorderColor);
|
||||
graphics.fill(0, this.backButtonH - 2, this.backButtonW, this.backButtonH, fadedBorderColor);
|
||||
graphics.fill(0, 0, 2, this.backButtonH, fadedBorderColor);
|
||||
graphics.fill(this.backButtonW - 2, 0, this.backButtonW, this.backButtonH, fadedBorderColor);
|
||||
graphics.m_280168_().m_85849_();
|
||||
String buttonText = "BACK";
|
||||
int textWidth = this.f_96547_.width(buttonText);
|
||||
int textColor = this.backButtonHovered ? -881908 : -1;
|
||||
int textAlpha = (int)(255.0f * alpha) << 24;
|
||||
int fadedTextColor = textColor & 0xFFFFFF | textAlpha;
|
||||
graphics.m_280056_(this.f_96547_, buttonText, this.backButtonX + (this.backButtonW - textWidth) / 2, this.backButtonY + (this.backButtonH - 8) / 2, fadedTextColor, true);
|
||||
}
|
||||
|
||||
private void playButtonSound() {
|
||||
try {
|
||||
Minecraft minecraft = Minecraft.getInstance();
|
||||
if (minecraft.m_91106_() != null) {
|
||||
minecraft.m_91106_().m_120367_((SoundInstance)SimpleSoundInstance.m_119755_((SoundEvent)((SoundEvent)ModSounds.BUTTON_SOUND.get()), (float)1.0f, (float)1.0f));
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
ExplosionOverhaul.LOGGER.warn("Failed to play button sound", (Throwable)e);
|
||||
}
|
||||
}
|
||||
|
||||
private static enum ScreenState {
|
||||
CHOOSING_MODE,
|
||||
CHOOSING_STYLE,
|
||||
FADING_OUT;
|
||||
|
||||
@Override
|
||||
public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTick) {
|
||||
super.render(graphics, mouseX, mouseY, partialTick);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,633 +1,16 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.vinlanx.explosionoverhaul.client;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.vinlanx.explosionoverhaul.ExplosionOverhaul;
|
||||
import com.vinlanx.explosionoverhaul.ModSounds;
|
||||
import com.vinlanx.explosionoverhaul.client.AnimationSoundManager;
|
||||
import com.vinlanx.explosionoverhaul.client.BackgroundParticle;
|
||||
import com.vinlanx.explosionoverhaul.client.FirstTimeScreen;
|
||||
import com.vinlanx.explosionoverhaul.client.IntroMusicManager;
|
||||
import com.vinlanx.explosionoverhaul.client.SpriteSheetAnimator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Queue;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
|
||||
import net.minecraft.client.resources.sounds.SoundInstance;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.util.RandomSource;
|
||||
|
||||
public class GuideSlidesScreen
|
||||
extends Screen {
|
||||
private static final SlideData[] SLIDES = new SlideData[]{new SlideData("claster_slide.png", 177, "Cluster TNT \u2013 If you place more than two TNT blocks next to each other, the explosion will be much stronger!"), new SlideData("cave_slide.png", 121, "Caves \u2013 If an explosion happens on the surface while you're underground, you'll hear a terrifying rumble, and the ground and dripstones will start to crumble!"), new SlideData("glass_slide.png", 98, "Glass Shattering \u2013 Explosions create shockwaves! Be careful when working with explosives near settlements."), new SlideData("lamp_slide.png", 154, "Lamp Flickering \u2013 If an explosion happens near lamps, the lights will start to flicker."), new SlideData("speed_of_sound_slide.png", 140, "Speed of Sound \u2013 Explosions travel at the speed of sound. You can also enable \"Epic Mode\" in the settings!")};
|
||||
private static final int FRAME_WIDTH = 854;
|
||||
private static final int FRAME_HEIGHT = 480;
|
||||
private static final int COLUMNS = 14;
|
||||
private static final int ROWS = 14;
|
||||
private static final int FPS = 24;
|
||||
private static final int COLOR_BG = -15921907;
|
||||
private static final int COLOR_ACCENT_ORANGE = -881908;
|
||||
private static final int COLOR_ACCENT_RED = -4250588;
|
||||
private static final int COLOR_ACCENT_ROSE = -2529701;
|
||||
private static final int COLOR_ACCENT_DARK_RED = -10939115;
|
||||
private static final int COLOR_TEXT = -1;
|
||||
private static final int COLOR_PROGRESS_BG = Integer.MIN_VALUE;
|
||||
private static final int COLOR_PROGRESS_FILL = -881908;
|
||||
private static final float FADE_IN_DURATION = 1.5f;
|
||||
private static final float SLIDE_TRANSITION_DURATION = 1.0f;
|
||||
private static final float AUTO_ADVANCE_DELAY = 0.5f;
|
||||
private int currentSlideIndex = 0;
|
||||
private SpriteSheetAnimator currentAnimator;
|
||||
private float fadeAlpha = 0.0f;
|
||||
private boolean fadingIn = true;
|
||||
private float fadeTime = 0.0f;
|
||||
private boolean isTransitioning = false;
|
||||
private float transitionTime = 0.0f;
|
||||
private int transitionToIndex = -1;
|
||||
private float transitionAlpha = 0.0f;
|
||||
private SpriteSheetAnimator nextAnimator;
|
||||
private float autoAdvanceTimer = 0.0f;
|
||||
private boolean waitingForAutoAdvance = false;
|
||||
private Queue<Integer> transitionQueue = new LinkedList<Integer>();
|
||||
private int animationX;
|
||||
private int animationY;
|
||||
private int animationWidth;
|
||||
private int animationHeight;
|
||||
private int progressBarX;
|
||||
private int progressBarY;
|
||||
private int progressBarWidth;
|
||||
private int progressBarHeight;
|
||||
private int leftArrowX;
|
||||
private int leftArrowY;
|
||||
private int arrowSize;
|
||||
private int rightArrowX;
|
||||
private int rightArrowY;
|
||||
private boolean leftArrowHovered = false;
|
||||
private boolean rightArrowHovered = false;
|
||||
private float leftArrowScale = 1.0f;
|
||||
private float rightArrowScale = 1.0f;
|
||||
private int continueButtonX;
|
||||
private int continueButtonY;
|
||||
private int continueButtonWidth;
|
||||
private int continueButtonHeight;
|
||||
private boolean continueButtonHovered = false;
|
||||
private float continueButtonScale = 1.0f;
|
||||
private List<BackgroundParticle> particles = new ArrayList<BackgroundParticle>();
|
||||
private RandomSource random = RandomSource.m_216327_();
|
||||
private long lastFrameTime = System.currentTimeMillis();
|
||||
private IntroMusicManager musicManager;
|
||||
|
||||
public class GuideSlidesScreen extends Screen {
|
||||
public GuideSlidesScreen() {
|
||||
super((Component)Component.literal((String)"Guide Slides"));
|
||||
super(Component.empty());
|
||||
}
|
||||
|
||||
protected void m_7856_() {
|
||||
int i;
|
||||
super.m_7856_();
|
||||
this.fadingIn = true;
|
||||
this.fadeTime = 0.0f;
|
||||
this.fadeAlpha = 0.0f;
|
||||
this.isTransitioning = false;
|
||||
this.waitingForAutoAdvance = false;
|
||||
this.autoAdvanceTimer = 0.0f;
|
||||
this.lastFrameTime = System.currentTimeMillis();
|
||||
this.musicManager = IntroMusicManager.getInstance();
|
||||
this.loadSlide(this.currentSlideIndex);
|
||||
int maxWidth = (int)((float)this.f_96543_ * 0.76f);
|
||||
int maxHeight = (int)((float)this.f_96544_ * 0.65f);
|
||||
float aspectRatio = 1.7791667f;
|
||||
if ((float)maxWidth / aspectRatio <= (float)maxHeight) {
|
||||
this.animationWidth = maxWidth;
|
||||
this.animationHeight = (int)((float)maxWidth / aspectRatio);
|
||||
} else {
|
||||
this.animationHeight = maxHeight;
|
||||
this.animationWidth = (int)((float)maxHeight * aspectRatio);
|
||||
}
|
||||
this.animationX = (this.f_96543_ - this.animationWidth) / 2;
|
||||
this.animationY = (int)((float)this.f_96544_ * 0.12f);
|
||||
this.progressBarWidth = this.animationWidth;
|
||||
this.progressBarHeight = (int)((float)this.f_96544_ * 0.025f);
|
||||
this.progressBarX = this.animationX;
|
||||
this.progressBarY = this.animationY + this.animationHeight + (int)((float)this.f_96544_ * 0.03f);
|
||||
this.arrowSize = (int)((float)this.f_96544_ * 0.08f);
|
||||
int arrowGap = (int)((float)this.f_96543_ * 0.02f);
|
||||
this.leftArrowX = this.animationX - this.arrowSize - arrowGap;
|
||||
this.leftArrowY = this.animationY + (this.animationHeight - this.arrowSize) / 2;
|
||||
this.rightArrowX = this.animationX + this.animationWidth + arrowGap;
|
||||
this.rightArrowY = this.animationY + (this.animationHeight - this.arrowSize) / 2;
|
||||
this.continueButtonWidth = (int)((float)this.f_96543_ * 0.15f);
|
||||
this.continueButtonHeight = (int)((float)this.f_96544_ * 0.06f);
|
||||
this.continueButtonX = (this.f_96543_ - this.continueButtonWidth) / 2;
|
||||
this.continueButtonY = (int)((float)this.f_96544_ * 0.88f);
|
||||
for (i = 0; i < 30; ++i) {
|
||||
this.particles.add(BackgroundParticle.createSpark(this.random, this.f_96543_, this.f_96544_));
|
||||
}
|
||||
for (i = 0; i < 10; ++i) {
|
||||
this.particles.add(BackgroundParticle.createEmber(this.random, this.f_96543_, this.f_96544_));
|
||||
}
|
||||
for (i = 0; i < 5; ++i) {
|
||||
this.particles.add(BackgroundParticle.createSmoke(this.random, this.f_96543_, this.f_96544_));
|
||||
}
|
||||
}
|
||||
|
||||
private void loadSlide(int index) {
|
||||
if (index < 0 || index >= SLIDES.length) {
|
||||
return;
|
||||
}
|
||||
if (this.currentAnimator != null) {
|
||||
this.currentAnimator.close();
|
||||
}
|
||||
SlideData slide = SLIDES[index];
|
||||
this.currentAnimator = new SpriteSheetAnimator(slide.spriteSheet, 854, 480, 14, 14, slide.totalFrames, 24);
|
||||
this.currentAnimator.load();
|
||||
this.registerSoundCallbacks(index, this.currentAnimator);
|
||||
this.currentAnimator.play();
|
||||
ExplosionOverhaul.LOGGER.info("Loaded guide slide {} - texture created fresh", (Object)index);
|
||||
}
|
||||
|
||||
private void registerSoundCallbacks(int slideIndex, SpriteSheetAnimator animator) {
|
||||
switch (slideIndex) {
|
||||
case 0: {
|
||||
animator.registerFrameCallback(43, AnimationSoundManager::playRandomFarPower2Sound);
|
||||
animator.registerFrameCallback(132, AnimationSoundManager::playRandomSuperfar4Sound);
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
animator.registerFrameCallback(43, AnimationSoundManager::playRandomMediumCavePower4Sound);
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
animator.registerFrameCallback(30, AnimationSoundManager::playRandomFarPower3Sound);
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
animator.registerFrameCallback(34, AnimationSoundManager::playRandomFarPower2Sound);
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
animator.registerFrameCallback(30, AnimationSoundManager::playRandomFarPower2Sound);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void m_86600_() {
|
||||
float progress;
|
||||
super.m_86600_();
|
||||
long currentTime = System.currentTimeMillis();
|
||||
float deltaTime = Math.min((float)(currentTime - this.lastFrameTime) / 1000.0f, 0.1f);
|
||||
this.lastFrameTime = currentTime;
|
||||
if (this.fadingIn) {
|
||||
this.fadeTime += deltaTime;
|
||||
progress = Math.min(1.0f, this.fadeTime / 1.5f);
|
||||
this.fadeAlpha = this.easeOutCubic(progress);
|
||||
if (this.fadeTime >= 1.5f) {
|
||||
this.fadingIn = false;
|
||||
this.fadeAlpha = 1.0f;
|
||||
}
|
||||
}
|
||||
if (this.isTransitioning) {
|
||||
this.transitionTime += deltaTime;
|
||||
progress = Math.min(1.0f, this.transitionTime / 1.0f);
|
||||
this.transitionAlpha = this.easeInOutCubic(progress);
|
||||
if (this.transitionTime >= 1.0f) {
|
||||
this.isTransitioning = false;
|
||||
this.currentSlideIndex = this.transitionToIndex;
|
||||
if (this.currentAnimator != null) {
|
||||
this.currentAnimator.close();
|
||||
}
|
||||
this.currentAnimator = this.nextAnimator;
|
||||
this.nextAnimator = null;
|
||||
this.transitionToIndex = -1;
|
||||
this.waitingForAutoAdvance = false;
|
||||
this.autoAdvanceTimer = 0.0f;
|
||||
ExplosionOverhaul.LOGGER.info("Transition complete to slide {}", (Object)this.currentSlideIndex);
|
||||
if (!this.transitionQueue.isEmpty()) {
|
||||
int nextIndex = this.transitionQueue.poll();
|
||||
ExplosionOverhaul.LOGGER.info("Processing queued transition to slide {}", (Object)nextIndex);
|
||||
this.startTransition(nextIndex);
|
||||
}
|
||||
} else if (this.transitionAlpha >= 0.5f && this.nextAnimator == null && this.transitionToIndex >= 0 && this.transitionToIndex < SLIDES.length) {
|
||||
SlideData slide = SLIDES[this.transitionToIndex];
|
||||
this.nextAnimator = new SpriteSheetAnimator(slide.spriteSheet, 854, 480, 14, 14, slide.totalFrames, 24);
|
||||
this.nextAnimator.load();
|
||||
this.registerSoundCallbacks(this.transitionToIndex, this.nextAnimator);
|
||||
this.nextAnimator.play();
|
||||
ExplosionOverhaul.LOGGER.info("Created next slide {} animator at transition midpoint", (Object)this.transitionToIndex);
|
||||
}
|
||||
}
|
||||
if (this.currentAnimator != null && !this.isTransitioning) {
|
||||
this.currentAnimator.tick(deltaTime);
|
||||
}
|
||||
float scaleSpeed = 0.2f;
|
||||
float targetScale = 1.1f;
|
||||
this.leftArrowScale = Mth.m_14179_((float)scaleSpeed, (float)this.leftArrowScale, (float)(this.leftArrowHovered ? targetScale : 1.0f));
|
||||
this.rightArrowScale = Mth.m_14179_((float)scaleSpeed, (float)this.rightArrowScale, (float)(this.rightArrowHovered ? targetScale : 1.0f));
|
||||
this.continueButtonScale = Mth.m_14179_((float)scaleSpeed, (float)this.continueButtonScale, (float)(this.continueButtonHovered ? targetScale : 1.0f));
|
||||
this.particles.removeIf(p -> {
|
||||
p.tick(deltaTime);
|
||||
return p.isDead() || p.x < -50.0f || p.x > (float)(this.f_96543_ + 50) || p.y < -50.0f || p.y > (float)(this.f_96544_ + 50);
|
||||
});
|
||||
if (this.random.m_188501_() < 0.1f) {
|
||||
this.particles.add(BackgroundParticle.createSpark(this.random, this.f_96543_, this.f_96544_));
|
||||
}
|
||||
if (this.random.m_188501_() < 0.03f) {
|
||||
this.particles.add(BackgroundParticle.createEmber(this.random, this.f_96543_, this.f_96544_));
|
||||
}
|
||||
if (this.random.m_188501_() < 0.01f) {
|
||||
this.particles.add(BackgroundParticle.createSmoke(this.random, this.f_96543_, this.f_96544_));
|
||||
}
|
||||
if (this.musicManager != null) {
|
||||
this.musicManager.tick(deltaTime);
|
||||
}
|
||||
}
|
||||
|
||||
private void startTransition(int toIndex) {
|
||||
if (toIndex < 0 || toIndex >= SLIDES.length || this.isTransitioning) {
|
||||
return;
|
||||
}
|
||||
this.isTransitioning = true;
|
||||
this.transitionTime = 0.0f;
|
||||
this.transitionAlpha = 0.0f;
|
||||
this.transitionToIndex = toIndex;
|
||||
this.waitingForAutoAdvance = false;
|
||||
this.autoAdvanceTimer = 0.0f;
|
||||
ExplosionOverhaul.LOGGER.info("Starting transition from slide {} to {}", (Object)this.currentSlideIndex, (Object)toIndex);
|
||||
}
|
||||
|
||||
public void m_88315_(GuiGraphics graphics, int mouseX, int mouseY, float partialTick) {
|
||||
graphics.fill(0, 0, this.f_96543_, this.f_96544_, -15921907);
|
||||
if (this.fadeAlpha < 0.01f) {
|
||||
return;
|
||||
}
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.defaultBlendFunc();
|
||||
this.renderBackgroundParticles(graphics, this.fadeAlpha * 0.6f);
|
||||
if (this.isTransitioning) {
|
||||
float currentAlpha = 1.0f - this.transitionAlpha;
|
||||
float nextAlpha = this.transitionAlpha;
|
||||
if (this.currentAnimator != null && currentAlpha > 0.01f) {
|
||||
this.renderAnimation(graphics, this.currentAnimator, this.fadeAlpha * currentAlpha);
|
||||
}
|
||||
if (this.nextAnimator != null && nextAlpha > 0.01f) {
|
||||
this.renderAnimation(graphics, this.nextAnimator, this.fadeAlpha * nextAlpha);
|
||||
}
|
||||
} else if (this.currentAnimator != null) {
|
||||
this.renderAnimation(graphics, this.currentAnimator, this.fadeAlpha);
|
||||
}
|
||||
this.renderGuideText(graphics, this.fadeAlpha);
|
||||
this.renderArrows(graphics, mouseX, mouseY, this.fadeAlpha);
|
||||
this.renderContinueButton(graphics, mouseX, mouseY, this.fadeAlpha);
|
||||
RenderSystem.disableBlend();
|
||||
}
|
||||
|
||||
private void renderBackgroundParticles(GuiGraphics graphics, float alpha) {
|
||||
for (BackgroundParticle p : this.particles) {
|
||||
float particleAlpha = p.getAlpha();
|
||||
float finalAlpha = particleAlpha * alpha;
|
||||
int colorWithAlpha = p.color & 0xFFFFFF | (int)(finalAlpha * 255.0f) << 24;
|
||||
switch (p.type) {
|
||||
case SPARK: {
|
||||
float sparkLen = p.size * 3.0f;
|
||||
float sparkAngle = (float)Math.atan2(p.vy, p.vx);
|
||||
int ex = (int)((double)p.x + Math.cos(sparkAngle) * (double)sparkLen);
|
||||
int ey = (int)((double)p.y + Math.sin(sparkAngle) * (double)sparkLen);
|
||||
this.drawLine(graphics, (int)p.x, (int)p.y, ex, ey, colorWithAlpha);
|
||||
break;
|
||||
}
|
||||
case EMBER: {
|
||||
int emberSize = (int)p.size;
|
||||
graphics.fill((int)p.x - emberSize, (int)p.y - emberSize, (int)p.x + emberSize, (int)p.y + emberSize, colorWithAlpha);
|
||||
break;
|
||||
}
|
||||
case FLASH: {
|
||||
int flashSize = (int)(p.size * 0.7f);
|
||||
int flashColor = colorWithAlpha & 0xFFFFFF | (int)(finalAlpha * 180.0f) << 24;
|
||||
graphics.fill((int)p.x - flashSize, (int)p.y - flashSize, (int)p.x + flashSize, (int)p.y + flashSize, flashColor);
|
||||
break;
|
||||
}
|
||||
case SMOKE: {
|
||||
int smokeSize = (int)p.size;
|
||||
int smokeColor = colorWithAlpha & 0xFFFFFF | (int)(finalAlpha * 60.0f) << 24;
|
||||
graphics.fill((int)p.x - smokeSize, (int)p.y - smokeSize, (int)p.x + smokeSize, (int)p.y + smokeSize, smokeColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void renderAnimation(GuiGraphics graphics, SpriteSheetAnimator animator, float alpha) {
|
||||
ResourceLocation texture = animator.getTextureLocation();
|
||||
if (texture == null) {
|
||||
return;
|
||||
}
|
||||
RenderSystem.setShader(GameRenderer::m_172817_);
|
||||
RenderSystem.setShaderTexture((int)0, (ResourceLocation)texture);
|
||||
RenderSystem.setShaderColor((float)1.0f, (float)1.0f, (float)1.0f, (float)alpha);
|
||||
graphics.m_280411_(texture, this.animationX, this.animationY, this.animationWidth, this.animationHeight, 0.0f, 0.0f, 854, 480, 854, 480);
|
||||
int glowColor = (int)(alpha * 32.0f) << 24 | 0xF28B0C;
|
||||
int borderThickness = 2;
|
||||
graphics.fill(this.animationX - borderThickness, this.animationY - borderThickness, this.animationX + this.animationWidth + borderThickness, this.animationY, glowColor);
|
||||
graphics.fill(this.animationX - borderThickness, this.animationY + this.animationHeight, this.animationX + this.animationWidth + borderThickness, this.animationY + this.animationHeight + borderThickness, glowColor);
|
||||
graphics.fill(this.animationX - borderThickness, this.animationY, this.animationX, this.animationY + this.animationHeight, glowColor);
|
||||
graphics.fill(this.animationX + this.animationWidth, this.animationY, this.animationX + this.animationWidth + borderThickness, this.animationY + this.animationHeight, glowColor);
|
||||
}
|
||||
|
||||
private void renderProgressBar(GuiGraphics graphics, float alpha) {
|
||||
if (this.currentAnimator == null) {
|
||||
return;
|
||||
}
|
||||
int currentFrame = this.currentAnimator.getCurrentFrame();
|
||||
int totalFrames = GuideSlidesScreen.SLIDES[this.currentSlideIndex].totalFrames;
|
||||
float progress = (float)currentFrame / (float)totalFrames;
|
||||
int bgColor = (int)(alpha * 128.0f) << 24 | 0;
|
||||
graphics.fill(this.progressBarX, this.progressBarY, this.progressBarX + this.progressBarWidth, this.progressBarY + this.progressBarHeight, bgColor);
|
||||
int fillWidth = (int)((float)this.progressBarWidth * progress);
|
||||
int fillColor = (int)(alpha * 255.0f) << 24 | 0xF28B0C;
|
||||
graphics.fill(this.progressBarX, this.progressBarY, this.progressBarX + fillWidth, this.progressBarY + this.progressBarHeight, fillColor);
|
||||
if (fillWidth > 0) {
|
||||
int glowColor = (int)(alpha * 64.0f) << 24 | 0xF28B0C;
|
||||
graphics.fill(this.progressBarX + fillWidth - 4, this.progressBarY - 1, this.progressBarX + fillWidth, this.progressBarY + this.progressBarHeight + 1, glowColor);
|
||||
}
|
||||
}
|
||||
|
||||
private void renderGuideText(GuiGraphics graphics, float alpha) {
|
||||
String text = GuideSlidesScreen.SLIDES[this.currentSlideIndex].guideText;
|
||||
int textColor = (int)(alpha * 255.0f) << 24 | 0xFFFFFF;
|
||||
int textY = this.animationY + this.animationHeight + (int)((float)this.f_96544_ * 0.04f);
|
||||
int maxLineWidth = this.animationWidth;
|
||||
List<String> lines = this.wrapText(text, maxLineWidth);
|
||||
Objects.requireNonNull(this.f_96547_);
|
||||
int lineHeight = 9 + 4;
|
||||
int totalTextHeight = lines.size() * lineHeight;
|
||||
int startY = textY;
|
||||
for (int i = 0; i < lines.size(); ++i) {
|
||||
String line = lines.get(i);
|
||||
int lineWidth = this.f_96547_.width(line);
|
||||
int x = this.animationX + (this.animationWidth - lineWidth) / 2;
|
||||
graphics.m_280056_(this.f_96547_, line, x, startY + i * lineHeight, textColor, true);
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> wrapText(String text, int maxWidth) {
|
||||
ArrayList<String> lines = new ArrayList<String>();
|
||||
String[] words = text.split(" ");
|
||||
StringBuilder currentLine = new StringBuilder();
|
||||
for (String word : words) {
|
||||
Object testLine = currentLine.length() > 0 ? currentLine + " " + word : word;
|
||||
int width = this.f_96547_.width((String)testLine);
|
||||
if (width > maxWidth && currentLine.length() > 0) {
|
||||
lines.add(currentLine.toString());
|
||||
currentLine = new StringBuilder(word);
|
||||
continue;
|
||||
}
|
||||
if (currentLine.length() > 0) {
|
||||
currentLine.append(" ");
|
||||
}
|
||||
currentLine.append(word);
|
||||
}
|
||||
if (currentLine.length() > 0) {
|
||||
lines.add(currentLine.toString());
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
private void renderArrows(GuiGraphics graphics, int mouseX, int mouseY, float alpha) {
|
||||
this.leftArrowHovered = this.isPointInArrow(mouseX, mouseY, this.leftArrowX, this.leftArrowY, this.arrowSize);
|
||||
this.rightArrowHovered = this.isPointInArrow(mouseX, mouseY, this.rightArrowX, this.rightArrowY, this.arrowSize);
|
||||
if (this.currentSlideIndex > 0) {
|
||||
this.renderArrow(graphics, this.leftArrowX, this.leftArrowY, this.arrowSize, true, this.leftArrowScale, this.leftArrowHovered, alpha);
|
||||
}
|
||||
if (this.currentSlideIndex < SLIDES.length - 1) {
|
||||
this.renderArrow(graphics, this.rightArrowX, this.rightArrowY, this.arrowSize, false, this.rightArrowScale, this.rightArrowHovered, alpha);
|
||||
}
|
||||
}
|
||||
|
||||
private void renderArrow(GuiGraphics graphics, int x, int y, int size, boolean pointLeft, float scale, boolean hovered, float alpha) {
|
||||
int scaledSize = (int)((float)size * scale);
|
||||
int offset = (scaledSize - size) / 2;
|
||||
int drawX = x - offset;
|
||||
int drawY = y - offset;
|
||||
int bgColor = hovered ? (int)(alpha * 192.0f) << 24 | 0xF28B0C : (int)(alpha * 128.0f) << 24 | 0x591515;
|
||||
this.fillCircle(graphics, drawX + scaledSize / 2, drawY + scaledSize / 2, scaledSize / 2, bgColor);
|
||||
int arrowColor = (int)(alpha * 255.0f) << 24 | 0xFFFFFF;
|
||||
int centerX = drawX + scaledSize / 2;
|
||||
int centerY = drawY + scaledSize / 2;
|
||||
int arrowWidth = scaledSize / 3;
|
||||
int arrowHeight = scaledSize / 4;
|
||||
if (pointLeft) {
|
||||
this.fillTriangle(graphics, centerX + arrowWidth / 2, centerY - arrowHeight, centerX + arrowWidth / 2, centerY + arrowHeight, centerX - arrowWidth / 2, centerY, arrowColor);
|
||||
} else {
|
||||
this.fillTriangle(graphics, centerX - arrowWidth / 2, centerY - arrowHeight, centerX - arrowWidth / 2, centerY + arrowHeight, centerX + arrowWidth / 2, centerY, arrowColor);
|
||||
}
|
||||
if (hovered) {
|
||||
int glowColor = (int)(alpha * 64.0f) << 24 | 0xF28B0C;
|
||||
this.fillCircle(graphics, drawX + scaledSize / 2, drawY + scaledSize / 2, scaledSize / 2 + 4, glowColor);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isPointInArrow(int px, int py, int arrowX, int arrowY, int size) {
|
||||
int centerX = arrowX + size / 2;
|
||||
int dx = px - centerX;
|
||||
int centerY = arrowY + size / 2;
|
||||
int dy = py - centerY;
|
||||
int radius = size / 2;
|
||||
return dx * dx + dy * dy <= radius * radius;
|
||||
}
|
||||
|
||||
private void fillCircle(GuiGraphics graphics, int centerX, int centerY, int radius, int color) {
|
||||
for (int y = -radius; y <= radius; ++y) {
|
||||
for (int x = -radius; x <= radius; ++x) {
|
||||
if (x * x + y * y > radius * radius) continue;
|
||||
graphics.fill(centerX + x, centerY + y, centerX + x + 1, centerY + y + 1, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void fillTriangle(GuiGraphics graphics, int x1, int y1, int x2, int y2, int x3, int y3, int color) {
|
||||
int minY = Math.min(y1, Math.min(y2, y3));
|
||||
int maxY = Math.max(y1, Math.max(y2, y3));
|
||||
for (int y = minY; y <= maxY; ++y) {
|
||||
int x;
|
||||
int minX = Integer.MAX_VALUE;
|
||||
int maxX = Integer.MIN_VALUE;
|
||||
if (this.checkIntersection(y, y1, y2, x1, x2)) {
|
||||
x = this.interpolate(y, y1, y2, x1, x2);
|
||||
minX = Math.min(minX, x);
|
||||
maxX = Math.max(maxX, x);
|
||||
}
|
||||
if (this.checkIntersection(y, y2, y3, x2, x3)) {
|
||||
x = this.interpolate(y, y2, y3, x2, x3);
|
||||
minX = Math.min(minX, x);
|
||||
maxX = Math.max(maxX, x);
|
||||
}
|
||||
if (this.checkIntersection(y, y3, y1, x3, x1)) {
|
||||
x = this.interpolate(y, y3, y1, x3, x1);
|
||||
minX = Math.min(minX, x);
|
||||
maxX = Math.max(maxX, x);
|
||||
}
|
||||
if (minX == Integer.MAX_VALUE || maxX == Integer.MIN_VALUE) continue;
|
||||
graphics.fill(minX, y, maxX + 1, y + 1, color);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkIntersection(int y, int y1, int y2, int x1, int x2) {
|
||||
return y >= Math.min(y1, y2) && y <= Math.max(y1, y2) && y1 != y2;
|
||||
}
|
||||
|
||||
private int interpolate(int y, int y1, int y2, int x1, int x2) {
|
||||
return x1 + (y - y1) * (x2 - x1) / (y2 - y1);
|
||||
}
|
||||
|
||||
public boolean m_6375_(double mouseX, double mouseY, int button) {
|
||||
if (button == 0) {
|
||||
if (this.isPointInButton((int)mouseX, (int)mouseY)) {
|
||||
this.playButtonSound();
|
||||
this.transitionToFirstTimeScreen();
|
||||
return true;
|
||||
}
|
||||
if (this.currentSlideIndex > 0 && this.isPointInArrow((int)mouseX, (int)mouseY, this.leftArrowX, this.leftArrowY, this.arrowSize)) {
|
||||
Integer nextTransition;
|
||||
this.playButtonSound();
|
||||
int targetIndex = this.currentSlideIndex - 1;
|
||||
this.transitionQueue.offer(targetIndex);
|
||||
if (!this.isTransitioning && (nextTransition = this.transitionQueue.poll()) != null) {
|
||||
this.startTransition(nextTransition);
|
||||
}
|
||||
ExplosionOverhaul.LOGGER.info("Queued left arrow transition to {}, queue size: {}", (Object)targetIndex, (Object)this.transitionQueue.size());
|
||||
return true;
|
||||
}
|
||||
if (this.currentSlideIndex < SLIDES.length - 1 && this.isPointInArrow((int)mouseX, (int)mouseY, this.rightArrowX, this.rightArrowY, this.arrowSize)) {
|
||||
Integer nextTransition;
|
||||
this.playButtonSound();
|
||||
int targetIndex = this.currentSlideIndex + 1;
|
||||
this.transitionQueue.offer(targetIndex);
|
||||
if (!this.isTransitioning && (nextTransition = this.transitionQueue.poll()) != null) {
|
||||
this.startTransition(nextTransition);
|
||||
}
|
||||
ExplosionOverhaul.LOGGER.info("Queued right arrow transition to {}, queue size: {}", (Object)targetIndex, (Object)this.transitionQueue.size());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return super.m_6375_(mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
private boolean isPointInButton(int px, int py) {
|
||||
return px >= this.continueButtonX && px <= this.continueButtonX + this.continueButtonWidth && py >= this.continueButtonY && py <= this.continueButtonY + this.continueButtonHeight;
|
||||
}
|
||||
|
||||
private void renderContinueButton(GuiGraphics graphics, int mouseX, int mouseY, float alpha) {
|
||||
this.continueButtonHovered = this.isPointInButton(mouseX, mouseY);
|
||||
int scaledWidth = (int)((float)this.continueButtonWidth * this.continueButtonScale);
|
||||
int scaledHeight = (int)((float)this.continueButtonHeight * this.continueButtonScale);
|
||||
int offsetX = (scaledWidth - this.continueButtonWidth) / 2;
|
||||
int offsetY = (scaledHeight - this.continueButtonHeight) / 2;
|
||||
int drawX = this.continueButtonX - offsetX;
|
||||
int drawY = this.continueButtonY - offsetY;
|
||||
int bgColor = this.continueButtonHovered ? (int)(alpha * 220.0f) << 24 | 0xF28B0C : (int)(alpha * 160.0f) << 24 | 0x591515;
|
||||
graphics.fill(drawX, drawY, drawX + scaledWidth, drawY + scaledHeight, bgColor);
|
||||
if (this.continueButtonHovered) {
|
||||
int glowColor = (int)(alpha * 80.0f) << 24 | 0xF28B0C;
|
||||
int border = 3;
|
||||
graphics.fill(drawX - border, drawY - border, drawX + scaledWidth + border, drawY, glowColor);
|
||||
graphics.fill(drawX - border, drawY + scaledHeight, drawX + scaledWidth + border, drawY + scaledHeight + border, glowColor);
|
||||
graphics.fill(drawX - border, drawY, drawX, drawY + scaledHeight, glowColor);
|
||||
graphics.fill(drawX + scaledWidth, drawY, drawX + scaledWidth + border, drawY + scaledHeight, glowColor);
|
||||
}
|
||||
String text = "Skip Guide";
|
||||
int textColor = (int)(alpha * 255.0f) << 24 | 0xFFFFFF;
|
||||
int textX = drawX + (scaledWidth - this.f_96547_.width(text)) / 2;
|
||||
Objects.requireNonNull(this.f_96547_);
|
||||
int textY = drawY + (scaledHeight - 9) / 2;
|
||||
graphics.m_280056_(this.f_96547_, text, textX, textY, textColor, true);
|
||||
}
|
||||
|
||||
public boolean m_6913_() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean m_7043_() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void m_7861_() {
|
||||
super.m_7861_();
|
||||
this.transitionQueue.clear();
|
||||
if (this.currentAnimator != null) {
|
||||
this.currentAnimator.close();
|
||||
}
|
||||
if (this.nextAnimator != null) {
|
||||
this.nextAnimator.close();
|
||||
}
|
||||
}
|
||||
|
||||
private void transitionToFirstTimeScreen() {
|
||||
ExplosionOverhaul.LOGGER.info("All guide slides complete. Transitioning to FirstTimeScreen.");
|
||||
Minecraft.getInstance().m_91152_((Screen)new FirstTimeScreen());
|
||||
}
|
||||
|
||||
private void drawLine(GuiGraphics graphics, int x1, int y1, int x2, int y2, int color) {
|
||||
int dx = Math.abs(x2 - x1);
|
||||
int dy = Math.abs(y2 - y1);
|
||||
int sx = x1 < x2 ? 1 : -1;
|
||||
int sy = y1 < y2 ? 1 : -1;
|
||||
int err = dx - dy;
|
||||
for (int steps = 0; steps < 200; ++steps) {
|
||||
graphics.fill(x1, y1, x1 + 1, y1 + 1, color);
|
||||
if (x1 == x2 && y1 == y2) break;
|
||||
int e2 = 2 * err;
|
||||
if (e2 > -dy) {
|
||||
err -= dy;
|
||||
x1 += sx;
|
||||
}
|
||||
if (e2 >= dx) continue;
|
||||
err += dx;
|
||||
y1 += sy;
|
||||
}
|
||||
}
|
||||
|
||||
private float easeOutCubic(float t) {
|
||||
return 1.0f - (float)Math.pow(1.0f - t, 3.0);
|
||||
}
|
||||
|
||||
private float easeInCubic(float t) {
|
||||
return t * t * t;
|
||||
}
|
||||
|
||||
private float easeInOutCubic(float t) {
|
||||
return t < 0.5f ? 4.0f * t * t * t : 1.0f - (float)Math.pow(-2.0f * t + 2.0f, 3.0) / 2.0f;
|
||||
}
|
||||
|
||||
private void playButtonSound() {
|
||||
try {
|
||||
Minecraft minecraft = Minecraft.getInstance();
|
||||
if (minecraft.m_91106_() != null) {
|
||||
minecraft.m_91106_().m_120367_((SoundInstance)SimpleSoundInstance.m_119755_((SoundEvent)((SoundEvent)ModSounds.BUTTON_SOUND.get()), (float)1.0f, (float)1.0f));
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
ExplosionOverhaul.LOGGER.warn("Failed to play button sound", (Throwable)e);
|
||||
}
|
||||
}
|
||||
|
||||
private static class SlideData {
|
||||
final ResourceLocation spriteSheet;
|
||||
final int totalFrames;
|
||||
final String guideText;
|
||||
|
||||
SlideData(String filename, int frames, String text) {
|
||||
this.spriteSheet = ResourceLocation.fromNamespaceAndPath((String)"explosionoverhaul", (String)("intro_gui/" + filename));
|
||||
this.totalFrames = frames;
|
||||
this.guideText = text;
|
||||
}
|
||||
@Override
|
||||
public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTick) {
|
||||
super.render(graphics, mouseX, mouseY, partialTick);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user