Merge pull request #55 from 12emin34/neo-1.20.6

fix NeoForge for 1.20.5/6
This commit is contained in:
Martin Prokoph
2024-06-08 20:17:22 +02:00
committed by GitHub
8 changed files with 50 additions and 48 deletions

View File

@@ -2,6 +2,7 @@ plugins {
id "architectury-plugin" version "3.4-SNAPSHOT" id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "1.6-SNAPSHOT" apply false id "dev.architectury.loom" version "1.6-SNAPSHOT" apply false
id "me.shedaniel.unified-publishing" version "0.1.+" apply false id "me.shedaniel.unified-publishing" version "0.1.+" apply false
id 'com.github.johnrengelman.shadow' version '8.1.1' apply false
} }
architectury { architectury {
@@ -14,7 +15,10 @@ subprojects {
dependencies { dependencies {
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}" minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
// The following line declares the yarn mappings you may select this one as well. // The following line declares the yarn mappings you may select this one as well.
mappings "net.fabricmc:yarn:${rootProject.yarn_mappings}:v2" mappings loom.layered {
it.mappings("net.fabricmc:yarn:$rootProject.yarn_mappings:v2")
it.mappings("dev.architectury:yarn-mappings-patch-neoforge:$rootProject.yarn_mappings_patch_neoforge_version")
}
} }
} }

View File

@@ -1,5 +1,5 @@
plugins { plugins {
id "com.github.johnrengelman.shadow" version "7.1.2" id 'com.github.johnrengelman.shadow'
id "me.shedaniel.unified-publishing" id "me.shedaniel.unified-publishing"
} }
repositories { repositories {

View File

@@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4096M
minecraft_version=1.20.6 minecraft_version=1.20.6
yarn_mappings=1.20.6+build.1 yarn_mappings=1.20.6+build.1
enabled_platforms=fabric enabled_platforms=fabric,neoforge
archives_base_name=midnightlib archives_base_name=midnightlib
mod_version=1.5.5 mod_version=1.5.5
@@ -14,7 +14,8 @@ modrinth_id=codAaoxh
fabric_loader_version=0.15.11 fabric_loader_version=0.15.11
fabric_api_version=0.97.8+1.20.6 fabric_api_version=0.97.8+1.20.6
neoforge_version=20.6.30-beta neoforge_version=20.6.63-beta
yarn_mappings_patch_neoforge_version = 1.20.5+build.3
quilt_loader_version=0.19.0-beta.18 quilt_loader_version=0.19.0-beta.18
quilt_fabric_api_version=7.0.1+0.83.0-1.20 quilt_fabric_api_version=7.0.1+0.83.0-1.20

View File

@@ -1,9 +1,14 @@
plugins { plugins {
id "com.github.johnrengelman.shadow" version "7.1.2" id 'com.github.johnrengelman.shadow'
} }
repositories { repositories {
maven {url "https://maven.neoforged.net/releases"} maven {
name = 'NeoForged'
url = 'https://maven.neoforged.net/releases'
} }
}
architectury { architectury {
platformSetupLoomIde() platformSetupLoomIde()
@@ -15,41 +20,44 @@ loom {
} }
configurations { configurations {
common common {
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this. canBeResolved = true
canBeConsumed = false
}
compileClasspath.extendsFrom common compileClasspath.extendsFrom common
runtimeClasspath.extendsFrom common runtimeClasspath.extendsFrom common
developmentForge.extendsFrom common developmentNeoForge.extendsFrom common
archivesBaseName = rootProject.archives_base_name + "-neoforge"
// Files in this configuration will be bundled into your mod using the Shadow plugin.
// Don't use the `shadow` configuration from the plugin itself as it's meant for excluding files.
shadowBundle {
canBeResolved = true
canBeConsumed = false
}
} }
dependencies { dependencies {
neoForge "net.neoforged:neoforge:${rootProject.neoforge_version}" neoForge "net.neoforged:neoforge:$rootProject.neoforge_version"
common(project(path: ":common", configuration: "namedElements")) { transitive false } common(project(path: ':common', configuration: 'namedElements')) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProductionNeoForge")) { transitive = false } shadowBundle project(path: ':common', configuration: 'transformProductionNeoForge')
} }
processResources { processResources {
inputs.property "version", project.version inputs.property 'version', project.version
filesMatching("META-INF/mods.toml") { filesMatching('META-INF/neoforge.mods.toml') {
expand "version": project.version expand version: project.version
} }
} }
shadowJar { shadowJar {
exclude "fabric.mod.json" configurations = [project.configurations.shadowBundle]
exclude "architectury.common.json" archiveClassifier = 'dev-shadow'
configurations = [project.configurations.shadowCommon]
archiveClassifier = "dev-shadow"
} }
remapJar { remapJar {
atAccessWideners.add('midnightlib.accesswidener')
input.set shadowJar.archiveFile input.set shadowJar.archiveFile
dependsOn shadowJar
} }
sourcesJar { sourcesJar {

View File

@@ -2,44 +2,39 @@ package eu.midnightdust.neoforge;
import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import eu.midnightdust.core.MidnightLib; import eu.midnightdust.core.MidnightLib;
import eu.midnightdust.core.screen.MidnightConfigOverviewScreen;
import eu.midnightdust.lib.config.AutoCommand; import eu.midnightdust.lib.config.AutoCommand;
import eu.midnightdust.lib.config.MidnightConfig; import eu.midnightdust.lib.config.MidnightConfig;
import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.command.ServerCommandSource;
import net.neoforged.api.distmarker.Dist; import net.neoforged.api.distmarker.Dist;
import net.neoforged.bus.api.SubscribeEvent; import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.IExtensionPoint;
import net.neoforged.fml.ModList; import net.neoforged.fml.ModList;
import net.neoforged.fml.ModLoadingContext; import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.fml.common.Mod; import net.neoforged.fml.common.Mod;
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent; import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
import net.neoforged.fml.loading.FMLEnvironment; import net.neoforged.fml.loading.FMLEnvironment;
import net.neoforged.neoforge.client.ConfigScreenHandler; import net.neoforged.neoforge.client.gui.IConfigScreenFactory;
import net.neoforged.neoforge.client.event.ScreenEvent;
import net.neoforged.neoforge.event.RegisterCommandsEvent; import net.neoforged.neoforge.event.RegisterCommandsEvent;
import static net.neoforged.fml.IExtensionPoint.DisplayTest.IGNORESERVERONLY;
@Mod("midnightlib") @Mod("midnightlib")
public class MidnightLibNeoForge { public class MidnightLibNeoForge {
public MidnightLibNeoForge() { public MidnightLibNeoForge() {
ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class, () -> new IExtensionPoint.DisplayTest(() -> IGNORESERVERONLY, (remote, server) -> true)); if (FMLEnvironment.dist == Dist.CLIENT) MidnightLib.onInitializeClient();
if (FMLEnvironment.dist == Dist.CLIENT) MidnightLib.onInitializeClient(); else MidnightLib.onInitializeServer(); else MidnightLib.onInitializeServer();
} }
@Mod.EventBusSubscriber(modid = "midnightlib", bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
@EventBusSubscriber(modid = "midnightlib", bus = EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
public static class MidnightLibBusEvents { public static class MidnightLibBusEvents {
@SubscribeEvent @SubscribeEvent
public static void onPostInit(FMLClientSetupEvent event) { public static void onPostInit(FMLClientSetupEvent event) {
ModList.get().forEachModContainer((modid, modContainer) -> { ModList.get().forEachModContainer((modid, modContainer) -> {
if (MidnightConfig.configClass.containsKey(modid)) { if (MidnightConfig.configClass.containsKey(modid)) {
modContainer.registerExtensionPoint(ConfigScreenHandler.ConfigScreenFactory.class, () -> modContainer.registerExtensionPoint(IConfigScreenFactory.class, (minecraftClient, screen) -> MidnightConfig.getScreen(screen, modid));
new ConfigScreenHandler.ConfigScreenFactory((client, parent) -> MidnightConfig.getScreen(parent, modid)));
} }
}); });
} }
} }
@Mod.EventBusSubscriber(modid = "midnightlib", value = Dist.DEDICATED_SERVER) @EventBusSubscriber(modid = "midnightlib", value = Dist.DEDICATED_SERVER)
public static class MidnightLibServerEvents { public static class MidnightLibServerEvents {
@SubscribeEvent @SubscribeEvent
public static void registerCommands(RegisterCommandsEvent event) { public static void registerCommands(RegisterCommandsEvent event) {

View File

@@ -1,5 +1,5 @@
modLoader = "javafml" modLoader = "javafml"
loaderVersion = "[1,)" loaderVersion = "[2,)"
#issueTrackerURL = "" #issueTrackerURL = ""
license = "MIT License" license = "MIT License"
@@ -17,13 +17,13 @@ Common Library for Team MidnightDust's mods.
[[dependencies.midnightlib]] [[dependencies.midnightlib]]
modId = "neoforge" modId = "neoforge"
mandatory = true mandatory = true
versionRange = "[20.3,)" versionRange = "[20.5,)"
ordering = "NONE" ordering = "NONE"
side = "BOTH" side = "BOTH"
[[dependencies.midnightlib]] [[dependencies.midnightlib]]
modId = "minecraft" modId = "minecraft"
mandatory = true mandatory = true
versionRange = "[1.20.3,)" versionRange = "[1.20.5,)"
ordering = "NONE" ordering = "NONE"
side = "BOTH" side = "BOTH"

View File

@@ -1,6 +0,0 @@
{
"pack": {
"description": "MidnightLib",
"pack_format": 22
}
}

View File

@@ -11,6 +11,6 @@ include("common")
include("fabric-like") include("fabric-like")
include("fabric") include("fabric")
//include("quilt") //include("quilt")
//include("neoforge") include("neoforge")
rootProject.name = "midnightlib" rootProject.name = "midnightlib"