From 5cdb14f84145d0307cde9ab5ca15d68b49b6f400 Mon Sep 17 00:00:00 2001 From: minglipro Date: Thu, 17 Jul 2025 10:06:13 +0800 Subject: [PATCH] add 1.21 1.21.1 1.21.3 1.21.4 1.21.5 --- build.gradle | 110 +++++++----------- gradle.properties | 6 +- .../EnchantmentDoNotConflictForge.java | 6 +- .../conflict/config/ModConfig.java | 9 +- .../enchantmentdoesnotconflict.mixins.json | 3 +- 5 files changed, 57 insertions(+), 77 deletions(-) diff --git a/build.gradle b/build.gradle index a6628ac..36f9e6a 100644 --- a/build.gradle +++ b/build.gradle @@ -22,51 +22,24 @@ minecraft { reobf = false copyIdeResources = true runs { + configureEach { + workingDirectory project.file('run') + property 'forge.logging.markers', 'REGISTRIES' + property 'forge.logging.console.level', 'debug' + } client { - workingDirectory project.file('run') - property 'forge.logging.markers', 'REGISTRIES' - property 'forge.logging.console.level', 'info' property 'forge.enabledGameTestNamespaces', mod_id - mods { - "${mod_id}" { - source sourceSets.main - } - } } - server { - workingDirectory project.file('run') - property 'forge.logging.markers', 'REGISTRIES' - property 'forge.logging.console.level', 'info' property 'forge.enabledGameTestNamespaces', mod_id - mods { - "${mod_id}" { - source sourceSets.main - } - } + args '--nogui' } - - gameTestServer { - workingDirectory project.file('run') - property 'forge.logging.markers', 'REGISTRIES' - property 'forge.logging.console.level', 'info' property 'forge.enabledGameTestNamespaces', mod_id - mods { - "${mod_id}" { - source sourceSets.main - } - } } data { - workingDirectory project.file('run') - property 'forge.logging.markers', 'REGISTRIES' + workingDirectory project.file('run-data') args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') - mods { - "${mod_id}" { - source sourceSets.main - } - } } } } @@ -75,22 +48,23 @@ repositories { } dependencies { - minecraft ("net.minecraftforge:forge:${minecraft_version}-${forge_version}") + minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" + implementation('net.sf.jopt-simple:jopt-simple:5.0.4') { version { strictly '5.0.4' } } + annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' } -def resourceTargets = ['META-INF/mods.toml', 'pack.mcmeta'] -def replaceProperties = [minecraft_version : minecraft_version, minecraft_version_range: minecraft_version_range, - forge_version : forge_version, forge_version_range: forge_version_range, - loader_version_range: loader_version_range, - mod_id : mod_id, mod_name: mod_name, mod_license: mod_license, - mod_version: mod_version, - mod_authors : mod_authors, mod_description: mod_description] -processResources { - inputs.properties replaceProperties - replaceProperties.put 'project', project - filesMatching(resourceTargets) { - expand replaceProperties +tasks.named('processResources', ProcessResources).configure { + var replaceProperties = [ + minecraft_version : minecraft_version, minecraft_version_range: minecraft_version_range, + forge_version : forge_version, forge_version_range: forge_version_range, + loader_version_range: loader_version_range, + mod_id : mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version, + mod_authors : mod_authors, mod_description: mod_description, + ] + inputs.properties replaceProperties + filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) { + expand replaceProperties + [project: project] } } @@ -99,36 +73,42 @@ mixin { config "${mod_id}.mixins.json" } -java{ +java { withSourcesJar() } -jar { +tasks.named('jar', Jar).configure { manifest { - attributes(["Specification-Title" : mod_id, - "Specification-Vendor" : mod_authors, - "Specification-Version" : "1", - "Implementation-Title" : project.name, - "Implementation-Version" : project.jar.archiveVersion, - "Implementation-Vendor" : mod_authors, - "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")]) + attributes([ + 'Specification-Title' : mod_id, + 'Specification-Vendor' : mod_authors, + 'Specification-Version' : '1', + 'Implementation-Title' : project.name, + 'Implementation-Version': project.jar.archiveVersion, + 'Implementation-Vendor' : mod_authors, + "MixinConfigs" : "${mod_id}.mixins.json" + ]) } } - -jar.finalizedBy('reobfJar') - - publishing { publications { - mavenJava(MavenPublication) { - artifact jar + register('mavenJava', MavenPublication) { + from components.java + groupId = mod_group_id + artifactId = mod_id + } + } + repositories { + maven { + name = "Disk" + url = uri("D:/git/maven-repository-raw") } } - repositories {} } - -idea.module { downloadJavadoc = downloadSources = true } +tasks.withType(JavaCompile).configureEach { + options.encoding = 'UTF-8' +} sourceSets.each { def dir = layout.buildDirectory.dir("sourcesSets/$it.name") diff --git a/gradle.properties b/gradle.properties index c859b60..576e2c4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,10 +1,10 @@ org.gradle.jvmargs=-Xmx4096m -Xms2048m -XX:MaxMetaspaceSize=1024m systemProp.file.encoding=UTF-8 minecraft_version=1.21 -minecraft_version_range=[1.21,1.22) +minecraft_version_range=[1.21,1.21.6) forge_version=51.0.0 -forge_version_range=[51,) -loader_version_range=[51,) +forge_version_range=[50,) +loader_version_range=[50,) mapping_channel=official mapping_version=1.21 mod_id=enchantmentdoesnotconflict diff --git a/src/main/java/com/mingliqiye/minecraft/enchantment/conflict/EnchantmentDoNotConflictForge.java b/src/main/java/com/mingliqiye/minecraft/enchantment/conflict/EnchantmentDoNotConflictForge.java index ea6e6c1..1377617 100644 --- a/src/main/java/com/mingliqiye/minecraft/enchantment/conflict/EnchantmentDoNotConflictForge.java +++ b/src/main/java/com/mingliqiye/minecraft/enchantment/conflict/EnchantmentDoNotConflictForge.java @@ -6,6 +6,7 @@ import com.mojang.logging.LogUtils; import net.minecraft.server.level.ServerPlayer; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.PlayerEvent; +import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; @@ -17,8 +18,9 @@ public class EnchantmentDoNotConflictForge { public static final String MODID = "enchantmentdoesnotconflict"; private static final Logger LOGGER = LogUtils.getLogger(); - public EnchantmentDoNotConflictForge(FMLJavaModLoadingContext context) { - context.getModEventBus().addListener(this::commonSetup); + public EnchantmentDoNotConflictForge() { + IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); + modEventBus.addListener(this::commonSetup); MinecraftForge.EVENT_BUS.addListener(this::onPlayerLogin); } diff --git a/src/main/java/com/mingliqiye/minecraft/enchantment/conflict/config/ModConfig.java b/src/main/java/com/mingliqiye/minecraft/enchantment/conflict/config/ModConfig.java index e089b8c..f5707a8 100644 --- a/src/main/java/com/mingliqiye/minecraft/enchantment/conflict/config/ModConfig.java +++ b/src/main/java/com/mingliqiye/minecraft/enchantment/conflict/config/ModConfig.java @@ -44,18 +44,17 @@ public class ModConfig { ModConfig.instance = instance; } - public static Map> load() { + public static void load() { try { if (Files.exists(CONFIG_PATH)) { - return GSON.fromJson(Files.newBufferedReader(CONFIG_PATH), TYPE); + setInstance(GSON.fromJson(Files.newBufferedReader(CONFIG_PATH), TYPE)); + return; } } catch (IOException e) { LOGGER.error(e.getMessage(),e); } - Map> modConfig = getDefData(); - setInstance(modConfig); + setInstance(getDefData()); save(); - return modConfig; } public static void save() { diff --git a/src/main/resources/enchantmentdoesnotconflict.mixins.json b/src/main/resources/enchantmentdoesnotconflict.mixins.json index 369865c..ec95972 100644 --- a/src/main/resources/enchantmentdoesnotconflict.mixins.json +++ b/src/main/resources/enchantmentdoesnotconflict.mixins.json @@ -1,7 +1,6 @@ { "required": true, "package": "com.mingliqiye.minecraft.enchantment.conflict.mixin", - "refmap": "enchantmentdoesnotconflict.mixins.refmap.json", "compatibilityLevel": "JAVA_17", "mixins": [ "EnchantmentMixin" @@ -9,7 +8,7 @@ "injectors": { "defaultRequire": 1 }, - "minVersion": "0.8", + "minVersion": "0.8.5", "overwrites": { "requireAnnotations": true }