Skip to content

Commit

Permalink
支持1.20.6
Browse files Browse the repository at this point in the history
  • Loading branch information
reserveword committed May 26, 2024
1 parent 57b547d commit 5b2a1a9
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 45 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ private static void checkTick() {
state.remove(IMState.TICK);
} else if (state.contains(IMState.TICK)) {
state.add(IMState.TICK_CHALLENGE);
scheduleTickCheck();
}
}

Expand Down
6 changes: 3 additions & 3 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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 {
Expand Down
4 changes: 1 addition & 3 deletions forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -28,8 +28,6 @@ runs {
dependencies {
implementation "net.neoforged:neoforge:${neo_version}"

runtimeOnly "mezz.jei:jei-${minecraft_version}-neoforge:${jei_version}"

implementation project(':common')
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -64,22 +70,23 @@ public String getClassName(Class<?> cls) {
}
URL loc = source.getLocation();
AtomicReference<String> 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();
Expand Down
26 changes: 15 additions & 11 deletions forge/src/main/java/io/github/reserveword/imblocker/IMBlocker.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
File renamed without changes.
24 changes: 12 additions & 12 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -20,29 +20,29 @@ author=reserveword
email=[email protected]

# 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
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 5b2a1a9

Please sign in to comment.