Port to Architectury

Still need to figure out how to register built-in resource packs on forge
This commit is contained in:
Motschen
2022-11-02 18:21:21 +01:00
parent 9e5ff1cb94
commit 54e6d69456
36 changed files with 684 additions and 232 deletions

32
.gitignore vendored Executable file → Normal file
View File

@@ -1,25 +1,19 @@
# gradle
.gradle/
out/
classes/
build/
# idea
.idea/
*.iml
*.ipr
run/
*.iws
# vscode
.settings/
.vscode/
out/
*.iml
.gradle/
output/
bin/
libs/
.classpath
.project
# fabric
run/
.idea/
classes/
.metadata
.vscode
.settings
*.launch

116
build.gradle Executable file → Normal file
View File

@@ -1,84 +1,58 @@
plugins {
id 'fabric-loom' version '0.12-SNAPSHOT'
id 'maven-publish'
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "1.0-SNAPSHOT" apply false
}
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group
architectury {
injectInjectables = false
minecraft = rootProject.minecraft_version
}
repositories {
maven {
url = "https://api.modrinth.com/maven"
}
maven {
url = "https://api.modrinth.com/maven"
}
}
dependencies {
//to change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
subprojects {
apply plugin: "dev.architectury.loom"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
loom {
silentMojangMappingsLicense()
}
modImplementation "maven.modrinth:midnightlib:${project.midnightlib_version}"
include "maven.modrinth:midnightlib:${project.midnightlib_version}"
dependencies {
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
// The following line declares the mojmap mappings, you may use other mappings as well
//mappings loom.officialMojangMappings()
// The following line declares the yarn mappings you may select this one as well.
mappings "net.fabricmc:yarn:1.19.2+build.3:v2"
}
}
processResources {
inputs.property "version", project.version
allprojects {
apply plugin: "java"
apply plugin: "architectury-plugin"
apply plugin: "maven-publish"
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}
tasks.withType(JavaCompile).configureEach {
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
// If Javadoc is generated, this must be specified in that task too.
it.options.encoding = "UTF-8"
// Minecraft 1.17 (21w19a) upwards uses Java 16.
it.options.release = 17
}
java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
}
jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"}
}
}
// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
// add all the jars that should be included when publishing to maven
artifact(remapJar) {
builtBy remapJar
}
artifact(sourcesJar) {
builtBy remapSourcesJar
}
}
}
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
// Notice: This block does NOT have the same function as the block in the top level.
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
archivesBaseName = rootProject.archives_base_name
version = rootProject.mod_version
group = rootProject.maven_group
repositories {
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
}
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
options.release = 17
}
java {
withSourcesJar()
}
}

34
common/build.gradle Normal file
View File

@@ -0,0 +1,34 @@
architectury {
injectInjectables = false
common(rootProject.enabled_platforms.split(","))
}
loom {
}
repositories {
maven { url "https://api.modrinth.com/maven" }
}
dependencies {
// We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies
// Do NOT use other classes from fabric loader
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
modCompileOnlyApi "maven.modrinth:midnightlib:${rootProject.midnightlib_version}-fabric"
// Remove the next line if you don't want to depend on the API
modApi "dev.architectury:architectury:${rootProject.architectury_version}"
}
publishing {
publications {
mavenCommon(MavenPublication) {
artifactId = rootProject.archives_base_name
from components.java
}
}
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
}
}

View File

@@ -0,0 +1,10 @@
package eu.midnightdust.cullleaves;
import eu.midnightdust.cullleaves.config.CullLeavesConfig;
public class CullLeavesClient {
public static void onInitializeClient() {
CullLeavesConfig.init("cullleaves", CullLeavesConfig.class);
}
}

View File

@@ -0,0 +1,2 @@
{
}

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -1,10 +1,12 @@
{
"required": true,
"package": "eu.midnightdust.cullleaves.mixin",
"compatibilityLevel": "JAVA_8",
"compatibilityLevel": "JAVA_17",
"client": [
"MixinLeavesBlock"
],
"mixins": [
],
"injectors": {
"defaultRequire": 1
}

View File

Before

Width:  |  Height:  |  Size: 8.3 KiB

After

Width:  |  Height:  |  Size: 8.3 KiB

16
fabric-like/build.gradle Normal file
View File

@@ -0,0 +1,16 @@
architectury {
injectInjectables = false
common(rootProject.enabled_platforms.split(","))
}
loom {
}
dependencies {
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}"
// Remove the next line if you don't want to depend on the API
modApi "dev.architectury:architectury-fabric:${rootProject.architectury_version}"
compileClasspath(project(path: ":common", configuration: "namedElements")) { transitive false }
}

88
fabric/build.gradle Normal file
View File

@@ -0,0 +1,88 @@
plugins {
id "com.github.johnrengelman.shadow" version "7.1.2"
}
architectury {
injectInjectables = false
platformSetupLoomIde()
fabric()
}
loom {
}
repositories {
maven { url "https://api.modrinth.com/maven" }
}
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
developmentFabric.extendsFrom common
}
dependencies {
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}"
// Remove the next line if you don't want to depend on the API
//modApi "dev.architectury:architectury-fabric:${rootProject.architectury_version}"
modImplementation "maven.modrinth:midnightlib:${rootProject.midnightlib_version}-fabric"
include "maven.modrinth:midnightlib:${rootProject.midnightlib_version}-fabric"
common(project(path: ":common", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false }
common(project(path: ":fabric-like", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":fabric-like", configuration: "transformProductionFabric")) { transitive false }
}
processResources {
inputs.property "version", project.version
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}
shadowJar {
exclude "architectury.common.json"
configurations = [project.configurations.shadowCommon]
classifier "dev-shadow"
}
remapJar {
input.set shadowJar.archiveFile
dependsOn shadowJar
classifier null
}
jar {
classifier "dev"
}
sourcesJar {
def commonSources = project(":common").sourcesJar
dependsOn commonSources
from commonSources.archiveFile.map { zipTree(it) }
}
components.java {
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
skip()
}
}
publishing {
publications {
mavenFabric(MavenPublication) {
artifactId = rootProject.archives_base_name + "-" + project.name
from components.java
}
}
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
}
}

View File

@@ -1,18 +1,16 @@
package eu.midnightdust.cullleaves;
package eu.midnightdust.cullleaves.fabric;
import eu.midnightdust.cullleaves.config.CullLeavesConfig;
import eu.midnightdust.cullleaves.CullLeavesClient;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
import net.fabricmc.fabric.api.resource.ResourcePackActivationType;
import net.fabricmc.loader.ModContainer;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.util.Identifier;
public class CullLeavesClient implements ClientModInitializer {
public class CullLeavesClientFabric implements ClientModInitializer {
@Override
public void onInitializeClient() {
CullLeavesConfig.init("cullleaves", CullLeavesConfig.class);
CullLeavesClient.onInitializeClient();
FabricLoader.getInstance().getModContainer("cullleaves").ifPresent(modContainer -> {
ResourceManagerHelper.registerBuiltinResourcePack(new Identifier("cullleaves:smartleaves"), modContainer, ResourcePackActivationType.NORMAL);
});

View File

@@ -21,7 +21,7 @@
"environment": "client",
"entrypoints": {
"client": [
"eu.midnightdust.cullleaves.CullLeavesClient"
"eu.midnightdust.cullleaves.fabric.CullLeavesClientFabric"
]
},

89
forge/build.gradle Normal file
View File

@@ -0,0 +1,89 @@
plugins {
id "com.github.johnrengelman.shadow" version "7.1.2"
}
architectury {
injectInjectables = false
platformSetupLoomIde()
forge()
}
loom {
forge {
mixinConfig "cullleaves.mixins.json"
}
}
repositories {
maven { url "https://api.modrinth.com/maven" }
}
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
developmentForge.extendsFrom common
}
dependencies {
forge "net.minecraftforge:forge:${rootProject.forge_version}"
// Remove the next line if you don't want to depend on the API
//modApi "dev.architectury:architectury-forge:${rootProject.architectury_version}"
modImplementation "maven.modrinth:midnightlib:${rootProject.midnightlib_version}-forge"
include "maven.modrinth:midnightlib:${rootProject.midnightlib_version}-forge"
common(project(path: ":common", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive = false }
}
processResources {
inputs.property "version", project.version
filesMatching("META-INF/mods.toml") {
expand "version": project.version
}
}
shadowJar {
exclude "fabric.mod.json"
exclude "architectury.common.json"
configurations = [project.configurations.shadowCommon]
classifier "dev-shadow"
}
remapJar {
input.set shadowJar.archiveFile
dependsOn shadowJar
classifier null
}
jar {
classifier "dev"
}
sourcesJar {
def commonSources = project(":common").sourcesJar
dependsOn commonSources
from commonSources.archiveFile.map { zipTree(it) }
}
components.java {
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
skip()
}
}
publishing {
publications {
mavenForge(MavenPublication) {
artifactId = rootProject.archives_base_name + "-" + project.name
from components.java
}
}
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
}
}

1
forge/gradle.properties Normal file
View File

@@ -0,0 +1 @@
loom.platform=forge

View File

@@ -0,0 +1,16 @@
package eu.midnightdust.cullleaves.forge;
import eu.midnightdust.cullleaves.CullLeavesClient;
import eu.midnightdust.lib.config.MidnightConfig;
import net.minecraftforge.client.ConfigScreenHandler;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
@Mod("cullleaves")
public class CullLeavesClientForge {
public CullLeavesClientForge() {
CullLeavesClient.onInitializeClient();
ModLoadingContext.get().registerExtensionPoint(ConfigScreenHandler.ConfigScreenFactory.class, () ->
new ConfigScreenHandler.ConfigScreenFactory((client, parent) -> MidnightConfig.getScreen(parent, "cullleaves")));
}
}

View File

@@ -0,0 +1,35 @@
modLoader = "javafml"
loaderVersion = "[43,)"
#issueTrackerURL = ""
license = "MIT"
[[mods]]
modId = "cullleaves"
version = "${version}"
displayName = "CullLeaves"
authors = "Motschen, TeamMidnightDust"
description = '''
Adds culling to leaf blocks, providing a huge performance boost over vanilla.
'''
logoFile = "icon.png"
[[dependencies.cullleaves]]
modId = "forge"
mandatory = true
versionRange = "[43,)"
ordering = "NONE"
side = "CLIENT"
[[dependencies.cullleaves]]
modId = "minecraft"
mandatory = true
versionRange = "[1.19.2,)"
ordering = "NONE"
side = "CLIENT"
[[dependencies.cullleaves]]
modId = "midnightlib"
mandatory = true
versionRange = "[1.0.0,)"
ordering = "NONE"
side = "CLIENT"

BIN
forge/src/main/resources/icon.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -0,0 +1,6 @@
{
"pack": {
"description": "CullLeaves",
"pack_format": 9
}
}

31
gradle.properties Executable file → Normal file
View File

@@ -1,18 +1,19 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G
org.gradle.jvmargs=-Xmx4096M
# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.19-rc2
yarn_mappings=1.19-rc2+build.1
loader_version=0.14.6
minecraft_version=1.19.2
enabled_platforms=quilt,fabric,forge
# Mod Properties
mod_version = 2.3.4
maven_group = eu.midnightdust
archives_base_name = cullleaves
archives_base_name=cullleaves
mod_version=3.0.0
maven_group=eu.midnightdust
# Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
fabric_version=0.55.1+1.19
midnightlib_version=0.5.2
architectury_version=6.2.43
midnightlib_version=1.0.0
fabric_loader_version=0.14.9
fabric_api_version=0.59.0+1.19.2
forge_version=1.19.2-43.0.8
quilt_loader_version=0.17.2-beta.3
quilt_fabric_api_version=4.0.0-beta.7+0.59.0-1.19.2

Binary file not shown.

View File

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

6
gradlew vendored
View File

@@ -205,6 +205,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.

14
gradlew.bat vendored
View File

@@ -14,7 +14,7 @@
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@@ -25,7 +25,7 @@
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
if "%DIRNAME%"=="" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
if %ERRORLEVEL% equ 0 goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -75,13 +75,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal

96
quilt/build.gradle Normal file
View File

@@ -0,0 +1,96 @@
plugins {
id "com.github.johnrengelman.shadow" version "7.1.2"
}
repositories {
maven { url "https://maven.quiltmc.org/repository/release/" }
maven { url "https://api.modrinth.com/maven" }
}
architectury {
injectInjectables = false
platformSetupLoomIde()
loader("quilt")
}
loom {
}
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
developmentQuilt.extendsFrom common
}
dependencies {
modImplementation "org.quiltmc:quilt-loader:${rootProject.quilt_loader_version}"
modApi "org.quiltmc.quilted-fabric-api:quilted-fabric-api:${rootProject.quilt_fabric_api_version}"
// Remove the next few lines if you don't want to depend on the API
//modApi("dev.architectury:architectury-fabric:${rootProject.architectury_version}") {
// // We must not pull Fabric Loader from Architectury Fabric
// exclude group: "net.fabricmc"
// exclude group: "net.fabricmc.fabric-api"
//}
modImplementation "maven.modrinth:midnightlib:${rootProject.midnightlib_version}-quilt"
include "maven.modrinth:midnightlib:${rootProject.midnightlib_version}-quilt"
common(project(path: ":common", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProductionQuilt")) { transitive false }
common(project(path: ":fabric-like", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":fabric-like", configuration: "transformProductionQuilt")) { transitive false }
}
processResources {
inputs.property "group", rootProject.maven_group
inputs.property "version", project.version
filesMatching("quilt.mod.json") {
expand "group": rootProject.maven_group,
"version": project.version
}
}
shadowJar {
exclude "architectury.common.json"
configurations = [project.configurations.shadowCommon]
classifier "dev-shadow"
}
remapJar {
input.set shadowJar.archiveFile
dependsOn shadowJar
classifier null
}
jar {
classifier "dev"
}
sourcesJar {
def commonSources = project(":common").sourcesJar
dependsOn commonSources
from commonSources.archiveFile.map { zipTree(it) }
}
components.java {
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
skip()
}
}
publishing {
publications {
mavenQuilt(MavenPublication) {
artifactId = rootProject.archives_base_name + "-" + project.name
from components.java
}
}
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
}
}

1
quilt/gradle.properties Normal file
View File

@@ -0,0 +1 @@
loom.platform=quilt

View File

@@ -0,0 +1,16 @@
package eu.midnightdust.cullleaves.quilt;
import eu.midnightdust.cullleaves.CullLeavesClient;
import net.minecraft.util.Identifier;
import org.quiltmc.loader.api.ModContainer;
import org.quiltmc.qsl.base.api.entrypoint.client.ClientModInitializer;
import org.quiltmc.qsl.resource.loader.api.ResourceLoader;
import org.quiltmc.qsl.resource.loader.api.ResourcePackActivationType;
public class CullLeavesClientQuilt implements ClientModInitializer {
@Override
public void onInitializeClient(ModContainer mod) {
CullLeavesClient.onInitializeClient();
ResourceLoader.registerBuiltinResourcePack(new Identifier("cullleaves:smartleaves"), mod, ResourcePackActivationType.NORMAL);
}
}

View File

@@ -0,0 +1,59 @@
{
"schema_version": 1,
"quilt_loader": {
"group": "${group}",
"id": "cullleaves",
"version": "${version}",
"name": "Cull Leaves",
"description": "Adds culling to leaf blocks, providing a huge performance boost over vanilla.",
"authors": [
"Motschen",
"TeamMidnightDust"
],
"contact": {
"homepage": "https://www.midnightdust.eu/",
"sources": "https://github.com/TeamMidnightDust/MidnightLib",
"issues": "https://github.com/TeamMidnightDust/MidnightLib/issues"
},
"license": "MIT",
"icon": "assets/cullleaves/icon.png",
"intermediate_mappings": "net.fabricmc:intermediary",
"environment": "*",
"entrypoints": {
"client_init": [
"eu.midnightdust.cullleaves.quilt.CullLeavesClientQuilt"
]
},
"depends": [
{
"id": "quilt_loader",
"version": "*"
},
{
"id": "quilt_base",
"version": "*"
},
{
"id": "midnightlib",
"version": "*"
}
],
"metadata": {
"name": "Cull Leaves (Quilt)",
"contributors": {
"Motschen": "Author",
"TeamMidnightDust": "Mascot"
},
"contact": {
"email": "mail@midnightdust.eu",
"homepage": "https://modrinth.com/mod/cullleaves",
"issues": "https://github.com/TeamMidnightDust/CullLeaves/issues",
"sources": "https://github.com/TeamMidnightDust/CullLeaves"
},
"icon": "assets/cullleaves/icon.png"
}
},
"mixin": [
"cullleaves.mixins.json"
]
}

16
settings.gradle Executable file → Normal file
View File

@@ -1,10 +1,16 @@
pluginManagement {
repositories {
jcenter()
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
maven { url "https://maven.fabricmc.net/" }
maven { url "https://maven.architectury.dev/" }
maven { url "https://maven.minecraftforge.net/" }
gradlePluginPortal()
}
}
include("common")
include("fabric-like")
include("fabric")
include("quilt")
include("forge")
rootProject.name = "cullleaves"