/* * 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.GuideSlidesScreen; import com.vinlanx.explosionoverhaul.client.SpriteSheetAnimator; 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.client.sounds.SoundManager; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvent; public class VinlanxSplashScreen extends Screen { private static final ResourceLocation SPRITE_SHEET = ResourceLocation.fromNamespaceAndPath((String)"explosionoverhaul", (String)"intro_gui/vinlanx_screen.png"); private static final int FRAME_WIDTH = 1280; private static final int FRAME_HEIGHT = 720; private static final int COLUMNS = 12; private static final int ROWS = 12; private static final int TOTAL_FRAMES = 126; private static final int FPS = 24; private SpriteSheetAnimator animator; private boolean animationFinished = false; private long lastFrameTime = System.currentTimeMillis(); private SimpleSoundInstance boomSoundInstance; public VinlanxSplashScreen() { super((Component)Component.m_237113_((String)"Vinlanx Intro")); } protected void m_7856_() { super.m_7856_(); this.animator = new SpriteSheetAnimator(SPRITE_SHEET, 1280, 720, 12, 12, 126, 24); this.animator.load(); this.animator.play(); try { SoundManager soundManager = Minecraft.m_91087_().m_91106_(); this.boomSoundInstance = SimpleSoundInstance.m_119755_((SoundEvent)((SoundEvent)ModSounds.INTRO_BOOM_2.get()), (float)1.0f, (float)1.0f); soundManager.m_120367_((SoundInstance)this.boomSoundInstance); } catch (Exception e) { ExplosionOverhaul.LOGGER.warn("Failed to play intro_boom_2: {}", (Object)e.toString()); } } 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.animationFinished && this.animator.getCurrentFrame() >= 125) { this.animationFinished = true; this.transitionToFirstTimeScreen(); } } } 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.boomSoundInstance != null) { try { Minecraft.m_91087_().m_91106_().m_120399_((SoundInstance)this.boomSoundInstance); } catch (Exception e) { ExplosionOverhaul.LOGGER.warn("Failed to stop intro_boom_2: {}", (Object)e.toString()); } } } private void skipToNext() { this.animationFinished = true; this.transitionToFirstTimeScreen(); } private void transitionToFirstTimeScreen() { Minecraft mc = Minecraft.m_91087_(); mc.m_91152_((Screen)new GuideSlidesScreen()); } }