Skip to content

Commit

Permalink
Updated Gradle, port to 1.21.4 and #37 solved
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxenceDC committed Dec 29, 2024
1 parent dba9dae commit a12ef6a
Show file tree
Hide file tree
Showing 19 changed files with 144 additions and 165 deletions.
6 changes: 4 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
plugins {
// Required for NeoGradle
id "org.jetbrains.gradle.plugin.idea-ext" version "1.1.7"
// see https://fabricmc.net/develop/ for new versions
id 'fabric-loom' version '1.8-SNAPSHOT' apply false
// see https://projects.neoforged.net/neoforged/moddevgradle for new versions
id 'net.neoforged.moddev' version '2.0.64-beta' apply false
}
56 changes: 35 additions & 21 deletions buildSrc/src/main/groovy/multiloader-common.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,20 @@ repositories {
url = 'https://repo.spongepowered.org/repository/maven-public'
}
}
filter { includeGroupAndSubgroups("org.spongepowered") }
filter { includeGroupAndSubgroups('org.spongepowered') }
}
exclusiveContent {
forRepositories(
maven {
name = 'ParchmentMC'
url = 'https://maven.parchmentmc.org/'
},
maven {
name = "NeoForge"
url = 'https://maven.neoforged.net/releases'
}
)
filter { includeGroup('org.parchmentmc.data') }
}
maven {
name = 'BlameJared'
Expand All @@ -35,6 +48,7 @@ repositories {
// Read more about capabilities here: https://docs.gradle.org/current/userguide/component_capabilities.html#sec:declaring-additional-capabilities-for-a-local-component
['apiElements', 'runtimeElements', 'sourcesElements', 'javadocElements'].each { variant ->
configurations."$variant".outgoing {
capability("$group:${project.name}:$version")
capability("$group:${base.archivesName.get()}:$version")
capability("$group:$mod_id-${project.name}-${minecraft_version}:$version")
capability("$group:$mod_id:$version")
Expand All @@ -45,13 +59,13 @@ repositories {
}

sourcesJar {
from(rootProject.file("LICENSE")) {
from(rootProject.file('LICENSE')) {
rename { "${it}_${mod_name}" }
}
}

jar {
from(rootProject.file("LICENSE")) {
from(rootProject.file('LICENSE')) {
rename { "${it}_${mod_name}" }
}

Expand All @@ -69,22 +83,22 @@ jar {
}

processResources {
def expandProps = [
"version": version,
"group": project.group, //Else we target the task's group.
"minecraft_version": minecraft_version,
"minecraft_version_range": minecraft_version_range,
"fabric_version": fabric_version,
"fabric_loader_version": fabric_loader_version,
"mod_name": mod_name,
"mod_author": mod_author,
"mod_id": mod_id,
"license": license,
"description": project.description,
"neoforge_version": neoforge_version,
"neoforge_loader_version_range": neoforge_loader_version_range,
"credits": credits,
"java_version": java_version
var expandProps = [
'version' : version,
'group' : project.group, //Else we target the task's group.
'minecraft_version' : minecraft_version,
'minecraft_version_range' : minecraft_version_range,
'fabric_version' : fabric_version,
'fabric_loader_version' : fabric_loader_version,
'mod_name' : mod_name,
'mod_author' : mod_author,
'mod_id' : mod_id,
'license' : license,
'description' : project.description,
'neoforge_version' : neoforge_version,
'neoforge_loader_version_range': neoforge_loader_version_range,
'credits' : credits,
'java_version' : java_version
]

filesMatching(['pack.mcmeta', 'fabric.mod.json', 'META-INF/mods.toml', 'META-INF/neoforge.mods.toml', '*.mixins.json']) {
Expand All @@ -102,7 +116,7 @@ publishing {
}
repositories {
maven {
url System.getenv("local_maven_url")
url System.getenv('local_maven_url')
}
}
}
}
4 changes: 2 additions & 2 deletions buildSrc/src/main/groovy/multiloader-loader.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ tasks.named('javadoc', Javadoc).configure {
source(configurations.commonJava)
}

tasks.named("sourcesJar", Jar) {
tasks.named('sourcesJar', Jar) {
dependsOn(configurations.commonJava)
from(configurations.commonJava)
dependsOn(configurations.commonResources)
from(configurations.commonResources)
}
}
23 changes: 15 additions & 8 deletions common/build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
plugins {
id 'multiloader-common'
id 'org.spongepowered.gradle.vanilla' version '0.2.1-SNAPSHOT'
id 'net.neoforged.moddev'
}

minecraft {
version(minecraft_version)
def aw = file("src/main/resources/${mod_id}.accesswidener")
if(aw.exists()){
accessWideners(aw)
neoForge {
neoFormVersion = neo_form_version
// Automatically enable AccessTransformers if the file exists
def at = file('src/main/resources/META-INF/accesstransformer.cfg')
if (at.exists()) {
accessTransformers.from(at.absolutePath)
}
parchment {
minecraftVersion = parchment_minecraft
mappingsVersion = parchment_version
}
}

dependencies {
compileOnly group:'org.spongepowered', name:'mixin', version:'0.8.5'
compileOnly group: 'org.spongepowered', name: 'mixin', version: '0.8.5'
// fabric and neoforge both bundle mixinextras, so it is safe to use it in common
compileOnly group: 'io.github.llamalad7', name: 'mixinextras-common', version: '0.3.5'
annotationProcessor group: 'io.github.llamalad7', name: 'mixinextras-common', version: '0.3.5'
}

configurations {
Expand All @@ -30,4 +38,3 @@ artifacts {
commonJava sourceSets.main.java.sourceDirectories.singleFile
commonResources sourceSets.main.resources.sourceDirectories.singleFile
}

Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,21 @@ public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
String fileName = new SimpleDateFormat("'structure_sets_dump_'yy_MM_dd_HH_mm'.txt'").format(new Date());
try {
dumpStructureSets(fileName);
context.getSource().sendSuccess(() -> Component.literal("Structure sets dumped to: `" + Paths.get(Constants.MOD_ID, fileName) + "`\n(if you're on a server, this is dumped in the server's files)"), false);
context.getSource().sendSuccess(() -> {
boolean isDedicatedServer = context.getSource().getServer().isDedicatedServer();
String fileLocation = Paths.get(Constants.MOD_ID, fileName).toString();

String message = "Structure sets dumped to: `" + fileLocation + "`";
if (isDedicatedServer) {
message += "\n(you can find the result in the server's files)";
}

return Component.literal(message);
}, false);
return 1;
} catch (IOException e) {
context.getSource().sendSuccess(() -> Component.literal("Failed to dump structure sets, check logs for error"), false);
Constants.LOG.error("Failed to dump structure sets", e);
Constants.LOG.error("Failed to dump structure sets\n", e);
return 0;
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.llamalad7.mixinextras.sugar.Local;
import com.mojang.serialization.Decoder;
import io.github.maxencedc.sparsestructures.CustomSpreadFactors;
import io.github.maxencedc.sparsestructures.SparseStructuresCommon;
Expand All @@ -24,7 +25,7 @@
public class MakeStructuresSparse {

@Inject(at = @At(value = "INVOKE", target = "Lcom/mojang/serialization/Decoder;parse(Lcom/mojang/serialization/DynamicOps;Ljava/lang/Object;)Lcom/mojang/serialization/DataResult;"), method = "loadElementFromResource", locals = LocalCapture.CAPTURE_FAILHARD)
private static <E> void loadElementFromResource(WritableRegistry<E> registry, Decoder<E> decoder, RegistryOps<JsonElement> ops, ResourceKey<E> resourceKey, Resource resource, RegistrationInfo registrationInfo, CallbackInfo ci, Reader reader, JsonElement jsonElement) {
private static <E> void loadElementFromResource(WritableRegistry<E> registry, Decoder<E> codec, RegistryOps<JsonElement> ops, ResourceKey<E> resourceKey, Resource resource, RegistrationInfo registrationInfo, CallbackInfo ci, @Local JsonElement jsonElement) {
String string = registry.key().location().getPath();
if (!string.equals("worldgen/structure_set")) return;

Expand Down Expand Up @@ -52,5 +53,4 @@ private static <E> void loadElementFromResource(WritableRegistry<E> registry, De
placement.addProperty("spacing", spacing);
placement.addProperty("separation", separation);
}
}
}
}}
3 changes: 2 additions & 1 deletion common/src/main/resources/sparsestructures.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"refmap": "${mod_id}.refmap.json",
"compatibilityLevel": "JAVA_21",
"mixins": [
"FixLocateDistance"
"FixLocateDistance",
"MakeStructuresSparse"
],
"client": [],
"server": [],
Expand Down
17 changes: 10 additions & 7 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
plugins {
id 'multiloader-loader'
id 'fabric-loom' version '1.7-SNAPSHOT'
id 'fabric-loom'
}
dependencies {
minecraft "com.mojang:minecraft:${minecraft_version}"
mappings loom.officialMojangMappings()
mappings loom.layered {
officialMojangMappings()
parchment("org.parchmentmc.data:parchment-${parchment_minecraft}:${parchment_version}@zip")
}
modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_version}"
}

loom {
def aw = project(":common").file("src/main/resources/${mod_id}.accesswidener")
def aw = project(':common').file("src/main/resources/${mod_id}.accesswidener")
if (aw.exists()) {
accessWidenerPath.set(aw)
}
Expand All @@ -20,15 +23,15 @@ loom {
runs {
client {
client()
setConfigName("Fabric Client")
setConfigName('Fabric Client')
ideConfigGenerated(true)
runDir("runs/client")
runDir('runs/client')
}
server {
server()
setConfigName("Fabric Server")
setConfigName('Fabric Server')
ideConfigGenerated(true)
runDir("runs/server")
runDir('runs/server')
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"refmap": "${mod_id}.refmap.json",
"compatibilityLevel": "JAVA_21",
"mixins": [
"MakeStructuresSparse",
"PushSpreadLimit"
],
"client": [],
Expand Down
21 changes: 14 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,35 @@
# Every field you add must be added to the root build.gradle expandProps map.

# Project
version=2.2.0
version=2.2.1
group=io.github.maxencedc.sparsestructures
java_version=21

# Common
minecraft_version=1.21
minecraft_version=1.21.4
mod_name=SparseStructures
mod_author=MaxenceDC
mod_id=sparsestructures
license=MIT
credits=All GitHub contributors, jaredlll08 for the Multiloader template, The modding community, and BisectHosting (use code MAX)!
description=Makes all structures more spread out. Configurable.\\n\\nIf you want to support me, you can use code MAX at BisectHosting for 25% off!
minecraft_version_range=[1.21, 1.22)
minecraft_version_range=[1.21.4, 1.22)

## NeoForm (https://projects.neoforged.net/neoforged/neoform)
neo_form_version=1.21.4-20241203.161809

# Parchment
parchment_minecraft=1.21.4
parchment_version=2024.12.22

# Fabric
fabric_version=0.100.3+1.21
fabric_loader_version=0.15.11
fabric_version=0.113.0+1.21.4
fabric_loader_version=0.16.9

# NeoForge
neoforge_version=21.0.30-beta
neoforge_version=21.4.46-beta
neoforge_loader_version_range=[4,)

# Gradle
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
org.gradle.daemon=false
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
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.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
7 changes: 5 additions & 2 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -84,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -246,4 +249,4 @@ eval "set -- $(
tr '\n' ' '
)" '"$@"'

exec "$JAVACMD" "$@"
exec "$JAVACMD" "$@"
4 changes: 3 additions & 1 deletion gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down Expand Up @@ -89,4 +91,4 @@ exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal

:omega
:omega
Binary file added media/gradle-wrapper.jar
Binary file not shown.
Loading

0 comments on commit a12ef6a

Please sign in to comment.