Skip to content

Commit

Permalink
render debug info on screens in dev
Browse files Browse the repository at this point in the history
  • Loading branch information
brachy84 committed Jul 13, 2024
1 parent 5d2b895 commit f9ab468
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/main/java/com/cleanroommc/neverenoughanimations/NEA.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
import com.cleanroommc.neverenoughanimations.animations.ItemHoverAnimation;
import com.cleanroommc.neverenoughanimations.animations.ItemMoveAnimation;
import com.cleanroommc.neverenoughanimations.animations.OpeningAnimation;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraftforge.client.event.GuiOpenEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Config;
Expand All @@ -13,11 +19,14 @@
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import net.minecraftforge.fml.relauncher.FMLLaunchHandler;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.awt.*;

@Mod(modid = Tags.MODID, version = Tags.VERSION, name = Tags.MODNAME,
acceptedMinecraftVersions = "[1.12.2]", clientSideOnly = true, dependencies = "required:mixinbooter@[8.8,);")
public class NEA {
Expand Down Expand Up @@ -50,4 +59,37 @@ public void onGuiOpen(GuiOpenEvent event) {
ItemHoverAnimation.onGuiOpen(event);
ItemMoveAnimation.onGuiOpen(event);
}

public static void drawScreenDebug(GuiContainer container, int mouseX, int mouseY) {
if (!FMLLaunchHandler.isDeobfuscatedEnvironment() || container.getClass().getName().contains("modularui")) return;
GlStateManager.disableDepth();
GlStateManager.disableLighting();
GlStateManager.enableBlend();

int screenH = container.height;
int color = new java.awt.Color(180, 40, 115).getRGB();
int lineY = screenH - 13;
FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
container.drawString(fr, "Mouse Pos: " + mouseX + ", " + mouseY, 5, lineY, color);
lineY -= 11;
container.drawString(fr, "Rel. Mouse Pos: " + (mouseX - container.getGuiLeft()) + ", " + (mouseY - container.getGuiTop()), 5, lineY, color);
IItemLocation slot = IItemLocation.of(container.getSlotUnderMouse());
if (slot != null) {
lineY -= 11;
container.drawString(fr, "Pos: " + slot.nea$getX() + ", " + slot.nea$getY(), 5, lineY, color);
lineY -= 11;
container.drawString(fr, "Class: " + slot.getClass().getSimpleName(), 5, lineY, color);
lineY -= 11;
container.drawString(fr, "Slot Number: " + slot.nea$getSlotNumber(), 5, lineY, color);
lineY -= 11;
}
// dot at mouse pos
Gui.drawRect(mouseX, mouseY, mouseX + 1, mouseY + 1, new Color(10, 230, 10, (int) (0.8 * 155)).getRGB());

GlStateManager.color(1f, 1f, 1f, 1f);
GlStateManager.enableLighting();
GlStateManager.enableDepth();
GlStateManager.enableRescaleNormal();
RenderHelper.enableStandardItemLighting();
}
}

0 comments on commit f9ab468

Please sign in to comment.