/* * 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 textures = new HashMap(); private final Map resourceLocations = new HashMap(); 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.m_91087_().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.m_91087_().m_91098_().m_213713_(fullPath).get()).m_215507_(); NativeImage image = NativeImage.m_85058_((InputStream)is); DynamicTexture texture = new DynamicTexture(image); ResourceLocation loc = Minecraft.m_91087_().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; } public void clear() { this.textures.values().forEach(DynamicTexture::close); this.textures.clear(); this.resourceLocations.clear(); } }