diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index c701f65..5f331d4 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -23,7 +23,7 @@ jobs: uses: actions/setup-java@v4 with: distribution: adopt - java-version: 17 + java-version: 21 - name: Build (Forge) run: ./gradlew build diff --git a/build-fabric.gradle b/build-fabric.gradle index a6c14bb..34bf505 100644 --- a/build-fabric.gradle +++ b/build-fabric.gradle @@ -2,13 +2,13 @@ plugins { id 'fabric-loom' version '1.6-SNAPSHOT' } -def minecraftVersion = "1.20.4" // Used for output JAR filenames. +def minecraftVersion = "1.20.6" // Used for output JAR filenames. version = project.mod_version group = "yalter.mousetweaks" archivesBaseName = "MouseTweaks-fabric-mc${minecraftVersion}" -java.toolchain.languageVersion = JavaLanguageVersion.of(17) +java.toolchain.languageVersion = JavaLanguageVersion.of(21) repositories { maven { @@ -36,10 +36,10 @@ loom { dependencies { minecraft "com.mojang:minecraft:${minecraftVersion}" mappings loom.officialMojangMappings() - modImplementation "net.fabricmc:fabric-loader:0.15.9" - modImplementation "net.fabricmc.fabric-api:fabric-api:0.96.11+1.20.4" + modImplementation "net.fabricmc:fabric-loader:0.15.10" + modImplementation "net.fabricmc.fabric-api:fabric-api:0.97.8+1.20.6" - modImplementation 'com.terraformersmc:modmenu:9.0.0' + modImplementation 'com.terraformersmc:modmenu:10.0.0-beta.1' } processResources { diff --git a/build-neoforge.gradle b/build-neoforge.gradle index c221400..f08d636 100644 --- a/build-neoforge.gradle +++ b/build-neoforge.gradle @@ -3,10 +3,10 @@ plugins { id 'eclipse' id 'idea' id 'maven-publish' - id 'net.neoforged.gradle.userdev' version '7.0.80' + id 'net.neoforged.gradle.userdev' version '7.0.109' } -def minecraftVersion = "1.20.4" // Used for output JAR filenames. +def minecraftVersion = "1.20.6" // Used for output JAR filenames. version = project.mod_version group = "yalter.mousetweaks" @@ -15,7 +15,7 @@ base { archivesName = "MouseTweaks-neoforge-mc${minecraftVersion}" } -java.toolchain.languageVersion = JavaLanguageVersion.of(17) +java.toolchain.languageVersion = JavaLanguageVersion.of(21) sourceSets { main { @@ -27,25 +27,14 @@ sourceSets { resources { exclude 'fabric.mod.json' - exclude 'META-INF/mods-neo.toml' + exclude 'META-INF/mods.toml' } } } -tasks.register("fixModsToml", Copy) { - // Copy the mods-neo.toml file to mods.toml - from "src/main/resources/META-INF" - include "mods-neo.toml" - rename "mods-neo.toml", "mods.toml" - into "src/main/resources/META-INF" -} - -// Make the fixModsToml task run before the processResources task -processResources.dependsOn(fixModsToml) - processResources { inputs.property "version", project.mod_version - filesMatching("META-INF/mods.toml") { + filesMatching("META-INF/neoforge.mods.toml") { expand "version": project.mod_version } } @@ -69,7 +58,7 @@ runs { } dependencies { - implementation "net.neoforged:neoforge:20.4.190" + implementation "net.neoforged:neoforge:20.6.11-beta" } task srcJar(type: Jar) { diff --git a/build.gradle b/build.gradle index e04db82..37dce89 100644 --- a/build.gradle +++ b/build.gradle @@ -11,13 +11,13 @@ buildscript { apply plugin: 'net.minecraftforge.gradle' apply plugin: 'org.spongepowered.mixin' -def minecraftVersion = "1.20.2" // Used for output JAR filenames. +def minecraftVersion = "1.20.6" // Used for output JAR filenames. version = project.mod_version group = "yalter.mousetweaks" base.archivesName = "MouseTweaks-forge-mc${minecraftVersion}" -java.toolchain.languageVersion = JavaLanguageVersion.of(17) +java.toolchain.languageVersion = JavaLanguageVersion.of(21) sourceSets { main { @@ -29,7 +29,7 @@ sourceSets { resources { exclude 'fabric.mod.json' - exclude 'META-INF/mods-neo.toml' + exclude 'META-INF/neoforge.mods.toml' } } } @@ -40,7 +40,7 @@ mixin { } minecraft { - mappings channel: 'official', version: '1.20.2' + mappings channel: 'official', version: '1.20.6' runs { client { @@ -71,17 +71,6 @@ minecraft { } } -tasks.register("fixModsToml", Copy) { - // Copy the mods-forge.toml file to mods.toml - from "src/main/resources/META-INF" - include "mods-forge.toml" - rename "mods-forge.toml", "mods.toml" - into "src/main/resources/META-INF" -} - -// Make the fixModsToml task run before the processResources task -processResources.dependsOn(fixModsToml) - processResources { inputs.property "version", project.mod_version filesMatching("META-INF/mods.toml") { @@ -90,7 +79,7 @@ processResources { } dependencies { - minecraft 'net.minecraftforge:forge:1.20.2-48.0.13' + minecraft 'net.minecraftforge:forge:1.20.6-50.0.0' annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' } diff --git a/src/main/java/yalter/mousetweaks/ConfigScreen.java b/src/main/java/yalter/mousetweaks/ConfigScreen.java index 5187b75..8994a7f 100644 --- a/src/main/java/yalter/mousetweaks/ConfigScreen.java +++ b/src/main/java/yalter/mousetweaks/ConfigScreen.java @@ -83,7 +83,7 @@ public void onClose() { @Override public void render(GuiGraphics guiGraphics, int i, int j, float f) { - this.renderDirtBackground(guiGraphics); + this.renderBackground(guiGraphics, i, j, f); guiGraphics.drawCenteredString(this.font, this.title, this.width / 2, 15, 0xFFFFFF); super.render(guiGraphics, i, j, f); } diff --git a/src/main/java/yalter/mousetweaks/Main.java b/src/main/java/yalter/mousetweaks/Main.java index 4740f4c..bf5646d 100644 --- a/src/main/java/yalter/mousetweaks/Main.java +++ b/src/main/java/yalter/mousetweaks/Main.java @@ -15,7 +15,6 @@ import yalter.mousetweaks.handlers.IMTModGuiContainer3ExHandler; import java.io.File; -import java.lang.reflect.Field; import java.util.ArrayList; import java.util.List; @@ -555,7 +554,7 @@ private static IGuiScreenHandler findHandler(Screen currentScreen) { // Returns true if we can put items from one stack into another. // This is different from ItemStack.areItemsEqual() because here empty stacks are compatible with anything. private static boolean areStacksCompatible(ItemStack a, ItemStack b) { - return a.isEmpty() || b.isEmpty() || (ItemStack.isSameItem(a, b) && ItemStack.isSameItemSameTags(a, b)); + return a.isEmpty() || b.isEmpty() || (ItemStack.isSameItem(a, b) && ItemStack.isSameItemSameComponents(a, b)); } /** diff --git a/src/main/java/yalter/mousetweaks/fabric/mixin/MixinMouseHandler.java b/src/main/java/yalter/mousetweaks/fabric/mixin/MixinMouseHandler.java index 310dff1..e2f94fc 100644 --- a/src/main/java/yalter/mousetweaks/fabric/mixin/MixinMouseHandler.java +++ b/src/main/java/yalter/mousetweaks/fabric/mixin/MixinMouseHandler.java @@ -18,7 +18,7 @@ public abstract class MixinMouseHandler { @SuppressWarnings("target") @Dynamic("Lambda that calls screen.mouseDragged()") - @Inject(method = "method_1602(Lnet/minecraft/client/gui/screens/Screen;DDDD)V", at = @At("HEAD"), cancellable = true) + @Inject(method = "method_55795(Lnet/minecraft/client/gui/screens/Screen;DDDD)V", at = @At("HEAD"), cancellable = true) private void onMouseDragged(Screen screen, double x, double y, double dx, double dy, CallbackInfo ci) { MouseButton button = MouseButton.fromEventButton(this.activeButton); if (button != null) { diff --git a/src/main/java/yalter/mousetweaks/neoforge/ClientHelper.java b/src/main/java/yalter/mousetweaks/neoforge/ClientHelper.java index 7229adb..40eed6f 100644 --- a/src/main/java/yalter/mousetweaks/neoforge/ClientHelper.java +++ b/src/main/java/yalter/mousetweaks/neoforge/ClientHelper.java @@ -1,14 +1,17 @@ package yalter.mousetweaks.neoforge; -import net.neoforged.neoforge.client.ConfigScreenHandler; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.screens.Screen; +import net.neoforged.neoforge.client.gui.IConfigScreenFactory; import yalter.mousetweaks.ConfigScreen; /** * Functions accessing client-only classes, extracted so that they can be called from MouseTweaksNeo * without causing class-loading errors on the server. */ -public class ClientHelper { - public static ConfigScreenHandler.ConfigScreenFactory createConfigScreenFactory() { - return new ConfigScreenHandler.ConfigScreenFactory((minecraft, screen) -> new ConfigScreen(screen)); +public class ClientHelper implements IConfigScreenFactory { + @Override + public Screen createScreen(Minecraft minecraft, Screen screen) { + return new ConfigScreen(screen); } } diff --git a/src/main/java/yalter/mousetweaks/neoforge/MouseTweaksNeo.java b/src/main/java/yalter/mousetweaks/neoforge/MouseTweaksNeo.java index 0c04180..1696ce8 100644 --- a/src/main/java/yalter/mousetweaks/neoforge/MouseTweaksNeo.java +++ b/src/main/java/yalter/mousetweaks/neoforge/MouseTweaksNeo.java @@ -1,13 +1,12 @@ package yalter.mousetweaks.neoforge; -import net.neoforged.neoforge.client.ConfigScreenHandler; import net.neoforged.neoforge.client.event.ScreenEvent.MouseButtonPressed; import net.neoforged.neoforge.client.event.ScreenEvent.MouseButtonReleased; import net.neoforged.neoforge.client.event.ScreenEvent.MouseDragged; import net.neoforged.neoforge.client.event.ScreenEvent.MouseScrolled; +import net.neoforged.neoforge.client.gui.IConfigScreenFactory; import net.neoforged.neoforge.common.NeoForge; import net.neoforged.bus.api.SubscribeEvent; -import net.neoforged.fml.IExtensionPoint; import net.neoforged.fml.ModLoadingContext; import net.neoforged.fml.loading.FMLEnvironment; import net.neoforged.fml.common.Mod; @@ -19,7 +18,6 @@ @Mod(Constants.MOD_ID) public class MouseTweaksNeo { public MouseTweaksNeo() { - ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class, () -> new IExtensionPoint.DisplayTest(() -> "ANY", (remote, isServer) -> true)); if (FMLEnvironment.dist != net.neoforged.api.distmarker.Dist.CLIENT) { Logger.Log("Disabled because not running on the client."); return; @@ -28,7 +26,7 @@ public MouseTweaksNeo() { Main.initialize(); NeoForge.EVENT_BUS.register(this); - ModLoadingContext.get().registerExtensionPoint(ConfigScreenHandler.ConfigScreenFactory.class, ClientHelper::createConfigScreenFactory); + ModLoadingContext.get().registerExtensionPoint(IConfigScreenFactory.class, ClientHelper::new); } @SubscribeEvent diff --git a/src/main/resources/META-INF/mods-forge.toml b/src/main/resources/META-INF/mods-forge.toml deleted file mode 100644 index 6721945..0000000 --- a/src/main/resources/META-INF/mods-forge.toml +++ /dev/null @@ -1,16 +0,0 @@ -modLoader="javafml" -loaderVersion="[48,)" -license="BSD-3-Clause" -issueTrackerURL="https://github.com/YaLTeR/MouseTweaks/issues" - -[[mods]] -modId="mousetweaks" -version="${version}" -displayName="Mouse Tweaks" -displayURL="https://minecraft.curseforge.com/projects/mouse-tweaks" -logoFile="mousetweaks_logo.png" -credits="Contributors: mezz, juliand665, panoskj, FabiClawZ, ErrorMikey." -authors="Ivan Molodetskikh (YaLTeR)" -description=''' -A mod that enhances the inventory management by adding various additional functions to the usual mouse buttons. -''' diff --git a/src/main/resources/META-INF/mods-neo.toml b/src/main/resources/META-INF/neoforge.mods.toml similarity index 100% rename from src/main/resources/META-INF/mods-neo.toml rename to src/main/resources/META-INF/neoforge.mods.toml diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index d3dcffc..ade9b59 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -35,10 +35,10 @@ "mousetweaks-fabric.mixins.json" ], "depends": { - "fabricloader": ">=0.15.9", + "fabricloader": ">=0.15.10", "fabric-api": "*", - "minecraft": "~1.20.4", - "java": ">=17" + "minecraft": "~1.20.6", + "java": ">=21" }, "suggests": {} } diff --git a/src/main/resources/mousetweaks-fabric.mixins.json b/src/main/resources/mousetweaks-fabric.mixins.json index 2dc88bc..4ce0e42 100644 --- a/src/main/resources/mousetweaks-fabric.mixins.json +++ b/src/main/resources/mousetweaks-fabric.mixins.json @@ -2,7 +2,7 @@ "required": true, "minVersion": "0.8", "package": "yalter.mousetweaks.fabric.mixin", - "compatibilityLevel": "JAVA_17", + "compatibilityLevel": "JAVA_21", "mixins": [], "client": [ "MixinMouseHandler" diff --git a/src/main/resources/mousetweaks.mixins.json b/src/main/resources/mousetweaks.mixins.json index 0cf12e8..1206a83 100644 --- a/src/main/resources/mousetweaks.mixins.json +++ b/src/main/resources/mousetweaks.mixins.json @@ -2,7 +2,7 @@ "required": true, "minVersion": "0.8", "package": "yalter.mousetweaks.mixin", - "compatibilityLevel": "JAVA_17", + "compatibilityLevel": "JAVA_21", "mixins": [], "client": [ "AbstractContainerScreenAccessor" diff --git a/src/main/resources/pack.mcmeta b/src/main/resources/pack.mcmeta index 804c8b2..516b49a 100644 --- a/src/main/resources/pack.mcmeta +++ b/src/main/resources/pack.mcmeta @@ -1,6 +1,6 @@ { "pack": { "description": "Mouse Tweaks Resources", - "pack_format": 15 + "pack_format": 32 } }