From 4eea61e78deb8a37feabab6edf50cc5c8154e06a Mon Sep 17 00:00:00 2001 From: XyperCode Date: Sun, 24 Mar 2024 13:51:57 +0100 Subject: [PATCH] Stable? --- LICENSE | 2 +- build.gradle | 33 ++++- common/build.gradle | 30 ++--- .../mods/advanceddebug/AdvancedDebug.java | 19 ++- .../advanceddebug/api/IAdvancedDebug.java | 17 ++- .../advanceddebug/api/common/Percentage.java | 2 +- .../api/common/SequencedHashMap.java | 2 +- .../api/init/ModDebugFormatters.java | 8 -- .../mods/advanceddebug/api/util/MathUtil.java | 2 +- .../mods/advanceddebug/client/Config.java | 76 ++++------- .../client/input/KeyBindingList.java | 2 +- .../advanceddebug/client/menu/DebugGui.java | 56 ++++---- .../client/menu/pages/DefaultPage.java | 2 +- .../client/menu/pages/EntityPage.java | 1 - .../client/menu/pages/MinecraftPage.java | 1 - .../client/menu/pages/PlayerPage.java | 1 - .../advanceddebug/init/ModDebugPages.java | 4 +- .../mixin/common/ImageButtonAccessor.java | 3 +- .../registry/ModPreRegistries.java | 4 +- .../mods/advanceddebug/util/ImGuiEx.java | 5 +- .../assets/advanced_debug/lang/en_us.json | 10 +- fabric/build.gradle | 9 +- .../client/fabric/ConfigImpl.java | 4 +- .../fabric/AdvDebugModMenuCompat.java | 15 +++ .../fabric/AdvancedDebugFabric.java | 2 - forge/build.gradle | 17 ++- .../client/forge/ConfigImpl.java | 13 -- .../forge/AdvancedDebugForge.java | 10 +- .../init/forge/ForgeOverlays.java | 4 +- .../mixin/forge/GameRendererMixin.java | 9 +- .../mixin/forge/KeyboardHandlerMixin.java | 8 +- forge/src/main/resources/META-INF/mods.toml | 6 +- gradle.properties | 33 ++--- neoforge/build.gradle | 124 ++++++++++++++++++ neoforge/gradle.properties | 1 + .../init/neoforge/ModOverlaysImpl.java | 18 +++ .../init/neoforge/NeoForgeOverlays.java | 25 ++++ .../mixin/neoforge/GameRendererMixin.java | 23 ++++ .../mixin/neoforge/KeyboardHandlerMixin.java | 62 +++++++++ .../neoforge/AdvancedDebugNeoForge.java | 28 ++++ .../src/main/resources/META-INF/mods.toml | 54 ++++++++ .../main/resources/advanced-debug.mixins.json | 15 +++ .../src/main/resources/advanced_debug.png | Bin 0 -> 407 bytes neoforge/src/main/resources/pack.mcmeta | 8 ++ settings.gradle | 4 +- 45 files changed, 582 insertions(+), 190 deletions(-) create mode 100644 fabric/src/main/java/com/ultreon/mods/advanceddebug/fabric/AdvDebugModMenuCompat.java delete mode 100644 forge/src/main/java/com/ultreon/mods/advanceddebug/client/forge/ConfigImpl.java create mode 100644 neoforge/build.gradle create mode 100644 neoforge/gradle.properties create mode 100644 neoforge/src/main/java/com/ultreon/mods/advanceddebug/init/neoforge/ModOverlaysImpl.java create mode 100644 neoforge/src/main/java/com/ultreon/mods/advanceddebug/init/neoforge/NeoForgeOverlays.java create mode 100644 neoforge/src/main/java/com/ultreon/mods/advanceddebug/mixin/neoforge/GameRendererMixin.java create mode 100644 neoforge/src/main/java/com/ultreon/mods/advanceddebug/mixin/neoforge/KeyboardHandlerMixin.java create mode 100644 neoforge/src/main/java/com/ultreon/mods/advanceddebug/neoforge/AdvancedDebugNeoForge.java create mode 100644 neoforge/src/main/resources/META-INF/mods.toml create mode 100644 neoforge/src/main/resources/advanced-debug.mixins.json create mode 100644 neoforge/src/main/resources/advanced_debug.png create mode 100644 neoforge/src/main/resources/pack.mcmeta diff --git a/LICENSE b/LICENSE index a9a95e2..752443e 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2022 Qboi123 (https://github.com/Qboi123) +Copyright (c) 2022 XyperCode (https://github.com/XyperCode) Ultreon API License (v1.0) --------------------------- diff --git a/build.gradle b/build.gradle index d36d5dd..d843d83 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,7 @@ //file:noinspection GroovyAccessibility plugins { id "architectury-plugin" version "3.4-SNAPSHOT" - id "dev.architectury.loom" version "1.3-SNAPSHOT" apply false + id "dev.architectury.loom" version "1.5-SNAPSHOT" apply false } repositories { gradlePluginPortal() @@ -12,8 +12,6 @@ architectury { minecraft = rootProject.minecraft_version } -version = mod_version - @SuppressWarnings('unused') Object getModDescription() { return "${mod_description}" @@ -21,6 +19,7 @@ Object getModDescription() { subprojects { apply plugin: "dev.architectury.loom" + apply plugin: "maven-publish" loom { silentMojangMappingsLicense() @@ -36,6 +35,19 @@ subprojects { compileOnly 'com.google.errorprone:error_prone_annotations:2.16' } + + publishing { + repositories { + maven { + name = "GitHubPackages" + url = uri("https://maven.pkg.github.com/Ultreon/advanced-debug") + credentials { + username = project.findProperty("gpr.user") == null ? System.getenv("USERNAME") : project.findProperty("gpr.user") + password = project.findProperty("gpr.key") == null ? System.getenv("TOKEN") : project.findProperty("gpr.key") + } + } + } + } } allprojects { @@ -44,7 +56,11 @@ allprojects { apply plugin: "maven-publish" archivesBaseName = rootProject.archives_base_name - version = rootProject.version + if (snapshot == "true") { + version = mod_version + "+snapshot." + new Date().format("yyyy.MM.dd.HH.mm") + } else { + version = mod_version + } group = rootProject.maven_group repositories { @@ -57,7 +73,14 @@ allprojects { maven { url "https://jitpack.io" } maven { url "https://cursemaven.com" } maven { url "https://raw.githubusercontent.com/Fuzss/modresources/main/maven/" } - + maven { + name = "GitHubPackages" + url = uri("https://maven.pkg.github.com/Ultreon/ultreonlib") + credentials { + username = project.findProperty("gpr.user") == null ? System.getenv("USERNAME") : project.findProperty("gpr.user") + password = project.findProperty("gpr.key") == null ? System.getenv("TOKEN") : project.findProperty("gpr.key") + } + } maven { name "Fuzs Mod Resources" url "https://raw.githubusercontent.com/Fuzss/modresources/main/maven/" diff --git a/common/build.gradle b/common/build.gradle index 70058ec..513d76c 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -1,6 +1,6 @@ //file:noinspection GradlePackageUpdate architectury { - common("fabric", "forge") + common("fabric", "forge", "neoforge") } loom { @@ -18,24 +18,22 @@ dependencies { // Remove the next line if you don't want to depend on the API modApi "dev.architectury:architectury:${architectury_version}" - modApi "com.github.Ultreon.ultreonlib:ultreon-lib:$ultreonlib_version" + modApi "com.ultreon.mods:ultreonlib-common:$ultreonlib_version" - api "com.github.Ultreon:ultreon-data:$ultreon_data_version" + api "io.github.ultreon:ubo:$ultreon_data_version" - api "com.github.Ultreon.corelibs:corelibs-collections-v0:$corelibs_version" - api "com.github.Ultreon.corelibs:corelibs-commons-v0:$corelibs_version" - api "com.github.Ultreon.corelibs:corelibs-crash-v0:$corelibs_version" - api "com.github.Ultreon.corelibs:corelibs-datetime-v0:$corelibs_version" - api "com.github.Ultreon.corelibs:corelibs-events-v1:$corelibs_version" - api "com.github.Ultreon.corelibs:corelibs-functions-v0:$corelibs_version" - api "com.github.Ultreon.corelibs:corelibs-registries-v0:$corelibs_version" - api "com.github.Ultreon.corelibs:corelibs-resources-v0:$corelibs_version" - api "com.github.Ultreon.corelibs:corelibs-text-v0:$corelibs_version" - api "com.github.Ultreon.corelibs:corelibs-translations-v0:$corelibs_version" + api "io.github.ultreon.corelibs:collections-v0:$corelibs_version" + api "io.github.ultreon.corelibs:commons-v0:$corelibs_version" + api "io.github.ultreon.corelibs:crash-v0:$corelibs_version" + api "io.github.ultreon.corelibs:datetime-v0:$corelibs_version" + api "io.github.ultreon.corelibs:events-v1:$corelibs_version" + api "io.github.ultreon.corelibs:functions-v0:$corelibs_version" + api "io.github.ultreon.corelibs:registries-v0:$corelibs_version" + api "io.github.ultreon.corelibs:resources-v0:$corelibs_version" + api "io.github.ultreon.corelibs:text-v0:$corelibs_version" + api "io.github.ultreon.corelibs:translations-v0:$corelibs_version" - modImplementation "fuzs.forgeconfigapiport:forgeconfigapiport-fabric:$forge_config_api_port_version" - modCompileOnly 'com.electronwill.night-config:core:3.6.3' - modCompileOnly 'com.electronwill.night-config:toml:3.6.3' + api "com.github.Ultreon:json5-api:d0a559bc9b" // ImGui implementation "io.github.spair:imgui-java-binding:$imgui_version" diff --git a/common/src/main/java/com/ultreon/mods/advanceddebug/AdvancedDebug.java b/common/src/main/java/com/ultreon/mods/advanceddebug/AdvancedDebug.java index 5849381..98a12d2 100644 --- a/common/src/main/java/com/ultreon/mods/advanceddebug/AdvancedDebug.java +++ b/common/src/main/java/com/ultreon/mods/advanceddebug/AdvancedDebug.java @@ -4,6 +4,7 @@ import com.ultreon.mods.advanceddebug.api.client.menu.IDebugGui; import com.ultreon.mods.advanceddebug.api.client.registry.IFormatterRegistry; import com.ultreon.mods.advanceddebug.api.init.ModDebugFormatters; +import com.ultreon.mods.advanceddebug.client.Config; import com.ultreon.mods.advanceddebug.client.input.KeyBindingList; import com.ultreon.mods.advanceddebug.client.menu.DebugGui; import com.ultreon.mods.advanceddebug.client.registry.FormatterRegistry; @@ -15,6 +16,7 @@ import com.ultreon.mods.advanceddebug.util.TargetUtils; import dev.architectury.event.events.client.ClientLifecycleEvent; import dev.architectury.event.events.client.ClientTickEvent; +import io.github.xypercode.craftyconfig.CraftyConfig; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.server.IntegratedServer; @@ -28,8 +30,6 @@ import org.slf4j.LoggerFactory; public class AdvancedDebug implements IAdvancedDebug { - public static final String MOD_ID = "advanced_debug"; - // Directly reference a log4j logger. public static final Logger LOGGER = LoggerFactory.getLogger("AdvancedDebug"); private static AdvancedDebug instance; @@ -38,19 +38,28 @@ public class AdvancedDebug implements IAdvancedDebug { public final InspectionRoot inspections = new InspectionRoot<>(Minecraft.getInstance()); - public static AdvancedDebug getInstance() { - return instance; - } + private final Config config = new Config(); @SuppressWarnings("ConstantConditions") public AdvancedDebug() { instance = this; + + config.load(); + } + + public static AdvancedDebug getInstance() { + return instance; } private static void tick(Minecraft minecraft) { DebugGui.get().tick(); } + @Override + public CraftyConfig getConfig() { + return config; + } + public void init() { ModOverlays.registerAll(); diff --git a/common/src/main/java/com/ultreon/mods/advanceddebug/api/IAdvancedDebug.java b/common/src/main/java/com/ultreon/mods/advanceddebug/api/IAdvancedDebug.java index 9f14f51..639c966 100644 --- a/common/src/main/java/com/ultreon/mods/advanceddebug/api/IAdvancedDebug.java +++ b/common/src/main/java/com/ultreon/mods/advanceddebug/api/IAdvancedDebug.java @@ -3,10 +3,13 @@ import com.ultreon.mods.advanceddebug.api.client.menu.IDebugGui; import com.ultreon.mods.advanceddebug.api.client.registry.IFormatterRegistry; import com.ultreon.mods.advanceddebug.client.Config; +import io.github.xypercode.craftyconfig.CraftyConfig; import java.lang.reflect.InvocationTargetException; public interface IAdvancedDebug { + String MOD_ID = "advanced_debug"; + static IAdvancedDebug get() { try { return (IAdvancedDebug) Class.forName("com.ultreon.mods.advanceddebug.AdvancedDebug").getDeclaredMethod("getInstance").invoke(null); @@ -16,6 +19,8 @@ static IAdvancedDebug get() { } } + CraftyConfig getConfig(); + IDebugGui getGui(); IFormatterRegistry getFormatterRegistry(); @@ -24,28 +29,28 @@ static IAdvancedDebug get() { @Deprecated(forRemoval = true) default boolean isSpacedNamespace() { - return Config.SPACED_NAMESPACES.get(); + return Config.spacedNamespaces; } @Deprecated(forRemoval = true) default boolean isSpacedEnumConstants() { - return Config.SPACED_ENUM_CONSTANTS.get(); + return Config.spacedEnumConstants; } @Deprecated(forRemoval = true) default boolean enableBubbleBlasterID() { - return Config.ENABLE_BUBBLE_BLASTER_ID.get(); + return Config.enableBubbleBlasterId; } default boolean isNamespaceSpaced() { - return Config.SPACED_NAMESPACES.get(); + return Config.spacedNamespaces; } default boolean isEnumConstantsSpaced() { - return Config.SPACED_ENUM_CONSTANTS.get(); + return Config.spacedEnumConstants; } default boolean isBubbleBlasterIdEnabled() { - return Config.ENABLE_BUBBLE_BLASTER_ID.get(); + return Config.enableBubbleBlasterId; } } diff --git a/common/src/main/java/com/ultreon/mods/advanceddebug/api/common/Percentage.java b/common/src/main/java/com/ultreon/mods/advanceddebug/api/common/Percentage.java index d89b158..4a758d2 100644 --- a/common/src/main/java/com/ultreon/mods/advanceddebug/api/common/Percentage.java +++ b/common/src/main/java/com/ultreon/mods/advanceddebug/api/common/Percentage.java @@ -10,7 +10,7 @@ * Use {@link #getValue() getValue} or {@link #setValue(double) setValue} for getting / settings the normalized value.
*
* - * @author Qboi123 + * @author XyperCode */ public final class Percentage implements IFormattable { private double percentage; diff --git a/common/src/main/java/com/ultreon/mods/advanceddebug/api/common/SequencedHashMap.java b/common/src/main/java/com/ultreon/mods/advanceddebug/api/common/SequencedHashMap.java index 4c7e7b0..8558505 100644 --- a/common/src/main/java/com/ultreon/mods/advanceddebug/api/common/SequencedHashMap.java +++ b/common/src/main/java/com/ultreon/mods/advanceddebug/api/common/SequencedHashMap.java @@ -61,7 +61,7 @@ * information on the Apache Software Foundation, please see * . * - * Note: this is modified to use type parameters. - Qboi123 + * Note: this is modified to use type parameters. - XyperCode * */ import org.jetbrains.annotations.NotNull; diff --git a/common/src/main/java/com/ultreon/mods/advanceddebug/api/init/ModDebugFormatters.java b/common/src/main/java/com/ultreon/mods/advanceddebug/api/init/ModDebugFormatters.java index f7150a9..bd60f87 100644 --- a/common/src/main/java/com/ultreon/mods/advanceddebug/api/init/ModDebugFormatters.java +++ b/common/src/main/java/com/ultreon/mods/advanceddebug/api/init/ModDebugFormatters.java @@ -406,14 +406,6 @@ public void format(BlockEntityType obj, IFormatterContext context) { .other(BuiltInRegistries.BLOCK_ENTITY_TYPE.getKey(obj)); } }); - public static final Formatter ADVANCEMENT = REGISTRY.register(new Formatter<>(Advancement.class, new ResourceLocation(IAdvancedDebug.get().getModId(), "minecraft/advancement")) { - @Override - public void format(Advancement obj, IFormatterContext context) { - context.className("advancement") - .space() - .other(obj.getId()); - } - }); public static final Formatter STAT = REGISTRY.register(new Formatter<>(Stat.class, new ResourceLocation(IAdvancedDebug.get().getModId(), "minecraft/stat")) { @Override public void format(Stat obj, IFormatterContext context) { diff --git a/common/src/main/java/com/ultreon/mods/advanceddebug/api/util/MathUtil.java b/common/src/main/java/com/ultreon/mods/advanceddebug/api/util/MathUtil.java index e8e2936..1650351 100644 --- a/common/src/main/java/com/ultreon/mods/advanceddebug/api/util/MathUtil.java +++ b/common/src/main/java/com/ultreon/mods/advanceddebug/api/util/MathUtil.java @@ -6,7 +6,7 @@ /** * Public math utilities. * - * @author Qboi123 + * @author XyperCode */ public class MathUtil { /** diff --git a/common/src/main/java/com/ultreon/mods/advanceddebug/client/Config.java b/common/src/main/java/com/ultreon/mods/advanceddebug/client/Config.java index 4fb651e..60b3189 100644 --- a/common/src/main/java/com/ultreon/mods/advanceddebug/client/Config.java +++ b/common/src/main/java/com/ultreon/mods/advanceddebug/client/Config.java @@ -1,50 +1,32 @@ package com.ultreon.mods.advanceddebug.client; -import com.ultreon.libs.commons.v0.Identifier; -import com.ultreon.mods.advanceddebug.api.client.menu.DebugPage; -import com.ultreon.mods.advanceddebug.client.menu.DebugGui; -import dev.architectury.injectables.annotations.ExpectPlatform; -import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.common.ForgeConfigSpec; - -import java.util.ArrayList; -import java.util.List; - -public class Config { - public static final ForgeConfigSpec.BooleanValue SHOW_FPS_ON_DEFAULT_PAGE; - public static final ForgeConfigSpec.BooleanValue SHOW_CURRENT_PAGE; - public static final ForgeConfigSpec.BooleanValue USE_CUSTOM_SCALE; - public static final ForgeConfigSpec.IntValue CUSTOM_SCALE; - public static final ForgeConfigSpec.BooleanValue SPACED_NAMESPACES; - public static final ForgeConfigSpec.BooleanValue SPACED_ENUM_CONSTANTS; - public static final ForgeConfigSpec.BooleanValue ENABLE_BUBBLE_BLASTER_ID; - public static final ForgeConfigSpec.ConfigValue> ENABLED_PAGES; - - static final ForgeConfigSpec.Builder CLIENT_BUILDER = new ForgeConfigSpec.Builder(); - - - static { - SHOW_FPS_ON_DEFAULT_PAGE = CLIENT_BUILDER.comment("Show FPS on default page").define("show_fps_on_default_page", false); - SHOW_CURRENT_PAGE = CLIENT_BUILDER.comment("Show current page").define("show_current_page", true); - USE_CUSTOM_SCALE = CLIENT_BUILDER.comment("Use scale other than in options").define("use_custom_scale", false); - CUSTOM_SCALE = CLIENT_BUILDER.comment("Custom scale to set").defineInRange("custom_scale", 2, 1, 4); - - List pages = DebugGui.get().getPages().stream().map(DebugPage::getId).map(Identifier::toString).toList(); - ENABLED_PAGES = CLIENT_BUILDER.comment("Enabled pages").defineList("enabled_pages", new ArrayList<>(pages), page -> page instanceof String pageName && pages.contains(pageName)); - - CLIENT_BUILDER.push("formatting"); - SPACED_NAMESPACES = CLIENT_BUILDER.comment("Spaced namespaces").define("spaced_namespaces", true); - SPACED_ENUM_CONSTANTS = CLIENT_BUILDER.comment("Spaced enum constants").define("spaced_enum_constants", true); - ENABLE_BUBBLE_BLASTER_ID = CLIENT_BUILDER.comment("Enable Bubble Blaster ID (Easter Egg)").define("enable_bubble_blaster_id", false); - CLIENT_BUILDER.pop(); - } - - @ExpectPlatform - public static void register(Object context) { - - } - - public static ForgeConfigSpec build() { - return CLIENT_BUILDER.build(); - } +import com.ultreon.mods.advanceddebug.api.IAdvancedDebug; +import io.github.xypercode.craftyconfig.ConfigEntry; +import io.github.xypercode.craftyconfig.ConfigInfo; +import io.github.xypercode.craftyconfig.CraftyConfig; +import io.github.xypercode.craftyconfig.Ranged; + +@ConfigInfo(fileName = "advanced-debug", modId = IAdvancedDebug.MOD_ID) +public class Config extends CraftyConfig { + @ConfigEntry(path = "showFpsOnDefaultPage", comment = "Show FPS on default page") + public static boolean showFpsOnDefaultPage = false; + + @ConfigEntry(path = "showCurrentPage", comment = "Show current page") + public static boolean showCurrentPage = true; + + @ConfigEntry(path = "useCustomScale", comment = "Use scale other than in options") + public static boolean useCustomScale = false; + + @ConfigEntry(path = "customScale", comment = "Custom scale to set") + @Ranged(min = 1, max = 4) + public static int customScale = 2; + + @ConfigEntry(path = "spacedNamespaces", comment = "Spaced namespaces") + public static boolean spacedNamespaces = true; + + @ConfigEntry(path = "spacedEnumConstants", comment = "Spaced enum constants") + public static boolean spacedEnumConstants = true; + + @ConfigEntry(path = "enableBubbleBlasterId", comment = "Enable Bubble Blaster ID") + public static boolean enableBubbleBlasterId = false; } diff --git a/common/src/main/java/com/ultreon/mods/advanceddebug/client/input/KeyBindingList.java b/common/src/main/java/com/ultreon/mods/advanceddebug/client/input/KeyBindingList.java index 269edc9..a4c33ec 100644 --- a/common/src/main/java/com/ultreon/mods/advanceddebug/client/input/KeyBindingList.java +++ b/common/src/main/java/com/ultreon/mods/advanceddebug/client/input/KeyBindingList.java @@ -10,7 +10,7 @@ /** * Keybinding list class. * - * @author Qboi123 + * @author XyperCode */ public class KeyBindingList { public static final List KEY_BINDINGS = new ArrayList<>(); diff --git a/common/src/main/java/com/ultreon/mods/advanceddebug/client/menu/DebugGui.java b/common/src/main/java/com/ultreon/mods/advanceddebug/client/menu/DebugGui.java index 992ecd4..3ab9410 100644 --- a/common/src/main/java/com/ultreon/mods/advanceddebug/client/menu/DebugGui.java +++ b/common/src/main/java/com/ultreon/mods/advanceddebug/client/menu/DebugGui.java @@ -46,6 +46,7 @@ import it.unimi.dsi.fastutil.longs.LongSet; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import net.fabricmc.loader.api.FabricLoader; import net.minecraft.ChatFormatting; import net.minecraft.CrashReport; import net.minecraft.CrashReportCategory; @@ -110,6 +111,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.concurrent.locks.ReentrantLock; +import java.util.function.Supplier; import static net.minecraft.ChatFormatting.*; import static net.minecraft.util.FastColor.ARGB32.*; @@ -184,7 +186,6 @@ public void format(Object obj, IFormatterContext context) { private String inspectIdxInput = ""; private DebugGui() { - ClassUtils.checkCallerClassEquals(DebugGui.class); if (INSTANCE != null) { throw new GenericError("Invalid initialization for singleton class " + DebugGui.class.getName()); } @@ -217,7 +218,7 @@ public void requestDisable() { CrashReportCategory shutdownReq = report.addCategory("Debug GUI Shutdown Request"); shutdownReq.setDetail("Duration", 30000 + "ms"); shutdownReq.setDetail("Flag set", !enabled); - Minecraft.crash(report); + Minecraft.crash(Minecraft.getInstance(), FabricLoader.getInstance().getGameDir().toFile(), report); Runtime.getRuntime().halt(0x0000_dead); // Should never run, unless some mod modifies crash handling in a weird way. } @@ -252,7 +253,9 @@ public boolean tryRequestDisable() throws InterruptedException { public void render(@NotNull GuiGraphics gfx, int mouseX, int mouseY, float partialTick) { if (!RenderSystem.isOnRenderThread()) return; - if (!enabled || Minecraft.getInstance().options.renderDebug) return; + if (!enabled + || Minecraft.getInstance().getDebugOverlay().showDebugScreen() + || Minecraft.getInstance().options.hideGui) return; updateSize(); @@ -263,18 +266,8 @@ public void render(@NotNull GuiGraphics gfx, int mouseX, int mouseY, float parti lock.lock(); double scale = mc.getWindow().getGuiScale(); - double preferredScale = Config.USE_CUSTOM_SCALE.get() ? Config.CUSTOM_SCALE.get() : scale; - Boolean useCustomScale = Config.USE_CUSTOM_SCALE.get(); - - int rescaledWidth = (int) (((double) width * scale) / preferredScale); - int rescaledHeight = (int) (((double) height * scale) / preferredScale); - - DebugRenderContext context = new DebugRenderContext(gfx, rescaledWidth, rescaledHeight) { - @Override - protected void drawLine(@NotNull GuiGraphics gfx, Component text, int x, int y) { - DebugGui.this.drawLine(gfx, text, x, y); - } - }; + double preferredScale = Config.useCustomScale ? Config.customScale : scale; + DebugRenderContext context = createContext(gfx, scale, preferredScale); long window = mc.getWindow().getWindow(); if (SHOW_OBJECT_INSPECTION.get()) { @@ -286,7 +279,7 @@ protected void drawLine(@NotNull GuiGraphics gfx, Component text, int x, int y) gfx.pose().scale((float) ((1 * preferredScale) / scale), (float) ((1 * preferredScale) / scale), 1); Identifier resourceLocation = debugPage.getId(); try { - if (Config.SHOW_CURRENT_PAGE.get()) { + if (Config.showCurrentPage) { drawLine(gfx, Component.literal("Debug Page: " + resourceLocation.toString()), 6, height - 16); } debugPage.render(gfx, context); @@ -313,6 +306,21 @@ protected void drawLine(@NotNull GuiGraphics gfx, Component text, int x, int y) lock.unlock(); } + @NotNull + private DebugRenderContext createContext(@NotNull GuiGraphics gfx, double scale, double preferredScale) { + Boolean useCustomScale = Config.useCustomScale; + + int rescaledWidth = (int) (((double) width * scale) / preferredScale); + int rescaledHeight = (int) (((double) height * scale) / preferredScale); + + return new DebugRenderContext(gfx, rescaledWidth, rescaledHeight) { + @Override + protected void drawLine(@NotNull GuiGraphics gfx1, Component text, int x, int y) { + DebugGui.this.drawLine(gfx1, text, x, y); + } + }; + } + private void renderObjectInspection(GuiGraphics gfx, long window, DebugRenderContext ctx, InspectionRoot inspections) { String path = this.inspectCurrentPath; @@ -380,9 +388,9 @@ private boolean renderInspections(GuiGraphics gfx, DebugRenderContext ctx, Inspe ctx.left(gfx, Component.literal("[" + i + "]: ").withStyle(s -> s.withColor(GOLD).withBold(true)).append(Component.literal(curNode.getName()).withStyle(s -> s.withColor(WHITE).withBold(false)))); } - List> elements = node.getElements().entrySet().stream().map(t -> new Pair<>(t.getKey(), t.getValue().get())).sorted(Comparator.comparing(Pair::getFirst)).toList(); - for (Pair element : elements) { - ctx.left(gfx, Component.literal(element.getFirst() + " = ").withStyle(s -> s.withColor(GRAY).withBold(false)).append(Component.literal(element.getSecond()).withStyle(s -> s.withColor(WHITE).withItalic(true)))); + List>> elements = node.getElements().entrySet().stream().map(t -> new Pair<>(t.getKey(), t.getValue())).sorted(Comparator.comparing(Pair::getFirst)).toList(); + for (Pair> element : elements) { + ctx.left(gfx, Component.literal(element.getFirst() + " = ").withStyle(s -> s.withColor(GRAY).withBold(false)).append(Component.literal(element.getSecond().get()).withStyle(s -> s.withColor(WHITE).withItalic(true)))); } return false; } @@ -407,7 +415,7 @@ public static synchronized void renderImGui(ImGuiImplGlfw glfw, ImGuiImplGl3 gl3 if (server != null) { if (nextTickTimeUpdate < System.currentTimeMillis()) { - int tps = (int) (MathUtils.average(server.tickTimes) * 1.0E-6D); + int tps = (int) (MathUtils.average(server.getTickTimesNanos()) * 1.0E-6D); ArrayUtils.shift(TICK_TIME_GRAPH, -1); TICK_TIME_GRAPH[TICK_TIME_GRAPH.length - 1] = tps; nextTickTimeUpdate = System.currentTimeMillis() + 1000; @@ -613,7 +621,6 @@ private static int getDefaultFlags() { } public static void showLocalPlayer(LocalPlayer player) { - ImGuiEx.text("Server Brand:", player::getServerBrand); ImGuiEx.text("Water Vision:", player::getWaterVision); showEntity(player); } @@ -1223,7 +1230,7 @@ public static void showLivingInfo(LivingEntity livingEntity) { public static void showEffectInstance(MobEffectInstance instance) { ImGuiEx.text("Id:", () -> BuiltInRegistries.MOB_EFFECT.getKey(instance.getEffect())); - ImGuiEx.text("Duration:", () -> MobEffectUtil.formatDuration(instance, 1.0f)); + ImGuiEx.text("Duration:", () -> MobEffectUtil.formatDuration(instance, 1.0f, Minecraft.getInstance().level.tickRateManager().tickrate())); ImGuiEx.text("Factor Data:", () -> instance.getFactorData().orElse(null)); } @@ -1312,7 +1319,10 @@ public static void showChildren(List children) { ImGuiEx.text("Value:", button::getValue); } if (child instanceof ImageButton button) { - ImGuiEx.text("Image:", () -> ((ImageButtonAccessor) button).getResourceLocation()); + ImGuiEx.text("Enabled Image:", () -> ((ImageButtonAccessor) button).getSprites().enabled()); + ImGuiEx.text("Disabled Image:", () -> ((ImageButtonAccessor) button).getSprites().disabled()); + ImGuiEx.text("Enabled Focused Image:", () -> ((ImageButtonAccessor) button).getSprites().enabledFocused()); + ImGuiEx.text("Disabled Focused Image:", () -> ((ImageButtonAccessor) button).getSprites().disabledFocused()); } if (child instanceof AbstractButton button) { ImGui.button("Click Button"); diff --git a/common/src/main/java/com/ultreon/mods/advanceddebug/client/menu/pages/DefaultPage.java b/common/src/main/java/com/ultreon/mods/advanceddebug/client/menu/pages/DefaultPage.java index 88daba9..9901ea8 100644 --- a/common/src/main/java/com/ultreon/mods/advanceddebug/client/menu/pages/DefaultPage.java +++ b/common/src/main/java/com/ultreon/mods/advanceddebug/client/menu/pages/DefaultPage.java @@ -18,7 +18,7 @@ public DefaultPage() { @Override public void render(@NotNull GuiGraphics gfx, IDebugRenderContext ctx) { - if (Config.SHOW_FPS_ON_DEFAULT_PAGE.get()) { + if (Config.showFpsOnDefaultPage) { ctx.left("FPS", MinecraftAccessor.getFps()); IntegratedServer server; if (mc.hasSingleplayerServer() && (server = mc.getSingleplayerServer()) != null) { diff --git a/common/src/main/java/com/ultreon/mods/advanceddebug/client/menu/pages/EntityPage.java b/common/src/main/java/com/ultreon/mods/advanceddebug/client/menu/pages/EntityPage.java index 1c96ec3..521cd30 100644 --- a/common/src/main/java/com/ultreon/mods/advanceddebug/client/menu/pages/EntityPage.java +++ b/common/src/main/java/com/ultreon/mods/advanceddebug/client/menu/pages/EntityPage.java @@ -44,7 +44,6 @@ public void render(@NotNull GuiGraphics gfx, IDebugRenderContext ctx) { ctx.left("Eye Height", entity.getEyeHeight()); ctx.left("Look Angle", entity.getLookAngle()); ctx.left("Riding Entity", entity.getVehicle()); - ctx.left("Riding Offset", entity.getMyRidingOffset()); ctx.left("Entity UUID", entity.getUUID()); ctx.left("Entity ID", entity.getId()); ctx.left("Entity Name", entity.getName().getString()); diff --git a/common/src/main/java/com/ultreon/mods/advanceddebug/client/menu/pages/MinecraftPage.java b/common/src/main/java/com/ultreon/mods/advanceddebug/client/menu/pages/MinecraftPage.java index 2cb1be3..dac002a 100644 --- a/common/src/main/java/com/ultreon/mods/advanceddebug/client/menu/pages/MinecraftPage.java +++ b/common/src/main/java/com/ultreon/mods/advanceddebug/client/menu/pages/MinecraftPage.java @@ -45,7 +45,6 @@ public void render(@NotNull GuiGraphics gfx, IDebugRenderContext ctx) { ctx.right("Game Paused", minecraft.isPaused()); ctx.right("Local Server", minecraft.isLocalServer()); ctx.right("Singleplayer", minecraft.hasSingleplayerServer()); - ctx.right("Connected to Realms", minecraft.isConnectedToRealms()); ctx.right(); } } diff --git a/common/src/main/java/com/ultreon/mods/advanceddebug/client/menu/pages/PlayerPage.java b/common/src/main/java/com/ultreon/mods/advanceddebug/client/menu/pages/PlayerPage.java index 0d831c7..9d2f399 100644 --- a/common/src/main/java/com/ultreon/mods/advanceddebug/client/menu/pages/PlayerPage.java +++ b/common/src/main/java/com/ultreon/mods/advanceddebug/client/menu/pages/PlayerPage.java @@ -70,7 +70,6 @@ public void render(@NotNull GuiGraphics gfx, IDebugRenderContext ctx) { ctx.left("Idle Time", player.getNoActionTime()); ctx.left("Motion", player.getDeltaMovement()); ctx.left("Team Name", (team != null ? team.getName() : "")); - ctx.left("Height Offset", player.getMyRidingOffset()); ctx.left("Eye Height", player.getEyeHeight()); ctx.left("Eye Height (real)", player.getEyeHeight(player.getPose())); ctx.left("Bounding Box", player.getBoundingBox()); diff --git a/common/src/main/java/com/ultreon/mods/advanceddebug/init/ModDebugPages.java b/common/src/main/java/com/ultreon/mods/advanceddebug/init/ModDebugPages.java index 03152b2..63a62e4 100644 --- a/common/src/main/java/com/ultreon/mods/advanceddebug/init/ModDebugPages.java +++ b/common/src/main/java/com/ultreon/mods/advanceddebug/init/ModDebugPages.java @@ -1,7 +1,7 @@ package com.ultreon.mods.advanceddebug.init; import com.ultreon.libs.commons.v0.Identifier; -import com.ultreon.mods.advanceddebug.AdvancedDebug; +import com.ultreon.mods.advanceddebug.api.IAdvancedDebug; import com.ultreon.mods.advanceddebug.api.client.menu.DebugPage; import com.ultreon.mods.advanceddebug.client.menu.DebugGui; import com.ultreon.mods.advanceddebug.client.menu.pages.*; @@ -23,7 +23,7 @@ public class ModDebugPages { public static final ComputerPage COMPUTER = register("computer", new ComputerPage()); private static T register(String name, T page) { - return DebugGui.get().registerPage(new Identifier(AdvancedDebug.MOD_ID, name), page); + return DebugGui.get().registerPage(new Identifier(IAdvancedDebug.MOD_ID, name), page); } public static void init() { diff --git a/common/src/main/java/com/ultreon/mods/advanceddebug/mixin/common/ImageButtonAccessor.java b/common/src/main/java/com/ultreon/mods/advanceddebug/mixin/common/ImageButtonAccessor.java index 15d7959..e61792d 100644 --- a/common/src/main/java/com/ultreon/mods/advanceddebug/mixin/common/ImageButtonAccessor.java +++ b/common/src/main/java/com/ultreon/mods/advanceddebug/mixin/common/ImageButtonAccessor.java @@ -2,6 +2,7 @@ import net.minecraft.client.ResourceLoadStateTracker; import net.minecraft.client.gui.components.ImageButton; +import net.minecraft.client.gui.components.WidgetSprites; import net.minecraft.resources.ResourceLocation; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; @@ -9,5 +10,5 @@ @Mixin(ImageButton.class) public interface ImageButtonAccessor { @Accessor - ResourceLocation getResourceLocation(); + WidgetSprites getSprites(); } diff --git a/common/src/main/java/com/ultreon/mods/advanceddebug/registry/ModPreRegistries.java b/common/src/main/java/com/ultreon/mods/advanceddebug/registry/ModPreRegistries.java index b31644b..5df5ab0 100644 --- a/common/src/main/java/com/ultreon/mods/advanceddebug/registry/ModPreRegistries.java +++ b/common/src/main/java/com/ultreon/mods/advanceddebug/registry/ModPreRegistries.java @@ -2,9 +2,9 @@ import com.ultreon.libs.commons.v0.Identifier; import com.ultreon.libs.registries.v0.Registry; -import com.ultreon.mods.advanceddebug.AdvancedDebug; +import com.ultreon.mods.advanceddebug.api.IAdvancedDebug; import com.ultreon.mods.advanceddebug.api.client.menu.DebugPage; public class ModPreRegistries { - public static final Registry DEBUG_PAGE = Registry.create(new Identifier(AdvancedDebug.MOD_ID, "debug_page")); + public static final Registry DEBUG_PAGE = Registry.create(new Identifier(IAdvancedDebug.MOD_ID, "debug_page")); } diff --git a/common/src/main/java/com/ultreon/mods/advanceddebug/util/ImGuiEx.java b/common/src/main/java/com/ultreon/mods/advanceddebug/util/ImGuiEx.java index c707014..7c3843c 100644 --- a/common/src/main/java/com/ultreon/mods/advanceddebug/util/ImGuiEx.java +++ b/common/src/main/java/com/ultreon/mods/advanceddebug/util/ImGuiEx.java @@ -31,6 +31,7 @@ import java.awt.*; import java.io.File; import java.io.IOException; +import java.nio.file.Path; import java.util.*; import java.util.List; import java.util.function.IntConsumer; @@ -72,7 +73,7 @@ public static void text(String label, Supplier value) { if (ImGuiFileDialog.isOk()) { String filePathName = ImGuiFileDialog.getFilePathName(); try { - NbtIo.writeCompressed(compoundTag, new File(filePathName)); + NbtIo.writeCompressed(compoundTag, Path.of(filePathName)); } catch (IOException e) { e.printStackTrace(); } @@ -116,7 +117,7 @@ public static void nbt(String label, Supplier o) { String filePathName = ImGuiFileDialog.getFilePathName(); try { - NbtIo.writeCompressed(compoundTag, new File(filePathName)); + NbtIo.writeCompressed(compoundTag, Path.of(filePathName)); } catch (IOException e) { e.printStackTrace(); } diff --git a/common/src/main/resources/assets/advanced_debug/lang/en_us.json b/common/src/main/resources/assets/advanced_debug/lang/en_us.json index 56cb5a8..db0ea44 100644 --- a/common/src/main/resources/assets/advanced_debug/lang/en_us.json +++ b/common/src/main/resources/assets/advanced_debug/lang/en_us.json @@ -2,5 +2,13 @@ "key.advanced_debug.debug_screen": "Change Page", "key.categories.advanced_debug": "Advanced Debug", "key.advanced_debug.selectEntity": "Select Entity", - "key.advanced_debug.selectBlock": "Select Block" + "key.advanced_debug.selectBlock": "Select Block", + "screen.advanced_debug.config": "Advanced Debug Config", + "config.advanced_debug.showFpsOnDefaultPage.description": "Show FPS on Default Page", + "config.advanced_debug.customScale.description": "Custom Scale", + "config.advanced_debug.showCurrentPage.description": "Show Current Page", + "config.advanced_debug.useCustomScale.description": "Use Custom Scale", + "config.advanced_debug.spacedNamespaces.description": "Spaced Namespaces", + "config.advanced_debug.enableBubbleBlasterId.description": "Enable Bubble Blaster ID", + "config.advanced_debug.spacedEnumConstants.description": "Spaced Enum Constants" } \ No newline at end of file diff --git a/fabric/build.gradle b/fabric/build.gradle index 9df1afc..55a6abc 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -34,18 +34,11 @@ dependencies { // Remove the next line if you don't want to depend on the API modApi "dev.architectury:architectury-fabric:$architectury_version" - modApi "com.github.Ultreon.ultreonlib:ultreon-lib-fabric:$ultreonlib_version" - - modImplementation 'com.electronwill.night-config:core:3.6.5' - modImplementation 'com.electronwill.night-config:toml:3.6.5' + modApi "com.ultreon.mods:ultreonlib-fabric:$ultreonlib_version" common(project(path: ":common", configuration: "namedElements")) { transitive false } shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false } - modImplementation "fuzs.forgeconfigapiport:forgeconfigapiport-fabric:$forge_config_api_port_version" - modImplementation "com.electronwill.night-config:core:$nightconfig_version" - modImplementation "com.electronwill.night-config:toml:$nightconfig_version" - modImplementation "com.terraformersmc:modmenu:$modmenu_version", { exclude module: "fabric-api" } diff --git a/fabric/src/main/java/com/ultreon/mods/advanceddebug/client/fabric/ConfigImpl.java b/fabric/src/main/java/com/ultreon/mods/advanceddebug/client/fabric/ConfigImpl.java index a46222e..e409cd6 100644 --- a/fabric/src/main/java/com/ultreon/mods/advanceddebug/client/fabric/ConfigImpl.java +++ b/fabric/src/main/java/com/ultreon/mods/advanceddebug/client/fabric/ConfigImpl.java @@ -1,12 +1,12 @@ package com.ultreon.mods.advanceddebug.client.fabric; -import com.ultreon.mods.advanceddebug.AdvancedDebug; +import com.ultreon.mods.advanceddebug.api.IAdvancedDebug; import com.ultreon.mods.advanceddebug.client.Config; import fuzs.forgeconfigapiport.api.config.v2.ForgeConfigRegistry; import net.minecraftforge.fml.config.ModConfig; public class ConfigImpl { public static void register(Object context) { - ForgeConfigRegistry.INSTANCE.register(AdvancedDebug.MOD_ID, ModConfig.Type.CLIENT, Config.build()); + ForgeConfigRegistry.INSTANCE.register(IAdvancedDebug.MOD_ID, ModConfig.Type.CLIENT, Config.build()); } } diff --git a/fabric/src/main/java/com/ultreon/mods/advanceddebug/fabric/AdvDebugModMenuCompat.java b/fabric/src/main/java/com/ultreon/mods/advanceddebug/fabric/AdvDebugModMenuCompat.java new file mode 100644 index 0000000..f57db57 --- /dev/null +++ b/fabric/src/main/java/com/ultreon/mods/advanceddebug/fabric/AdvDebugModMenuCompat.java @@ -0,0 +1,15 @@ +package com.ultreon.mods.advanceddebug.fabric; + +import com.terraformersmc.modmenu.api.ConfigScreenFactory; +import com.terraformersmc.modmenu.api.ModMenuApi; +import com.ultreon.mods.advanceddebug.AdvancedDebug; +import com.ultreon.mods.lib.client.gui.config.ConfigScreen; + +public class AdvDebugModMenuCompat implements ModMenuApi { + @Override + public ConfigScreenFactory getModConfigScreenFactory() { + return back -> { + return new ConfigScreen(AdvancedDebug.getInstance().getConfig(), back) + }; + } +} diff --git a/fabric/src/main/java/com/ultreon/mods/advanceddebug/fabric/AdvancedDebugFabric.java b/fabric/src/main/java/com/ultreon/mods/advanceddebug/fabric/AdvancedDebugFabric.java index 8f23052..af4ffec 100644 --- a/fabric/src/main/java/com/ultreon/mods/advanceddebug/fabric/AdvancedDebugFabric.java +++ b/fabric/src/main/java/com/ultreon/mods/advanceddebug/fabric/AdvancedDebugFabric.java @@ -9,7 +9,5 @@ public class AdvancedDebugFabric implements ClientModInitializer { public void onInitializeClient() { AdvancedDebug advancedDebug = new AdvancedDebug(); advancedDebug.init(); - - Config.register(null); } } diff --git a/forge/build.gradle b/forge/build.gradle index 61d2e53..528241e 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -33,16 +33,21 @@ dependencies { // Remove the next line if you don't want to depend on the API modApi "dev.architectury:architectury-forge:$architectury_version" - modApi "com.github.Ultreon.ultreonlib:ultreon-lib-forge:$ultreonlib_version" + modApi "com.ultreon.mods:ultreonlib-forge:$ultreonlib_version" common(project(path: ":common", configuration: "namedElements")) { transitive false } shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive = false } - include implementation("io.github.spair:imgui-java-binding:$imgui_version") - include implementation("io.github.spair:imgui-java-lwjgl3:$imgui_version") - include implementation("io.github.spair:imgui-java-natives-linux:$imgui_version") - include implementation("io.github.spair:imgui-java-natives-macos:$imgui_version") - include implementation("io.github.spair:imgui-java-natives-windows:$imgui_version") + include forgeRuntimeLibrary(implementation("io.github.spair:imgui-java-binding:$imgui_version")) + include forgeRuntimeLibrary(implementation("io.github.spair:imgui-java-lwjgl3:$imgui_version"), { exclude group: "org.lwjgl" }) + include forgeRuntimeLibrary(implementation("io.github.spair:imgui-java-natives-linux:$imgui_version")) + include forgeRuntimeLibrary(implementation("io.github.spair:imgui-java-natives-macos:$imgui_version")) + include forgeRuntimeLibrary(implementation("io.github.spair:imgui-java-natives-windows:$imgui_version")) + + forgeRuntimeLibrary "com.github.Ultreon:json5-api:$json5_api_version" + forgeRuntimeLibrary "io.github.ultreon.corelibs:commons-v0:$corelibs_version" + forgeRuntimeLibrary "io.github.ultreon.corelibs:collections-v0:$corelibs_version" + forgeRuntimeLibrary "io.github.ultreon.corelibs:registries-v0:$corelibs_version" } processResources { diff --git a/forge/src/main/java/com/ultreon/mods/advanceddebug/client/forge/ConfigImpl.java b/forge/src/main/java/com/ultreon/mods/advanceddebug/client/forge/ConfigImpl.java deleted file mode 100644 index 7c51bf1..0000000 --- a/forge/src/main/java/com/ultreon/mods/advanceddebug/client/forge/ConfigImpl.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.ultreon.mods.advanceddebug.client.forge; - -import com.ultreon.mods.advanceddebug.client.Config; -import net.minecraftforge.fml.ModLoadingContext; -import net.minecraftforge.fml.config.ModConfig; - -public class ConfigImpl { - public static void register(Object context) { - if (context instanceof ModLoadingContext ctx) { - ctx.registerConfig(ModConfig.Type.CLIENT, Config.build()); - } - } -} diff --git a/forge/src/main/java/com/ultreon/mods/advanceddebug/forge/AdvancedDebugForge.java b/forge/src/main/java/com/ultreon/mods/advanceddebug/forge/AdvancedDebugForge.java index 1f912c8..e924c04 100644 --- a/forge/src/main/java/com/ultreon/mods/advanceddebug/forge/AdvancedDebugForge.java +++ b/forge/src/main/java/com/ultreon/mods/advanceddebug/forge/AdvancedDebugForge.java @@ -1,14 +1,16 @@ package com.ultreon.mods.advanceddebug.forge; import com.ultreon.mods.advanceddebug.AdvancedDebug; -import com.ultreon.mods.advanceddebug.client.Config; +import com.ultreon.mods.advanceddebug.api.IAdvancedDebug; +import com.ultreon.mods.lib.client.gui.config.ConfigScreen; import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.client.ConfigScreenHandler; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.IExtensionPoint.DisplayTest; import net.minecraftforge.fml.ModLoadingContext; import net.minecraftforge.fml.common.Mod; -@Mod(AdvancedDebug.MOD_ID) +@Mod(IAdvancedDebug.MOD_ID) public class AdvancedDebugForge { public AdvancedDebugForge() { DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> { @@ -16,9 +18,11 @@ public AdvancedDebugForge() { advancedDebug.init(); ModLoadingContext ctx = ModLoadingContext.get(); - Config.register(ctx); ctx.registerExtensionPoint(DisplayTest.class, () -> new DisplayTest(() -> "anything. i don't care", (version, clientSide) -> clientSide)); + ctx.registerExtensionPoint(ConfigScreenHandler.ConfigScreenFactory.class, () -> new ConfigScreenHandler.ConfigScreenFactory((minecraft, back) -> { + return new ConfigScreen(advancedDebug.getConfig(), back); + })); }); } } diff --git a/forge/src/main/java/com/ultreon/mods/advanceddebug/init/forge/ForgeOverlays.java b/forge/src/main/java/com/ultreon/mods/advanceddebug/init/forge/ForgeOverlays.java index e6d4765..1ac7dcf 100644 --- a/forge/src/main/java/com/ultreon/mods/advanceddebug/init/forge/ForgeOverlays.java +++ b/forge/src/main/java/com/ultreon/mods/advanceddebug/init/forge/ForgeOverlays.java @@ -1,6 +1,6 @@ package com.ultreon.mods.advanceddebug.init.forge; -import com.ultreon.mods.advanceddebug.AdvancedDebug; +import com.ultreon.mods.advanceddebug.api.IAdvancedDebug; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.event.RegisterGuiOverlaysEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -11,7 +11,7 @@ import java.util.List; import java.util.function.Consumer; -@EventBusSubscriber(value = Dist.CLIENT, modid = AdvancedDebug.MOD_ID, bus = Bus.MOD) +@EventBusSubscriber(value = Dist.CLIENT, modid = IAdvancedDebug.MOD_ID, bus = Bus.MOD) public class ForgeOverlays { private static final List> LISTENERS = new ArrayList<>(); diff --git a/forge/src/main/java/com/ultreon/mods/advanceddebug/mixin/forge/GameRendererMixin.java b/forge/src/main/java/com/ultreon/mods/advanceddebug/mixin/forge/GameRendererMixin.java index 8571cfb..7f1b776 100644 --- a/forge/src/main/java/com/ultreon/mods/advanceddebug/mixin/forge/GameRendererMixin.java +++ b/forge/src/main/java/com/ultreon/mods/advanceddebug/mixin/forge/GameRendererMixin.java @@ -10,14 +10,15 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; +@SuppressWarnings("UnstableApiUsage") @Mixin(GameRenderer.class) public class GameRendererMixin { - @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/client/ForgeHooksClient;drawScreen(Lnet/minecraft/client/gui/screens/Screen;Lnet/minecraft/client/gui/GuiGraphics;IIF)V")) - private void advancedDebug$redirectMouseForImGui(Screen instance, @NotNull GuiGraphics gfx, int i, int j, float f) { + @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/client/ForgeHooksClient;drawScreen(Lnet/minecraft/client/gui/screens/Screen;Lnet/minecraft/client/gui/GuiGraphics;IIF)V", remap = false)) + private void advancedDebug$redirectMouseForImGui(Screen instance, @NotNull GuiGraphics gfx, int mouseX, int mouseY, float partialTicks) { if (DebugGui.isImGuiHovered()) { - ForgeHooksClient.drawScreen(instance, gfx, Integer.MAX_VALUE, Integer.MAX_VALUE, f); + ForgeHooksClient.drawScreen(instance, gfx, Integer.MAX_VALUE, Integer.MAX_VALUE, partialTicks); } else { - ForgeHooksClient.drawScreen(instance, gfx, i, j, f); + ForgeHooksClient.drawScreen(instance, gfx, mouseX, mouseY, partialTicks); } } } diff --git a/forge/src/main/java/com/ultreon/mods/advanceddebug/mixin/forge/KeyboardHandlerMixin.java b/forge/src/main/java/com/ultreon/mods/advanceddebug/mixin/forge/KeyboardHandlerMixin.java index a1ac3a3..77658e2 100644 --- a/forge/src/main/java/com/ultreon/mods/advanceddebug/mixin/forge/KeyboardHandlerMixin.java +++ b/forge/src/main/java/com/ultreon/mods/advanceddebug/mixin/forge/KeyboardHandlerMixin.java @@ -32,14 +32,14 @@ public class KeyboardHandlerMixin { } return true; } - @Redirect(method = "lambda$charTyped$6", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/client/ForgeHooksClient;onScreenCharTypedPre(Lnet/minecraft/client/gui/screens/Screen;CI)Z", ordinal = 0)) + @Redirect(method = "lambda$charTyped$6", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/client/ForgeHooksClient;onScreenCharTypedPre(Lnet/minecraft/client/gui/screens/Screen;CI)Z", ordinal = 0, remap = false)) private static boolean advancedDebug$redirectForgeCharTypedPre(Screen guiScreen, char codePoint, int modifiers) { if (!(DebugGui.isImGuiFocused() && !Minecraft.getInstance().mouseHandler.isMouseGrabbed())) { ForgeHooksClient.onScreenCharTypedPre(guiScreen, codePoint, modifiers); } return true; } - @Redirect(method = "lambda$charTyped$6", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/client/ForgeHooksClient;onScreenCharTypedPost(Lnet/minecraft/client/gui/screens/Screen;CI)V", ordinal = 0)) + @Redirect(method = "lambda$charTyped$6", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/client/ForgeHooksClient;onScreenCharTypedPost(Lnet/minecraft/client/gui/screens/Screen;CI)V", ordinal = 0, remap = false)) private static void advancedDebug$redirectForgeCharTypedPost(Screen guiScreen, char codePoint, int modifiers) { if (!(DebugGui.isImGuiFocused() && !Minecraft.getInstance().mouseHandler.isMouseGrabbed())) { ForgeHooksClient.onScreenCharTypedPost(guiScreen, codePoint, modifiers); @@ -52,14 +52,14 @@ public class KeyboardHandlerMixin { } return true; } - @Redirect(method = "lambda$charTyped$7", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/client/ForgeHooksClient;onScreenCharTypedPre(Lnet/minecraft/client/gui/screens/Screen;CI)Z", ordinal = 0)) + @Redirect(method = "lambda$charTyped$7", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/client/ForgeHooksClient;onScreenCharTypedPre(Lnet/minecraft/client/gui/screens/Screen;CI)Z", ordinal = 0, remap = false)) private static boolean advancedDebug$redirectForgeCharTypedPre2(Screen guiScreen, char codePoint, int modifiers) { if (!(DebugGui.isImGuiFocused() && !Minecraft.getInstance().mouseHandler.isMouseGrabbed())) { ForgeHooksClient.onScreenCharTypedPre(guiScreen, codePoint, modifiers); } return true; } - @Redirect(method = "lambda$charTyped$7", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/client/ForgeHooksClient;onScreenCharTypedPost(Lnet/minecraft/client/gui/screens/Screen;CI)V", ordinal = 0)) + @Redirect(method = "lambda$charTyped$7", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/client/ForgeHooksClient;onScreenCharTypedPost(Lnet/minecraft/client/gui/screens/Screen;CI)V", ordinal = 0, remap = false)) private static void advancedDebug$redirectForgeCharTypedPost2(Screen guiScreen, char codePoint, int modifiers) { if (!(DebugGui.isImGuiFocused() && !Minecraft.getInstance().mouseHandler.isMouseGrabbed())) { ForgeHooksClient.onScreenCharTypedPost(guiScreen, codePoint, modifiers); diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml index b29a83f..2edb7eb 100644 --- a/forge/src/main/resources/META-INF/mods.toml +++ b/forge/src/main/resources/META-INF/mods.toml @@ -29,20 +29,20 @@ side = "CLIENT" [[dependencies.advanced_debug]] modId = "minecraft" mandatory = true -versionRange = "[${minecraftVersion},1.20.2)" +versionRange = "${minecraftVersion}" ordering = "NONE" side = "CLIENT" [[dependencies.advanced_debug]] modId = "architectury" mandatory = true -versionRange = "[9.1,10)" +versionRange = "[11,12)" ordering = "NONE" side = "CLIENT" [[dependencies.advanced_debug]] modId = "ultreonlib" mandatory = true -versionRange = "[1.5.0,)" +versionRange = "[1.5,)" ordering = "NONE" side = "CLIENT" diff --git a/gradle.properties b/gradle.properties index e905228..3ae3af0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,22 +1,25 @@ org.gradle.jvmargs=-Xmx5G -minecraft_version=1.20.1 + +snapshot=true + +minecraft_version=1.20.4 archives_base_name=advanced-debug mod_version=2.5.0 -maven_group=com.ultreon.mods -architectury_version=9.1.12 -fabric_loader_version=0.14.21 -fabric_api_version=0.89.0+1.20.1 -forge_version=47.1.47 +maven_group=io.github.ultreon.mods +architectury_version=11.1.17 +fabric_loader_version=0.15.7 +fabric_api_version=0.96.11+1.20.4 +forge_version=49.0.38 +neoforge_version=20.4.210 -forge_config_api_port_version=8.0.0 -modmenu_version=7.2.2 -rei_version=12.0.659 - -nightconfig_version=3.6.5 +modmenu_version=9.0.0 +rei_version=14.0.688 mod_description=More advanced debug overlay, with way more information. Also has an API for developers. -ultreonlib_version=1.5.0 -imgui_version=1.86.10 -ultreon_data_version=0.1.0 -corelibs_version=0.1.0 +ultreonlib_version=1.6.0+snapshot.2024.03.24.13.11 +imgui_version=1.86.2 +ultreon_data_version=1.3.0 +corelibs_version=0.2.0 + +json5_api_version=d0a559bc9b diff --git a/neoforge/build.gradle b/neoforge/build.gradle new file mode 100644 index 0000000..7c7fd9b --- /dev/null +++ b/neoforge/build.gradle @@ -0,0 +1,124 @@ +//file:noinspection GrDeprecatedAPIUsage +//file:noinspection GroovyAssignabilityCheck +plugins { + id "com.github.johnrengelman.shadow" version "7.1.2" +} + +version rootProject.version + +architectury { + platformSetupLoomIde() + neoForge() +} + +loom { + accessWidenerPath = project(":common").loom.accessWidenerPath +} + +configurations { + common + shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this. + compileClasspath.extendsFrom common + runtimeClasspath.extendsFrom common + developmentNeoForge.extendsFrom common +} + +repositories { + maven { url = "https://maven.neoforged.net/releases" } +} + +dependencies { + neoForge "net.neoforged:neoforge:$neoforge_version" + // Remove the next line if you don't want to depend on the API + modApi "dev.architectury:architectury-neoforge:$architectury_version" + + modApi "com.ultreon.mods:ultreonlib-neoforge:$ultreonlib_version" + + common(project(path: ":common", configuration: "namedElements")) { transitive false } + shadowCommon(project(path: ":common", configuration: "transformProductionNeoForge")) { transitive = false } + + include forgeRuntimeLibrary(implementation("io.github.spair:imgui-java-binding:$imgui_version")) + include forgeRuntimeLibrary(implementation("io.github.spair:imgui-java-lwjgl3:$imgui_version")) + include forgeRuntimeLibrary(implementation("io.github.spair:imgui-java-natives-linux:$imgui_version")) + include forgeRuntimeLibrary(implementation("io.github.spair:imgui-java-natives-macos:$imgui_version")) + include forgeRuntimeLibrary(implementation("io.github.spair:imgui-java-natives-windows:$imgui_version")) + + forgeRuntimeLibrary "com.github.Ultreon:json5-api:$json5_api_version" + forgeRuntimeLibrary "io.github.ultreon.corelibs:commons-v0:$corelibs_version" + forgeRuntimeLibrary "io.github.ultreon.corelibs:collections-v0:$corelibs_version" + forgeRuntimeLibrary "io.github.ultreon.corelibs:registries-v0:$corelibs_version" +} + +processResources { + inputs.property "version", rootProject.version + inputs.property "description", rootProject.getModDescription() + System.out.println(inputs.getProperties()) + + filesMatching("META-INF/mods.toml") { + HashMap p = new HashMap<>() + p.put("version", rootProject.version) + p.put("description", rootProject.getModDescription()) + p.put("loaderVersion", rootProject.neoforge_version.split("\\.")[0]) + p.put("neoforgeVersion", rootProject.neoforge_version) + p.put("minecraftVersion", rootProject.architectury.minecraft) + expand(p) + } + + from "$rootProject.projectDir/LICENSE" +} + +shadowJar { + exclude "fabric.mod.json" + exclude "architectury.common.json" + + configurations = [project.configurations.shadowCommon] + archiveClassifier = "dev-shadow" +} + +remapJar { + input.set shadowJar.archiveFile + dependsOn shadowJar + archiveClassifier = null +} + +jar { + archiveClassifier = "dev" + manifest { + attributes([ + "Specification-Title" : "Ultreon Modding Lib", + "Specification-Vendor" : "Ultreon Team", + "Specification-Version" : "1", // We are version 1 of ourselves + "Implementation-Title" : project.name, + "Implementation-Version" : project.jar.archiveVersion, + "Implementation-Vendor" : "Ultreon Team", + "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") + ]) + } +} + +sourcesJar { + def commonSources = project(":common").sourcesJar + dependsOn commonSources + from commonSources.archiveFile.map { zipTree(it) } +} + +components.java { + withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { + skip() + } +} + +publishing { + publications { + mavenForge(MavenPublication) { + artifactId = rootProject.archives_base_name + "-" + project.name + from components.java + } + } + + // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. + repositories { + // Add repositories to publish to here. + mavenLocal() + } +} diff --git a/neoforge/gradle.properties b/neoforge/gradle.properties new file mode 100644 index 0000000..2914393 --- /dev/null +++ b/neoforge/gradle.properties @@ -0,0 +1 @@ +loom.platform=neoforge \ No newline at end of file diff --git a/neoforge/src/main/java/com/ultreon/mods/advanceddebug/init/neoforge/ModOverlaysImpl.java b/neoforge/src/main/java/com/ultreon/mods/advanceddebug/init/neoforge/ModOverlaysImpl.java new file mode 100644 index 0000000..7364b26 --- /dev/null +++ b/neoforge/src/main/java/com/ultreon/mods/advanceddebug/init/neoforge/ModOverlaysImpl.java @@ -0,0 +1,18 @@ +package com.ultreon.mods.advanceddebug.init.neoforge; + +import com.ultreon.mods.advanceddebug.AdvancedDebug; +import com.ultreon.mods.advanceddebug.api.IAdvancedDebug; +import net.minecraft.client.gui.components.Renderable; +import net.minecraft.resources.ResourceLocation; + +public class ModOverlaysImpl { + @SuppressWarnings("CodeBlock2Expr") + public static void registerTop(String name, Renderable overlay) { + NeoForgeOverlays.listen(event -> { + AdvancedDebug.LOGGER.info("Registering mod overlay: " + name); + event.registerAboveAll(new ResourceLocation(IAdvancedDebug.MOD_ID, name), (forgeGui, poseStack, tickDelta, x, y) -> { + overlay.render(poseStack, Integer.MAX_VALUE, Integer.MAX_VALUE, tickDelta); + }); + }); + } +} diff --git a/neoforge/src/main/java/com/ultreon/mods/advanceddebug/init/neoforge/NeoForgeOverlays.java b/neoforge/src/main/java/com/ultreon/mods/advanceddebug/init/neoforge/NeoForgeOverlays.java new file mode 100644 index 0000000..760d090 --- /dev/null +++ b/neoforge/src/main/java/com/ultreon/mods/advanceddebug/init/neoforge/NeoForgeOverlays.java @@ -0,0 +1,25 @@ +package com.ultreon.mods.advanceddebug.init.neoforge; + +import com.ultreon.mods.advanceddebug.api.IAdvancedDebug; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.bus.api.SubscribeEvent; +import net.neoforged.fml.common.Mod; +import net.neoforged.neoforge.client.event.RegisterGuiOverlaysEvent; + +import java.util.ArrayList; +import java.util.List; +import java.util.function.Consumer; + +@Mod.EventBusSubscriber(value = Dist.CLIENT, modid = IAdvancedDebug.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) +public class NeoForgeOverlays { + private static final List> LISTENERS = new ArrayList<>(); + + @SubscribeEvent + public static void registerGuiOverlays(RegisterGuiOverlaysEvent event) { + LISTENERS.forEach(listener -> listener.accept(event)); + } + + public static void listen(Consumer listener) { + LISTENERS.add(listener); + } +} diff --git a/neoforge/src/main/java/com/ultreon/mods/advanceddebug/mixin/neoforge/GameRendererMixin.java b/neoforge/src/main/java/com/ultreon/mods/advanceddebug/mixin/neoforge/GameRendererMixin.java new file mode 100644 index 0000000..5b38a2a --- /dev/null +++ b/neoforge/src/main/java/com/ultreon/mods/advanceddebug/mixin/neoforge/GameRendererMixin.java @@ -0,0 +1,23 @@ +package com.ultreon.mods.advanceddebug.mixin.neoforge; + +import com.ultreon.mods.advanceddebug.client.menu.DebugGui; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.renderer.GameRenderer; +import net.neoforged.neoforge.client.ClientHooks; +import org.jetbrains.annotations.NotNull; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(GameRenderer.class) +public class GameRendererMixin { + @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/neoforged/neoforge/client/ClientHooks;drawScreen(Lnet/minecraft/client/gui/screens/Screen;Lnet/minecraft/client/gui/GuiGraphics;IIF)V")) + private void advancedDebug$redirectMouseForImGui(Screen instance, @NotNull GuiGraphics gfx, int i, int j, float f) { + if (DebugGui.isImGuiHovered()) { + ClientHooks.drawScreen(instance, gfx, Integer.MAX_VALUE, Integer.MAX_VALUE, f); + } else { + ClientHooks.drawScreen(instance, gfx, i, j, f); + } + } +} diff --git a/neoforge/src/main/java/com/ultreon/mods/advanceddebug/mixin/neoforge/KeyboardHandlerMixin.java b/neoforge/src/main/java/com/ultreon/mods/advanceddebug/mixin/neoforge/KeyboardHandlerMixin.java new file mode 100644 index 0000000..ab76851 --- /dev/null +++ b/neoforge/src/main/java/com/ultreon/mods/advanceddebug/mixin/neoforge/KeyboardHandlerMixin.java @@ -0,0 +1,62 @@ +package com.ultreon.mods.advanceddebug.mixin.neoforge; + +import com.ultreon.mods.advanceddebug.client.menu.DebugGui; +import net.minecraft.client.KeyboardHandler; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.screens.Screen; +import net.neoforged.neoforge.client.ClientHooks; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(KeyboardHandler.class) +public class KeyboardHandlerMixin { + @Redirect(method = "method_1454", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screens/Screen;keyPressed(III)Z", ordinal = 0)) + private static boolean advancedDebug$redirectKeyPress(Screen instance, int keyCode, int scanCode, int modifiers) { + if (!(DebugGui.isImGuiFocused() && !Minecraft.getInstance().mouseHandler.isMouseGrabbed())) { + instance.keyPressed(keyCode, scanCode, modifiers); + } + return true; + } + @Redirect(method = "method_1454", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screens/Screen;keyReleased(III)Z", ordinal = 0)) + private static boolean advancedDebug$redirectKeyRelease(Screen instance, int keyCode, int scanCode, int modifiers) { + if (!(DebugGui.isImGuiFocused() && !Minecraft.getInstance().mouseHandler.isMouseGrabbed())) { + instance.keyPressed(keyCode, scanCode, modifiers); + } + return true; + } + @Redirect(method = "lambda$charTyped$6", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screens/Screen;charTyped(CI)Z", ordinal = 0)) + private static boolean advancedDebug$redirectCharTyped(Screen guiScreen, char codePoint, int modifiers) { + if (!(DebugGui.isImGuiFocused() && !Minecraft.getInstance().mouseHandler.isMouseGrabbed())) { + guiScreen.charTyped(codePoint, modifiers); + } + return true; + } + @Redirect(method = "lambda$charTyped$6", at = @At(value = "INVOKE", target = "Lnet/neoforged/neoforge/client/ClientHooks;onScreenCharTypedPre(Lnet/minecraft/client/gui/screens/Screen;CI)Z", ordinal = 0, remap = false)) + private static boolean advancedDebug$redirectForgeCharTypedPre(Screen guiScreen, char codePoint, int modifiers) { + if (!(DebugGui.isImGuiFocused() && !Minecraft.getInstance().mouseHandler.isMouseGrabbed())) { + ClientHooks.onScreenCharTypedPre(guiScreen, codePoint, modifiers); + } + return true; + } + @Redirect(method = "lambda$charTyped$6", at = @At(value = "INVOKE", target = "Lnet/neoforged/neoforge/client/ClientHooks;onScreenCharTypedPost(Lnet/minecraft/client/gui/screens/Screen;CI)V", ordinal = 0, remap = false)) + private static void advancedDebug$redirectForgeCharTypedPost(Screen guiScreen, char codePoint, int modifiers) { + if (!(DebugGui.isImGuiFocused() && !Minecraft.getInstance().mouseHandler.isMouseGrabbed())) { + ClientHooks.onScreenCharTypedPost(guiScreen, codePoint, modifiers); + } + } + @Redirect(method = "lambda$charTyped$7", at = @At(value = "INVOKE", target = "Lnet/neoforged/neoforge/client/ClientHooks;onScreenCharTypedPre(Lnet/minecraft/client/gui/screens/Screen;CI)Z", ordinal = 0, remap = false)) + private static boolean advancedDebug$redirectCharTyped2(Screen guiScreen, char codePoint, int modifiers) { + if (!(DebugGui.isImGuiFocused() && !Minecraft.getInstance().mouseHandler.isMouseGrabbed())) { + guiScreen.charTyped(codePoint, modifiers); + } + return true; + } + + @Redirect(method = "lambda$charTyped$7", at = @At(value = "INVOKE", target = "Lnet/neoforged/neoforge/client/ClientHooks;onScreenCharTypedPost(Lnet/minecraft/client/gui/screens/Screen;CI)V", ordinal = 0, remap = false)) + private static void advancedDebug$redirectForgeCharTypedPost2(Screen guiScreen, char codePoint, int modifiers) { + if (!(DebugGui.isImGuiFocused() && !Minecraft.getInstance().mouseHandler.isMouseGrabbed())) { + ClientHooks.onScreenCharTypedPost(guiScreen, codePoint, modifiers); + } + } +} diff --git a/neoforge/src/main/java/com/ultreon/mods/advanceddebug/neoforge/AdvancedDebugNeoForge.java b/neoforge/src/main/java/com/ultreon/mods/advanceddebug/neoforge/AdvancedDebugNeoForge.java new file mode 100644 index 0000000..aed639d --- /dev/null +++ b/neoforge/src/main/java/com/ultreon/mods/advanceddebug/neoforge/AdvancedDebugNeoForge.java @@ -0,0 +1,28 @@ +package com.ultreon.mods.advanceddebug.neoforge; + +import com.ultreon.mods.advanceddebug.AdvancedDebug; +import com.ultreon.mods.advanceddebug.api.IAdvancedDebug; +import com.ultreon.mods.lib.client.gui.config.ConfigScreen; +import dev.architectury.utils.Env; +import dev.architectury.utils.EnvExecutor; +import net.neoforged.fml.IExtensionPoint; +import net.neoforged.fml.ModLoadingContext; +import net.neoforged.fml.common.Mod; +import net.neoforged.neoforge.client.ConfigScreenHandler; + +@Mod(IAdvancedDebug.MOD_ID) +public class AdvancedDebugNeoForge { + public AdvancedDebugNeoForge() { + EnvExecutor.runInEnv(Env.CLIENT, () -> () -> { + AdvancedDebug advancedDebug = new AdvancedDebug(); + advancedDebug.init(); + + ModLoadingContext ctx = ModLoadingContext.get(); + + ctx.registerExtensionPoint(IExtensionPoint.DisplayTest.class, () -> new IExtensionPoint.DisplayTest(() -> "anything. i don't care", (version, clientSide) -> clientSide)); + ctx.registerExtensionPoint(ConfigScreenHandler.ConfigScreenFactory.class, () -> new ConfigScreenHandler.ConfigScreenFactory((minecraft, back) -> { + return new ConfigScreen(advancedDebug.getConfig(), back); + })); + }); + } +} diff --git a/neoforge/src/main/resources/META-INF/mods.toml b/neoforge/src/main/resources/META-INF/mods.toml new file mode 100644 index 0000000..b0f545f --- /dev/null +++ b/neoforge/src/main/resources/META-INF/mods.toml @@ -0,0 +1,54 @@ +modLoader = "javafml" +loaderVersion = "[2,)" +license = "Ultreon API 1.0" +issueTrackerURL = "https://github.com/Ultreon/advanced-debug/issues" + +# The main mod, and all sub-mods. +[[mods]] +modId = "advanced_debug" +version = "${version}" +displayName = "Advanced Debug" +#updateJSONURL="http://myurl.me/" +displayURL = "https://github.com/Ultreon/advanced-debug" +logoFile="advanced_debug.png" +credits = "Qboi" +authors = "Ultreon Team" +description = """ +${description} +""" +displayTest = "IGNORE_ALL_VERSION" + +[[mixins]] +config = "advanced-debug.mixins.json" + +[[mixins]] +config = "advanced-debug-common.mixins.json" + +# Dependencies for the main mod. +[[dependencies.advanced_debug]] +modId = "neoforge" +type = "required" +versionRange = "[${neoforgeVersion},)" +ordering = "NONE" +side = "CLIENT" + +[[dependencies.advanced_debug]] +modId = "minecraft" +type = "required" +versionRange = "${minecraftVersion}" +ordering = "NONE" +side = "CLIENT" + +[[dependencies.advanced_debug]] +modId = "architectury" +type = "required" +versionRange = "[11,12)" +ordering = "NONE" +side = "CLIENT" + +[[dependencies.advanced_debug]] +modId = "ultreonlib" +type = "required" +versionRange = "[1.5,)" +ordering = "BEFORE" +side = "CLIENT" diff --git a/neoforge/src/main/resources/advanced-debug.mixins.json b/neoforge/src/main/resources/advanced-debug.mixins.json new file mode 100644 index 0000000..d020a26 --- /dev/null +++ b/neoforge/src/main/resources/advanced-debug.mixins.json @@ -0,0 +1,15 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "com.ultreon.mods.advanceddebug.mixin.neoforge", + "compatibilityLevel": "JAVA_17", + "mixins": [ + ], + "client": [ + "GameRendererMixin", + "KeyboardHandlerMixin" + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/neoforge/src/main/resources/advanced_debug.png b/neoforge/src/main/resources/advanced_debug.png new file mode 100644 index 0000000000000000000000000000000000000000..4ce208341dde2bf94b410ca53d5826d5b20a9ace GIT binary patch literal 407 zcmeAS@N?(olHy`uVBq!ia0y~yU;;9k7?_xWRHv9tCXiw*4sv&5Sa(k5C6L3C?&#~t zz_78O`%fY(kk1+56XMFSwe-N7I|&z7D0SXc1PK;+L>4nJ@ErzW#^d=bQh=t2d%8G= zRNQ)dXCvnU10GjL{gJgA}z_ z=;1+7SRjD~vKyLQ9dBcp!GPp?h&PtJV&_282x8u6_CWY?$$ax;tohqpA`f~u><7tu My85}Sb4q9e0P)jad;kCd literal 0 HcmV?d00001 diff --git a/neoforge/src/main/resources/pack.mcmeta b/neoforge/src/main/resources/pack.mcmeta new file mode 100644 index 0000000..cf2ea09 --- /dev/null +++ b/neoforge/src/main/resources/pack.mcmeta @@ -0,0 +1,8 @@ +{ + "pack": { + "description": "Advanced Debug Resources", + "pack_format": 12, + "forge:resource_pack_format": 12, + "forge:data_pack_format": 10 + } +} diff --git a/settings.gradle b/settings.gradle index 06a89e4..0051514 100644 --- a/settings.gradle +++ b/settings.gradle @@ -3,10 +3,12 @@ pluginManagement { maven { url "https://maven.fabricmc.net/" } maven { url "https://maven.architectury.dev/" } maven { url "https://maven.minecraftforge.net/" } + maven { url "https://maven.neoforged.net/releases" } gradlePluginPortal() } } include("common") include("fabric") -include("forge") \ No newline at end of file +include("forge") +include("neoforge") \ No newline at end of file