diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index a12fdfd..4e7e32f 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -12,11 +12,11 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v2 with: distribution: 'temurin' - java-version: 17 + java-version: 21 - name: Build with Gradle run: ./gradlew :jar - name: Upload artifact diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml index bb01227..6ad0033 100644 --- a/.github/workflows/tag.yml +++ b/.github/workflows/tag.yml @@ -6,7 +6,7 @@ on: - '*' env: - JAVA_VERSION: 17 + JAVA_VERSION: 21 MODRINTH_TOKEN: ${{ secrets.PUBLISH_MODRINTH_TOKEN }} CURSEFORGE_TOKEN: ${{ secrets.PUBLISH_CURSEFORGE_TOKEN }} GITHUB_TOKEN: ${{ secrets.PUBLISH_GITHUB_TOKEN }} diff --git a/build.gradle b/build.gradle index 8a19baa..ffd5ed8 100644 --- a/build.gradle +++ b/build.gradle @@ -74,13 +74,14 @@ allprojects { tasks.withType(ProcessResources).configureEach { inputs.properties all_properties - filesMatching(['META-INF/mods.toml', 'fabric.mod.json', 'pack.mcmeta']) { + filesMatching(['META-INF/neoforge.mods.toml', 'fabric.mod.json', 'pack.mcmeta']) { expand all_properties } } tasks.withType(JavaCompile).configureEach { options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation + options.release = 21 } tasks.register('feedbackClass', Copy) { diff --git a/common/src/main/java/io/github/reserveword/imblocker/IMCheckState.java b/common/src/main/java/io/github/reserveword/imblocker/IMCheckState.java index a6112c2..8bbdd41 100644 --- a/common/src/main/java/io/github/reserveword/imblocker/IMCheckState.java +++ b/common/src/main/java/io/github/reserveword/imblocker/IMCheckState.java @@ -100,6 +100,7 @@ private static void checkTick() { state.remove(IMState.TICK); } else if (state.contains(IMState.TICK)) { state.add(IMState.TICK_CHALLENGE); + scheduleTickCheck(); } } diff --git a/fabric/build.gradle b/fabric/build.gradle index 3363916..ac88516 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -34,7 +34,7 @@ dependencies { // run time test modRuntimeOnly "dev.emi:emi-fabric:$emi_version" - modRuntimeOnly "maven.modrinth:replaymod:$replaymod_version" + // modRuntimeOnly "maven.modrinth:replaymod:$replaymod_version" modRuntimeOnly "maven.modrinth:voxelmap-updated:$voxelmap_version" modRuntimeOnly "me.shedaniel:RoughlyEnoughItems-fabric:$rei_version" @@ -47,8 +47,8 @@ java { // If you remove this line, sources will not be generated. withSourcesJar() - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 } project.jar { diff --git a/forge/build.gradle b/forge/build.gradle index 7aead22..56d97b5 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -5,7 +5,7 @@ plugins { } // Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17. -java.toolchain.languageVersion = JavaLanguageVersion.of(17) +java.toolchain.languageVersion = JavaLanguageVersion.of(21) sourceSets { main @@ -28,8 +28,6 @@ runs { dependencies { implementation "net.neoforged:neoforge:${neo_version}" - runtimeOnly "mezz.jei:jei-${minecraft_version}-neoforge:${jei_version}" - implementation project(':common') } diff --git a/forge/src/main/java/io/github/reserveword/imblocker/ForgeConfig.java b/forge/src/main/java/io/github/reserveword/imblocker/ForgeConfig.java index 24f20ab..6ffffc4 100644 --- a/forge/src/main/java/io/github/reserveword/imblocker/ForgeConfig.java +++ b/forge/src/main/java/io/github/reserveword/imblocker/ForgeConfig.java @@ -7,10 +7,16 @@ import net.neoforged.neoforge.common.ModConfigSpec; import org.apache.commons.lang3.tuple.Pair; +import java.net.MalformedURLException; import java.net.URL; import java.security.CodeSource; -import java.security.ProtectionDomain; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Objects; +import java.util.Set; import java.util.concurrent.atomic.AtomicReference; public class ForgeConfig extends Config { @@ -64,22 +70,23 @@ public String getClassName(Class cls) { } URL loc = source.getLocation(); AtomicReference name = new AtomicReference<>("UNKNOWN_SCREEN"); - ModList.get().forEachModContainer((modid, mod) -> { + ModList.get().forEachModFile(mod -> { try { - if (!"minecraft".equals(modid) && !"imblocker".equals(modid) && loc == mod.getMod().getClass() - .getProtectionDomain().getCodeSource().getLocation()) { + String modid = mod.getModInfos().get(0).getModId(); + if (!"minecraft".equals(modid) && !"imblocker".equals(modid) && Objects.equals(loc, + mod.getFilePath().toUri().toURL())) { name.set(modid + ":" + cls.getName()); } } catch (NullPointerException npe) { + String modid = mod.getModInfos().get(0).getModId(); Common.LOGGER.error("something is null when grabbing mod jar:"); - Object modobj = mod.getMod(); - Class modcls = modobj != null ? modobj.getClass() : null; - ProtectionDomain pd = modcls != null ? modcls.getProtectionDomain() : null; - CodeSource cs = pd != null ? pd.getCodeSource() : null; - Common.LOGGER.warn("modid {}, mod {}, class {}, domain {}, source {}", - modid, modobj, modcls, pd, cs); + Common.LOGGER.warn("modid {}, file {}", modid, mod.getFileName()); Common.LOGGER.error("enableScreenRecovering disabled."); CLIENT.enableScreenRecovering.set(false); + } catch (MalformedURLException e) { + throw new RuntimeException(e); + } catch (IndexOutOfBoundsException e) { + // do nothing } }); return name.get(); diff --git a/forge/src/main/java/io/github/reserveword/imblocker/IMBlocker.java b/forge/src/main/java/io/github/reserveword/imblocker/IMBlocker.java index 674449f..f5b2f52 100644 --- a/forge/src/main/java/io/github/reserveword/imblocker/IMBlocker.java +++ b/forge/src/main/java/io/github/reserveword/imblocker/IMBlocker.java @@ -2,31 +2,35 @@ import net.neoforged.api.distmarker.Dist; import net.neoforged.bus.api.SubscribeEvent; -import net.neoforged.fml.ModLoadingContext; +import net.neoforged.fml.ModContainer; +import net.neoforged.fml.common.EventBusSubscriber; import net.neoforged.fml.common.Mod; import net.neoforged.fml.config.ModConfig; import net.neoforged.fml.event.config.ModConfigEvent; -import net.neoforged.neoforge.event.TickEvent; +import net.neoforged.neoforge.client.event.ClientTickEvent; +import net.neoforged.neoforge.client.event.ScreenEvent; -// The value here should match an entry in the META-INF/mods.toml file +// The value here should match an entry in the META-INF/neoforge.mods.toml file @Mod(Common.MODID) public class IMBlocker { - public IMBlocker() { + public IMBlocker(ModContainer container) { // Register ourselves for server and other game events we are interested in - ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, ForgeConfig.clientSpec); + container.registerConfig(ModConfig.Type.CLIENT, ForgeConfig.clientSpec); } - @Mod.EventBusSubscriber(Dist.CLIENT) + @EventBusSubscriber(Dist.CLIENT) public static class ForgeEvents { @SubscribeEvent - public static void onClientTick(TickEvent.ClientTickEvent cte) { - if (cte.phase == TickEvent.Phase.START) { - IMCheckState.clientTick(new ForgeScreenInfo()); - } + public static void onClientTick(ClientTickEvent.Pre cte) { + IMCheckState.clientTick(new ForgeScreenInfo()); + } + @SubscribeEvent + public static void onMouseButtonReleased(ScreenEvent.MouseButtonReleased.Post mbr) { + IMCheckState.scheduleTickCheck(); } } - @Mod.EventBusSubscriber(value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD) + @EventBusSubscriber(value = Dist.CLIENT, bus = EventBusSubscriber.Bus.MOD) public static class ModEvents { @SubscribeEvent public static void onConfigLoadReload(ModConfigEvent e) { diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/neoforge.mods.toml similarity index 100% rename from forge/src/main/resources/META-INF/mods.toml rename to forge/src/main/resources/META-INF/neoforge.mods.toml diff --git a/gradle.properties b/gradle.properties index 296a23d..3ad2967 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ org.gradle.daemon=false org.gradle.debug=false # mc -minecraft_version=1.20.4 +minecraft_version=1.20.6 # mod mod_id=imblocker @@ -20,29 +20,29 @@ author=reserveword email=reserveword@outlook.com # fabric -fabric_version=0.96.0+1.20.4 -yarn_mappings=1.20.4+build.3 -loader_version=0.15.6 -loom_version=1.5-SNAPSHOT +fabric_version=0.99.0+1.20.6 +yarn_mappings=1.20.6+build.3 +loader_version=0.15.11 +loom_version=1.6-SNAPSHOT # forge loader_version_range=[2.0,) -neo_version=20.4.80-beta -neogradle_version=7.0.80 +neo_version=20.6.62-beta +neogradle_version=7.0.133 # dependency versions -modmenu_version=9.0.0 -clothconfig_version=13.0.121 +modmenu_version=10.0.0-beta.1 +clothconfig_version=14.0.126 # compat versions jei_version=17.3.0.49 -rei_version=14.0.688 +rei_version=15.0.728 replaymod_version=1.20.4-2.6.14 notebook_version=3.1.0 easyanvils_version=v20.4.2-1.20.4 puzzleslib_version=v20.4.22-1.20.4 forgeconfigapiport_version=v20.4.3-1.20.4 -voxelmap_version=1.20.4-1.12.17 +voxelmap_version=1.20.6-1.12.19 ftblib_version=438495:4643333 ftbquest_version=438496:4652999 cottonlibgui_version=9.2.2+1.20.2 -emi_version=1.1.1+1.20.4 +emi_version=1.1.6+1.20.6 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index c30b486..20db9ad 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists