generated from MrSphay/codex-agent-repository-kit
64 lines
2.7 KiB
Java
64 lines
2.7 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*/
|
|
package com.vinlanx.explosionoverhaul;
|
|
|
|
import com.vinlanx.explosionoverhaul.BlockIndexManager;
|
|
import com.vinlanx.explosionoverhaul.ScanInfoHUD;
|
|
import com.vinlanx.explosionoverhaul.client.ModKeyMappings;
|
|
import net.minecraft.client.Minecraft;
|
|
import net.minecraft.client.gui.GuiGraphics;
|
|
import net.neoforged.api.distmarker.Dist;
|
|
import net.neoforged.neoforge.client.event.RenderGuiEvent;
|
|
import net.neoforged.bus.api.SubscribeEvent;
|
|
import net.neoforged.fml.common.Mod;
|
|
import net.neoforged.fml.common.EventBusSubscriber;
|
|
|
|
@EventBusSubscriber(value={Dist.CLIENT})
|
|
public class ScanPromptHUD {
|
|
private static boolean isVisible = false;
|
|
|
|
public static boolean isVisible() {
|
|
return isVisible;
|
|
}
|
|
|
|
public static void setVisible(boolean visible) {
|
|
isVisible = visible;
|
|
if (!visible) {
|
|
ScanInfoHUD.setVisible(false);
|
|
}
|
|
}
|
|
|
|
@SubscribeEvent
|
|
public static void onRenderGuiOverlay(RenderGuiEvent.Post event) {
|
|
if (!isVisible) {
|
|
return;
|
|
}
|
|
Minecraft mc = Minecraft.getInstance();
|
|
if (mc.player == null) {
|
|
return;
|
|
}
|
|
if (!mc.player.m_20310_(2) && !mc.hasSingleplayerServer()) {
|
|
return;
|
|
}
|
|
GuiGraphics guiGraphics = event.getGuiGraphics();
|
|
String promptText = BlockIndexManager.isRescanMode() ? "Rescan all chunks?" : "Start chunk scanning?";
|
|
int x = 10;
|
|
int y = 10;
|
|
String key1Text = "[" + ModKeyMappings.ACCEPT_SCAN.getTranslatedKeyMessage().getString() + "] = Yes";
|
|
String key2Text = "[" + ModKeyMappings.DECLINE_SCAN.getTranslatedKeyMessage().getString() + "] = No";
|
|
String key3Text = "[" + ModKeyMappings.INFO_SCAN.getTranslatedKeyMessage().getString() + "] = Info";
|
|
int maxWidth = Math.max(mc.font.width(promptText), mc.font.width("Press " + key1Text + ", " + key2Text + ", " + key3Text));
|
|
guiGraphics.fill(x - 5, y - 5, x + maxWidth + 10, y + 35, Integer.MIN_VALUE);
|
|
guiGraphics.drawString(mc.font, promptText, x, y, 0xFFFFFF);
|
|
int currentX = x;
|
|
int textY = y + 12;
|
|
guiGraphics.drawString(mc.font, "Press ", currentX, textY, 0xFFFFFF);
|
|
guiGraphics.drawString(mc.font, key1Text, currentX += mc.font.width("Press "), textY, 65280);
|
|
guiGraphics.drawString(mc.font, ", ", currentX += mc.font.width(key1Text), textY, 0xFFFFFF);
|
|
guiGraphics.drawString(mc.font, key2Text, currentX += mc.font.width(", "), textY, 0xFF0000);
|
|
guiGraphics.drawString(mc.font, ", ", currentX += mc.font.width(key2Text), textY, 0xFFFFFF);
|
|
guiGraphics.drawString(mc.font, key3Text, currentX += mc.font.width(", "), textY, 0xFFFF00);
|
|
}
|
|
}
|