diff options
author | Kevin <92656833+kevinthegreat1@users.noreply.github.com> | 2024-05-20 16:46:18 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-20 16:46:18 -0400 |
commit | 53668124dfcb53beba92b54062ae25315d5624b3 (patch) | |
tree | 3fe24a7071d74f04f7609ffaf2d4598119e75fb3 /src/main/java/de/hysky/skyblocker/debug/Debug.java | |
parent | 6886f2d89416bf56d0255f6aac3036141ce41caf (diff) | |
parent | c155b6532531fd2de49ced44b12730571d740432 (diff) | |
download | Skyblocker-53668124dfcb53beba92b54062ae25315d5624b3.tar.gz Skyblocker-53668124dfcb53beba92b54062ae25315d5624b3.tar.bz2 Skyblocker-53668124dfcb53beba92b54062ae25315d5624b3.zip |
Merge pull request #643 from VeritasDL/BranchMa
Quick Nav Refactor and Clean Up, 2 Extra Tabs, Config Version 3, Config Data Fixer Refactor, Debug Dump Hovered Item Tool
Diffstat (limited to 'src/main/java/de/hysky/skyblocker/debug/Debug.java')
-rw-r--r-- | src/main/java/de/hysky/skyblocker/debug/Debug.java | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/main/java/de/hysky/skyblocker/debug/Debug.java b/src/main/java/de/hysky/skyblocker/debug/Debug.java index 8c883b30..d9ac668c 100644 --- a/src/main/java/de/hysky/skyblocker/debug/Debug.java +++ b/src/main/java/de/hysky/skyblocker/debug/Debug.java @@ -2,21 +2,27 @@ package de.hysky.skyblocker.debug; import com.mojang.brigadier.Command; import com.mojang.brigadier.builder.LiteralArgumentBuilder; +import com.mojang.serialization.JsonOps; import de.hysky.skyblocker.SkyblockerMod; +import de.hysky.skyblocker.mixins.accessors.HandledScreenAccessor; import de.hysky.skyblocker.utils.Constants; import de.hysky.skyblocker.utils.ItemUtils; import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; +import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents; +import net.fabricmc.fabric.api.client.screen.v1.ScreenKeyboardEvents; import net.fabricmc.loader.api.FabricLoader; +import net.minecraft.client.gui.screen.ingame.HandledScreen; import net.minecraft.entity.decoration.ArmorStandEntity; import net.minecraft.item.ItemStack; import net.minecraft.predicate.entity.EntityPredicates; import net.minecraft.text.Text; - -import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal; +import org.lwjgl.glfw.GLFW; import java.util.List; +import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal; + public class Debug { private static final boolean DEBUG_ENABLED = Boolean.parseBoolean(System.getProperty("skyblocker.debug", "false")); @@ -26,6 +32,10 @@ public class Debug { return DEBUG_ENABLED || FabricLoader.getInstance().isDevelopmentEnvironment(); } + public static boolean shouldShowInvisibleArmorStands() { + return showInvisibleArmorStands; + } + public static void init() { if (debugEnabled()) { SnapshotDebug.init(); @@ -35,6 +45,15 @@ public class Debug { .then(toggleShowingInvisibleArmorStands()) .then(dumpArmorStandHeadTextures()) ))); + ScreenEvents.BEFORE_INIT.register((client, screen, scaledWidth, scaledHeight) -> { + if (screen instanceof HandledScreen<?> handledScreen) { + ScreenKeyboardEvents.afterKeyPress(screen).register((_screen, key, scancode, modifier) -> { + if (key == GLFW.GLFW_KEY_U && client.player != null) { + client.player.sendMessage(Text.literal("[Skyblocker Debug] Hovered Item: " + SkyblockerMod.GSON_COMPACT.toJson(ItemStack.CODEC.encodeStart(JsonOps.INSTANCE, ((HandledScreenAccessor) handledScreen).getFocusedSlot().getStack())))); + } + }); + } + }); } } @@ -73,8 +92,4 @@ public class Debug { return Command.SINGLE_SUCCESS; }); } - - public static boolean shouldShowInvisibleArmorStands() { - return showInvisibleArmorStands; - } } |