Skip to content

Commit

Permalink
Support NeoForge 1.20.2
Browse files Browse the repository at this point in the history
  • Loading branch information
shedaniel committed Nov 17, 2023
1 parent 0206a64 commit f4ddda2
Show file tree
Hide file tree
Showing 16 changed files with 275 additions and 21 deletions.
8 changes: 6 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "0.12.0-SNAPSHOT" apply false
id "dev.architectury.loom" version "1.4-SNAPSHOT" apply false
id "me.shedaniel.unified-publishing" version "0.1.+" apply false
id "maven-publish"
id "org.cadixdev.licenser" version "0.6.1" apply false
Expand All @@ -16,6 +16,10 @@ subprojects {
loom {
silentMojangMappingsLicense()
}

repositories {
maven { url "https://maven.neoforged.net/releases/" }
}
}

allprojects {
Expand All @@ -36,7 +40,7 @@ allprojects {
// The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too
// JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used.
// We'll use that if it's available, but otherwise we'll use the older option.
options.release = 16
options.release = 17
}

license {
Expand Down
9 changes: 3 additions & 6 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ dependencies {
}

architectury {
common("fabric", "forge")
common("fabric", "forge", "neoforge")
}

task sourcesJar(type: Jar, dependsOn: classes) {
classifier = "sources"
archiveClassifier = "sources"
from sourceSets.main.allSource
}

Expand All @@ -60,10 +60,7 @@ publishing {
publications {
mavenCommon(MavenPublication) {
artifactId = rootProject.archives_base_name
artifact(remapJar)
artifact(sourcesJar) {
builtBy remapSourcesJar
}
from components.java
}
}

Expand Down
7 changes: 2 additions & 5 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ shadowJar {
relocate "org.yaml.snakeyaml", "${rootProject.maven_group}.clothconfig.shadowed.org.yaml.snakeyaml"

configurations = [project.configurations.shadowCommon]
classifier "shadow"
archiveClassifier = "shadow"
}

remapJar {
Expand All @@ -88,10 +88,7 @@ publishing {
publications {
mavenFabric(MavenPublication) {
artifactId = rootProject.archives_base_name + "-fabric"
artifact(remapJar.archivePath) {
builtBy build
classifier null
}
from components.java
}
}

Expand Down
11 changes: 4 additions & 7 deletions forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ shadowJar {
relocate "org.yaml.snakeyaml", "${rootProject.maven_group}.clothconfig.shadowed.org.yaml.snakeyaml"

configurations = [project.configurations.shadowCommon]
classifier "shadow"
archiveClassifier = "shadow"
}

remapJar {
Expand All @@ -79,10 +79,7 @@ publishing {
publications {
mavenForge(MavenPublication) {
artifactId = rootProject.archives_base_name + "-forge"
artifact(remapJar.archivePath) {
builtBy build
classifier null
}
from components.java
}
}

Expand All @@ -101,9 +98,9 @@ publishing {

unifiedPublishing {
project {
displayName = "[LexForge $rootProject.supported_version] v$project.version"
displayName = "[MinecraftForge $rootProject.supported_version] v$project.version"
releaseType = "release"
gameVersions = ["1.20", "1.20.1"]
gameVersions = ["1.20.2"]
gameLoaders = ["forge"]

mainPublication remapJar
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ fabric_api_version=0.89.0+1.20.2
mod_menu_version=8.0.0-beta.2

forge_version=48.0.1
neoforge_version=20.2.52-beta

curseforge_id=348521
modrinth_id=9s6osm5g
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip
125 changes: 125 additions & 0 deletions neoforge/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
plugins {
id "com.github.johnrengelman.shadow" version "7.0.0"
id "me.shedaniel.unified-publishing"
id "maven-publish"
}

configurations {
shadowCommon
dev
}

artifacts {
dev(jar)
}

architectury {
platformSetupLoomIde()
neoForge()
}

configurations {
common
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
compileClasspath.extendsFrom common
runtimeClasspath.extendsFrom common
developmentNeoForge.extendsFrom common
}

dependencies {
minecraft "com.mojang:minecraft:${rootProject.architectury.minecraft}"
mappings loom.officialMojangMappings()

neoForge "net.neoforged:neoforge:${rootProject.neoforge_version}"

modLocalRuntime("me.shedaniel.cloth:basic-math:0.6.1")
forgeRuntimeLibrary(shadowCommon("me.shedaniel.cloth:basic-math:0.6.1"))

implementation("blue.endless:jankson:${rootProject.jankson_version}")
implementation("com.moandjiezana.toml:toml4j:${rootProject.toml4j_version}")
implementation("org.yaml:snakeyaml:${rootProject.snakeyaml_version}")
forgeRuntimeLibrary(shadowCommon("blue.endless:jankson:${rootProject.jankson_version}"))
forgeRuntimeLibrary(shadowCommon("com.moandjiezana.toml:toml4j:${rootProject.toml4j_version}") {
exclude(module: "gson")
})
forgeRuntimeLibrary(shadowCommon("org.yaml:snakeyaml:${rootProject.snakeyaml_version}"))

common(project(path: ":common", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProductionNeoForge")) { transitive false }
}

processResources {
filesMatching("META-INF/mods.toml") {
expand "version": project.version
}
inputs.property "META-INF/mods.toml", project.version
}

shadowJar {
exclude "fabric.mod.json"
exclude "cloth-config.accessWidener"
relocate "blue.endless.jankson", "${rootProject.maven_group}.clothconfig.shadowed.blue.endless.jankson"
relocate "com.moandjiezana.toml", "${rootProject.maven_group}.clothconfig.shadowed.com.moandjiezana.toml"
relocate "org.yaml.snakeyaml", "${rootProject.maven_group}.clothconfig.shadowed.org.yaml.snakeyaml"

configurations = [project.configurations.shadowCommon]
archiveClassifier = "shadow"
}

remapJar {
input.set(shadowJar.archiveFile)
dependsOn(shadowJar)
archiveClassifier = "neoforge"

from rootProject.file("LICENSE.md")
}

publishing {
publications {
mavenNeoForge(MavenPublication) {
artifactId = rootProject.archives_base_name + "-neoforge"
from components.java
}
}

repositories {
if (System.getenv("MAVEN_PASS") != null) {
maven {
url = "https://deploy.shedaniel.me/"
credentials {
username = "shedaniel"
password = System.getenv("MAVEN_PASS")
}
}
}
}
}

unifiedPublishing {
project {
displayName = "[NeoForge $rootProject.supported_version] v$project.version"
releaseType = "release"
gameVersions = ["1.20.2"]
gameLoaders = ["neoforge"]

mainPublication remapJar

if (project.hasProperty("curse_api_key") || System.getenv("curse_api_key") != null) {
curseforge {
token = project.hasProperty("curse_api_key") ? project.property("curse_api_key") : System.getenv("curse_api_key")
id = project.curseforge_id
gameVersions.addAll "Java 17"
}
}

if (project.hasProperty("modrinth_key") || System.getenv("modrinth_key") != null) {
modrinth {
token = project.hasProperty("modrinth_key") ? project.property("modrinth_key") : System.getenv("modrinth_key")
id = project.modrinth_id
version = "$project.version+$project.name"
}
}
}
}

rootProject.tasks.getByName("modPublish").dependsOn tasks.getByName("publishUnified")
1 change: 1 addition & 0 deletions neoforge/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
loom.platform=neoforge
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* This file is part of Cloth Config.
* Copyright (C) 2020 - 2021 shedaniel
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

package me.shedaniel.autoconfig.util.forge;

import net.neoforged.fml.loading.FMLPaths;

import java.nio.file.Path;

public class UtilsImpl {
public static Path getConfigFolder() {
return FMLPaths.CONFIGDIR.get();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* This file is part of Cloth Config.
* Copyright (C) 2020 - 2021 shedaniel
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

package me.shedaniel.clothconfig;

import me.shedaniel.clothconfig2.ClothConfigInitializer;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.fml.DistExecutor;
import net.neoforged.fml.IExtensionPoint;
import net.neoforged.fml.ModLoadingContext;
import net.neoforged.fml.common.Mod;

@Mod(ClothConfigInitializer.MOD_ID)
public class ClothConfigForge {
public ClothConfigForge() {
ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class, () -> new IExtensionPoint.DisplayTest(() -> IExtensionPoint.DisplayTest.IGNORESERVERONLY, (a, b) -> true));
DistExecutor.safeRunWhenOn(Dist.CLIENT, () -> ClothConfigForgeDemo::registerModsPage);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* This file is part of Cloth Config.
* Copyright (C) 2020 - 2021 shedaniel
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

package me.shedaniel.clothconfig;

import me.shedaniel.clothconfig2.ClothConfigDemo;
import net.neoforged.fml.ModLoadingContext;
import net.neoforged.neoforge.client.ConfigScreenHandler;

public class ClothConfigForgeDemo {
public static void registerModsPage() {
ModLoadingContext.get().registerExtensionPoint(ConfigScreenHandler.ConfigScreenFactory.class, () -> new ConfigScreenHandler.ConfigScreenFactory((client, parent) -> {
return ClothConfigDemo.getConfigBuilderWithDemo().setParentScreen(parent).build();
}));
}
}
6 changes: 6 additions & 0 deletions neoforge/src/main/resources/META-INF/accesstransformer.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Font.renderText
public net.minecraft.client.gui.Font renderText(Ljava/lang/String;FFIZLorg/joml/Matrix4f;Lnet/minecraft/client/renderer/MultiBufferSource;Lnet/minecraft/client/gui/Font$DisplayMode;II)F # renderText
# Button.onPress
public-f net.minecraft.client.gui.components.Button onPress # onPress
# KeyMapping.key
public net.minecraft.client.KeyMapping key # key
22 changes: 22 additions & 0 deletions neoforge/src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
modLoader = "javafml"
loaderVersion = "[1,)"
issueTrackerURL = "https://github.com/architectury/ClothConfig/issues/"
displayURL = "https://www.curseforge.com/minecraft/mc-mods/cloth-config-forge/"
logoFile = "icon.png"
authors = "shedaniel"
license = "GNU LGPLv3"

[[mods]]
modId = "cloth_config"
version = "${version}"
displayName = "Cloth Config v12 API"
description = '''
An API for config screens.
'''

[[dependencies.cloth_config]]
modId = "neoforge"
mandatory = true
versionRange = "[20.2,)"
ordering = "NONE"
side = "BOTH"
Binary file added neoforge/src/main/resources/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions neoforge/src/main/resources/pack.mcmeta
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"pack": {
"description": "Mod resources",
"pack_format": 4
}
}
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ pluginManagement {
include("common")
include("fabric")
include("forge")
include("neoforge")

rootProject.name = 'cloth-config'

0 comments on commit f4ddda2

Please sign in to comment.