Files
Explosion-Overhaul/com/vinlanx/explosionoverhaul/ScanLoadInfoHUD.java
2026-05-04 10:03:58 +00:00

65 lines
3.4 KiB
Java

/*
* Decompiled with CFR 0.152.
*/
package com.vinlanx.explosionoverhaul;
import com.vinlanx.explosionoverhaul.client.ModKeyMappings;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.RenderGuiOverlayEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
@Mod.EventBusSubscriber(value={Dist.CLIENT})
public class ScanLoadInfoHUD {
private static boolean isVisible = false;
public static boolean isVisible() {
return isVisible;
}
public static void setVisible(boolean visible) {
isVisible = visible;
}
@SubscribeEvent
public static void onRenderGuiOverlay(RenderGuiOverlayEvent.Post event) {
if (!isVisible) {
return;
}
Minecraft mc = Minecraft.m_91087_();
if (mc.f_91074_ == null) {
return;
}
if (!mc.f_91074_.m_20310_(2) && !mc.m_91091_()) {
return;
}
GuiGraphics guiGraphics = event.getGuiGraphics();
String[] infoLines = new String[]{"\u00a76\u00a7lExisting Scan Data Found", "", "\u00a7eThis world has previously scanned block data.", "\u00a7eYou have two options:", "", "\u00a7a\u00a7l[" + ModKeyMappings.ACCEPT_SCAN.m_90863_().getString() + "] Load Data \u00a7r\u00a77- Load existing scan results", "\u00a77\u2022 Instant setup - no waiting time", "\u00a77\u2022 Uses previously found block positions", "\u00a77\u2022 May miss blocks placed after last scan", "\u00a77\u2022 Recommended for established worlds", "", "\u00a7c\u00a7l[" + ModKeyMappings.DECLINE_SCAN.m_90863_().getString() + "] New Scan \u00a7r\u00a77- Perform fresh scan", "\u00a77\u2022 Scans all chunks for current blocks", "\u00a77\u2022 Takes time but finds all blocks", "\u00a77\u2022 Replaces old data with new results", "\u00a77\u2022 Recommended if world changed significantly", "", "\u00a7eNote: \u00a77Block changes are tracked automatically", "\u00a77after loading, so both options work well for", "\u00a77ongoing gameplay.", "", "\u00a7cPress [" + ModKeyMappings.INFO_SCAN.m_90863_().getString() + "] again to close this info"};
int maxWidth = 0;
for (String line : infoLines) {
int lineWidth = mc.f_91062_.m_92895_(line);
if (lineWidth <= maxWidth) continue;
maxWidth = lineWidth;
}
int windowWidth = maxWidth + 20;
int windowHeight = infoLines.length * 12 + 20;
int screenWidth = mc.m_91268_().m_85445_();
int screenHeight = mc.m_91268_().m_85446_();
int x = (screenWidth - windowWidth) / 2;
int y = (screenHeight - windowHeight) / 2;
guiGraphics.m_280509_(x - 5, y - 5, x + windowWidth, y + windowHeight, -536870912);
guiGraphics.m_280509_(x - 6, y - 6, x + windowWidth + 1, y - 5, -12303292);
guiGraphics.m_280509_(x - 6, y + windowHeight, x + windowWidth + 1, y + windowHeight + 1, -12303292);
guiGraphics.m_280509_(x - 6, y - 5, x - 5, y + windowHeight, -12303292);
guiGraphics.m_280509_(x + windowWidth, y - 5, x + windowWidth + 1, y + windowHeight, -12303292);
for (int i = 0; i < infoLines.length; ++i) {
String line = infoLines[i];
if (line.isEmpty()) continue;
guiGraphics.m_280488_(mc.f_91062_, line, x + 10, y + 10 + i * 12, 0xFFFFFF);
}
}
}