diff --git a/build.gradle.kts b/build.gradle.kts index 239808d..6b6cef8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -51,6 +51,10 @@ loom { } } + if(isForge) { + forge.mixinConfig("wayfix.mixins.json") + } + /* runConfigs.all { ideConfigGenerated(stonecutter.current.isActive) @@ -74,12 +78,12 @@ tasks.processResources { if (isFabric) { filesMatching("fabric.mod.json") { expand(expandProps) } - exclude("META-INF/mods.toml", "META-INF/neoforge.mods.toml", "pack.mcmeta") + exclude("META-INF/mods.toml", "META-INF/neoforge.mods.toml", "pack.mcmeta", "icon.png") } if(isForge) { filesMatching("META-INF/*mods.toml") { expand(expandProps) } - exclude("fabric.mod.json") + exclude("fabric.mod.json", "assets/wayfix/icon.png") } inputs.properties(expandProps) diff --git a/gradle.properties b/gradle.properties index 68258ed..694c8b0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,8 +1,6 @@ # Done to increase the memory available to gradle. org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 #org.gradle.parallel=true -org.gradle.caching=true -org.gradle.caching.debug=false # Mod Information mod.version=1.0.2 diff --git a/src/main/java/net/notcoded/wayfix/WayFix.java b/src/main/java/net/notcoded/wayfix/WayFix.java index 82c567b..f00d552 100644 --- a/src/main/java/net/notcoded/wayfix/WayFix.java +++ b/src/main/java/net/notcoded/wayfix/WayFix.java @@ -11,8 +11,7 @@ *///?} elif forge { import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.common.Mod; //? if >=1.19 { import net.minecraftforge.client.ConfigScreenHandler; @@ -40,24 +39,21 @@ public void onInitializeClient() { //? if forge { public WayFix() { - IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); - modEventBus.addListener(WayFix::onClientSetup); + DistExecutor.safeRunWhenOn(Dist.CLIENT, () -> WayFix::setupConfigScreen); } - private static void onClientSetup(final FMLClientSetupEvent event) { - event.enqueueWork(() -> { - //? if >=1.19 { - ModLoadingContext.get().registerExtensionPoint(ConfigScreenHandler.ConfigScreenFactory.class, () -> - new ConfigScreenHandler.ConfigScreenFactory( - (client, parent) -> AutoConfig.getConfigScreen(ModConfig.class, parent).get() - ) - ); - //?} elif <1.19 { - /*ModLoadingContext.get().registerExtensionPoint(ExtensionPoint.CONFIGGUIFACTORY, () -> - (client, parent) -> AutoConfig.getConfigScreen(ModConfig.class, parent).get() - );*///?} - }); - } + private static void setupConfigScreen() { + //? if >=1.19 { + ModLoadingContext.get().registerExtensionPoint(ConfigScreenHandler.ConfigScreenFactory.class, () -> + new ConfigScreenHandler.ConfigScreenFactory( + (client, parent) -> AutoConfig.getConfigScreen(ModConfig.class, parent).get() + ) + ); + //?} elif <1.19 { + /*ModLoadingContext.get().registerExtensionPoint(ExtensionPoint.CONFIGGUIFACTORY, () -> + (client, parent) -> AutoConfig.getConfigScreen(ModConfig.class, parent).get() + );*///?} + } //?} public static boolean isWayland() { diff --git a/src/main/java/net/notcoded/wayfix/mixin/MinecraftClientMixin.java b/src/main/java/net/notcoded/wayfix/mixin/MinecraftClientMixin.java index 9ccc307..b2c4427 100644 --- a/src/main/java/net/notcoded/wayfix/mixin/MinecraftClientMixin.java +++ b/src/main/java/net/notcoded/wayfix/mixin/MinecraftClientMixin.java @@ -34,11 +34,11 @@ private double fixHiDPIScaling(double d) { *///?} // "Auto" or Gui Scale 0 already auto-scales it - return guiScale != 0 && WayFix.config.autoScaleGUI ? window.calculateScaleFactor(Math.round(guiScale * getScaleFactor()), this.forcesUnicodeFont()) : d; + return guiScale != 0 && WayFix.config.autoScaleGUI ? window.calculateScaleFactor(Math.round(guiScale * wayFix$getScaleFactor()), this.forcesUnicodeFont()) : d; } @Unique - private float getScaleFactor() { + private float wayFix$getScaleFactor() { float[] pos = new float[1]; GLFW.glfwGetWindowContentScale(this.window.getHandle(), pos, pos); diff --git a/src/main/java/net/notcoded/wayfix/mixin/MonitorTrackerMixin.java b/src/main/java/net/notcoded/wayfix/mixin/MonitorTrackerMixin.java index 128bc09..6cf2756 100644 --- a/src/main/java/net/notcoded/wayfix/mixin/MonitorTrackerMixin.java +++ b/src/main/java/net/notcoded/wayfix/mixin/MonitorTrackerMixin.java @@ -21,11 +21,11 @@ public class MonitorTrackerMixin { @Inject(method = {"handleMonitorEvent", ""}, at = @At("TAIL")) private void handleConfigAdditions(CallbackInfo ci) { - this.refreshMonitors(); + this.wayFix$refreshMonitors(); } @Unique - private void refreshMonitors() { + private void wayFix$refreshMonitors() { ArrayList monitors = new ArrayList<>(); this.pointerToMonitorMap.forEach((aLong, monitor1) -> monitors.add(monitor1)); diff --git a/src/main/java/net/notcoded/wayfix/mixin/TextFieldWidgetMixin.java b/src/main/java/net/notcoded/wayfix/mixin/TextFieldWidgetMixin.java index cb3f018..5120e19 100644 --- a/src/main/java/net/notcoded/wayfix/mixin/TextFieldWidgetMixin.java +++ b/src/main/java/net/notcoded/wayfix/mixin/TextFieldWidgetMixin.java @@ -18,11 +18,11 @@ public class TextFieldWidgetMixin { @Inject(method = "charTyped", at = @At("HEAD"), cancellable = true) private void charTyped(char chr, int modifiers, CallbackInfoReturnable cir) { - if (WayFix.config.keyModifiersFix && WayFix.isWayland() && isSpecialChar(chr) && Screen.hasControlDown()) cir.setReturnValue(false); + if (WayFix.config.keyModifiersFix && WayFix.isWayland() && wayFix$isSpecialChar(chr) && Screen.hasControlDown()) cir.setReturnValue(false); } @Unique - private boolean isSpecialChar(char chr) { + private boolean wayFix$isSpecialChar(char chr) { return chr == 'a' // CTRL + A (select all) || chr == 'v' // CTRL + V (paste) || chr == 'c' // CTRL + C (copy) diff --git a/src/main/java/net/notcoded/wayfix/mixin/WindowMixin.java b/src/main/java/net/notcoded/wayfix/mixin/WindowMixin.java index f799f7f..2c5235a 100644 --- a/src/main/java/net/notcoded/wayfix/mixin/WindowMixin.java +++ b/src/main/java/net/notcoded/wayfix/mixin/WindowMixin.java @@ -1,7 +1,5 @@ package net.notcoded.wayfix.mixin; -import net.minecraft.client.WindowEventHandler; -import net.minecraft.client.WindowSettings; import net.minecraft.client.util.Monitor; import net.minecraft.client.util.MonitorTracker; import net.minecraft.client.util.Window; @@ -41,7 +39,7 @@ @Mixin(Window.class) public class WindowMixin { @Inject(method = "", at = @At(value = "INVOKE", target = "Lorg/lwjgl/glfw/GLFW;glfwDefaultWindowHints()V", shift = At.Shift.AFTER, remap = false)) - private void onWindowHints(WindowEventHandler windowEventHandler, MonitorTracker monitorTracker, WindowSettings windowSettings, String string, String string2, CallbackInfo ci) { + private void onWindowHints(CallbackInfo ci) { if (isWayland()) { GLFW.glfwWindowHint(GLFW.GLFW_FOCUS_ON_SHOW, GLFW.GLFW_FALSE); @@ -53,11 +51,11 @@ private void onWindowHints(WindowEventHandler windowEventHandler, MonitorTracker @Redirect(method = "updateWindowRegion", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/MonitorTracker;getMonitor(Lnet/minecraft/client/util/Window;)Lnet/minecraft/client/util/Monitor;")) private Monitor fixWrongMonitor(MonitorTracker instance, Window window) { - return WayFix.config.fullscreen.useMonitorName ? getMonitor(instance) : instance.getMonitor(window); + return WayFix.config.fullscreen.useMonitorName ? wayFix$getMonitor(instance) : instance.getMonitor(window); } @Unique - private Monitor getMonitor(MonitorTracker instance) { + private Monitor wayFix$getMonitor(MonitorTracker instance) { String monitorName = WayFix.config.fullscreen.monitorName; long monitorID = monitorName.trim().isEmpty() ? GLFW.glfwGetPrimaryMonitor() : ModConfig.Monitors.getMonitor(monitorName); diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index fe4a2c8..c38b26c 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -9,7 +9,7 @@ version = "${version}" displayName = "WayFix" authors = "NotCoded" description = "Fixes multiple issues regarding Wayland compatibility for Minecraft." -logoFile = "assets/wayfix/icon.png" +logoFile = "icon.png" logoBlur = false [["dependencies.wayfix"]] diff --git a/src/main/resources/META-INF/neoforge.mods.toml b/src/main/resources/META-INF/neoforge.mods.toml index fe4a2c8..c38b26c 100644 --- a/src/main/resources/META-INF/neoforge.mods.toml +++ b/src/main/resources/META-INF/neoforge.mods.toml @@ -9,7 +9,7 @@ version = "${version}" displayName = "WayFix" authors = "NotCoded" description = "Fixes multiple issues regarding Wayland compatibility for Minecraft." -logoFile = "assets/wayfix/icon.png" +logoFile = "icon.png" logoBlur = false [["dependencies.wayfix"]] diff --git a/src/main/resources/icon.png b/src/main/resources/icon.png new file mode 100644 index 0000000..83f7a39 Binary files /dev/null and b/src/main/resources/icon.png differ