generated from MrSphay/codex-agent-repository-kit
This commit is contained in:
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.vinlanx.explosionoverhaul.client;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.vinlanx.explosionoverhaul.client.IntroMusicManager;
|
||||
import com.vinlanx.explosionoverhaul.client.SpriteSheetAnimator;
|
||||
import com.vinlanx.explosionoverhaul.client.VinlanxSplashScreen;
|
||||
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.renderer.GameRenderer;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class IntroSplashScreen
|
||||
extends Screen {
|
||||
private static final ResourceLocation SPRITE_SHEET = ResourceLocation.fromNamespaceAndPath((String)"explosionoverhaul", (String)"intro_gui/screen.png");
|
||||
private static final int FRAME_WIDTH = 1280;
|
||||
private static final int FRAME_HEIGHT = 720;
|
||||
private static final int COLUMNS = 14;
|
||||
private static final int ROWS = 14;
|
||||
private static final int TOTAL_FRAMES = 196;
|
||||
private static final int FPS = 24;
|
||||
private SpriteSheetAnimator animator;
|
||||
private IntroMusicManager musicManager;
|
||||
private long lastFrameTime = System.currentTimeMillis();
|
||||
private boolean animationFinished = false;
|
||||
|
||||
public IntroSplashScreen() {
|
||||
super((Component)Component.m_237113_((String)"Intro"));
|
||||
}
|
||||
|
||||
protected void m_7856_() {
|
||||
super.m_7856_();
|
||||
this.animator = new SpriteSheetAnimator(SPRITE_SHEET, 1280, 720, 14, 14, 196, 24);
|
||||
this.animator.load();
|
||||
this.animator.play();
|
||||
this.musicManager = IntroMusicManager.getInstance();
|
||||
this.musicManager.start();
|
||||
}
|
||||
|
||||
public void m_86600_() {
|
||||
super.m_86600_();
|
||||
long currentTime = System.currentTimeMillis();
|
||||
float deltaTime = (float)(currentTime - this.lastFrameTime) / 1000.0f;
|
||||
this.lastFrameTime = currentTime;
|
||||
if (this.animator != null) {
|
||||
this.animator.tick(deltaTime);
|
||||
if (this.animator.getCurrentFrame() >= 195 && !this.animationFinished) {
|
||||
this.animationFinished = true;
|
||||
this.transitionToFirstTimeScreen();
|
||||
}
|
||||
}
|
||||
if (this.musicManager != null) {
|
||||
this.musicManager.tick(deltaTime);
|
||||
}
|
||||
}
|
||||
|
||||
public void m_88315_(GuiGraphics graphics, int mouseX, int mouseY, float partialTick) {
|
||||
int displayWidth;
|
||||
int displayHeight;
|
||||
graphics.m_280509_(0, 0, this.f_96543_, this.f_96544_, -16777216);
|
||||
if (this.animator == null) {
|
||||
return;
|
||||
}
|
||||
ResourceLocation texture = this.animator.getTextureLocation();
|
||||
if (texture == null) {
|
||||
return;
|
||||
}
|
||||
float screenAspectRatio = (float)this.f_96543_ / (float)this.f_96544_;
|
||||
float targetAspectRatio = 1.7777778f;
|
||||
if (screenAspectRatio > targetAspectRatio) {
|
||||
displayHeight = this.f_96544_;
|
||||
displayWidth = (int)((float)displayHeight * targetAspectRatio);
|
||||
} else {
|
||||
displayWidth = this.f_96543_;
|
||||
displayHeight = (int)((float)displayWidth / targetAspectRatio);
|
||||
}
|
||||
int x = (this.f_96543_ - displayWidth) / 2;
|
||||
int y = (this.f_96544_ - displayHeight) / 2;
|
||||
RenderSystem.setShader(GameRenderer::m_172817_);
|
||||
RenderSystem.setShaderTexture((int)0, (ResourceLocation)texture);
|
||||
RenderSystem.setShaderColor((float)1.0f, (float)1.0f, (float)1.0f, (float)1.0f);
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.defaultBlendFunc();
|
||||
graphics.m_280411_(texture, x, y, displayWidth, displayHeight, 0.0f, 0.0f, 1280, 720, 1280, 720);
|
||||
RenderSystem.disableBlend();
|
||||
}
|
||||
|
||||
public boolean m_6913_() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean m_7933_(int keyCode, int scanCode, int modifiers) {
|
||||
if (keyCode == 256) {
|
||||
this.skipToNext();
|
||||
return true;
|
||||
}
|
||||
return super.m_7933_(keyCode, scanCode, modifiers);
|
||||
}
|
||||
|
||||
public boolean m_6375_(double mouseX, double mouseY, int button) {
|
||||
this.skipToNext();
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean m_7043_() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void m_7861_() {
|
||||
super.m_7861_();
|
||||
if (this.animator != null) {
|
||||
this.animator.close();
|
||||
}
|
||||
if (this.musicManager != null) {
|
||||
this.musicManager.stopBoomSound();
|
||||
}
|
||||
}
|
||||
|
||||
private void skipToNext() {
|
||||
this.animationFinished = true;
|
||||
this.transitionToFirstTimeScreen();
|
||||
}
|
||||
|
||||
private void transitionToFirstTimeScreen() {
|
||||
Minecraft mc = Minecraft.m_91087_();
|
||||
if (!(mc.f_91080_ instanceof TitleScreen)) {
|
||||
mc.execute(() -> {
|
||||
if (mc.f_91080_ instanceof TitleScreen) {
|
||||
mc.m_91152_((Screen)new VinlanxSplashScreen());
|
||||
} else {
|
||||
mc.m_91152_((Screen)new VinlanxSplashScreen());
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
mc.m_91152_((Screen)new VinlanxSplashScreen());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user