Skip to content

Commit 2326a9f

Browse files
authored
Merge pull request #13 from MicrocontrollersDev/stonecutter
2 parents a2418c1 + 0960cc1 commit 2326a9f

22 files changed

Lines changed: 184 additions & 484 deletions

File tree

build.gradle.kts

Lines changed: 89 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,107 @@
1-
@file:Suppress("UnstableApiUsage", "PropertyName")
2-
3-
import dev.deftu.gradle.utils.GameSide
4-
import dev.deftu.gradle.utils.includeOrShade
1+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
2+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
53

64
plugins {
7-
java
8-
kotlin("jvm")
9-
id("dev.deftu.gradle.multiversion") // Applies preprocessing for multiple versions of Minecraft and/or multiple mod loaders.
10-
id("dev.deftu.gradle.tools") // Applies several configurations to things such as the Java version, project name/version, etc.
11-
id("dev.deftu.gradle.tools.resources") // Applies resource processing so that we can replace tokens, such as our mod name/version, in our resources.
12-
id("dev.deftu.gradle.tools.bloom") // Applies the Bloom plugin, which allows us to replace tokens in our source files, such as being able to use `@MOD_VERSION` in our source files.
13-
id("dev.deftu.gradle.tools.shadow") // Applies the Shadow plugin, which allows us to shade our dependencies into our mod JAR. This is NOT recommended for Fabric mods, but we have an *additional* configuration for those!
14-
id("dev.deftu.gradle.tools.minecraft.loom") // Applies the Loom plugin, which automagically configures Essential's Architectury Loom plugin for you.
15-
id("dev.deftu.gradle.tools.minecraft.releases") // Applies the Minecraft auto-releasing plugin, which allows you to automatically release your mod to CurseForge and Modrinth.
5+
id("net.fabricmc.fabric-loom-remap") version "1.14-SNAPSHOT"
6+
id("org.jetbrains.kotlin.jvm") version "2.3.0"
7+
id("dev.deftu.gradle.bloom") version "0.2.0"
168
}
179

18-
toolkitMultiversion {
19-
moveBuildsToRootProject = true
10+
val modid = property("mod.id")
11+
val modname = property("mod.name")
12+
val modversion = property("mod.version")
13+
val mcversion = property("minecraft_version")
14+
15+
base {
16+
archivesName.set(property("mod.id") as String)
2017
}
2118

22-
toolkitLoomHelper {
23-
useOneConfig {
24-
version = "1.0.0-alpha.153"
25-
loaderVersion = "1.1.0-alpha.49"
19+
repositories {
20+
maven("https://maven.parchmentmc.org")
21+
maven("https://repo.polyfrost.org/releases")
22+
maven("https://repo.polyfrost.org/snapshots")
23+
maven("https://maven.gegy.dev/releases")
24+
}
2625

27-
usePolyMixin = true
28-
polyMixinVersion = "0.8.4+build.2"
26+
loom {
27+
runConfigs.all {
28+
ideConfigGenerated(stonecutter.current.isActive)
29+
runDir = "../../run" // This sets the run folder for all mc versions to the same folder. Remove this line if you want individual run folders.
30+
}
2931

30-
applyLoaderTweaker = true
32+
runConfigs.remove(runConfigs["server"]) // Removes server run configs
33+
}
3134

32-
for (module in arrayOf("commands", "config", "config-impl", "events", "internal", "ui", "utils")) {
33-
+module
35+
dependencies {
36+
minecraft("com.mojang:minecraft:${property("minecraft_version")}")
37+
@Suppress("UnstableApiUsage")
38+
mappings(loom.layered {
39+
officialMojangMappings()
40+
optionalProp("${property("parchment_version")}") {
41+
parchment("org.parchmentmc.data:parchment-${property("minecraft_version")}:$it@zip")
3442
}
35-
}
36-
useDevAuth("1.2.1")
37-
useMixinExtras("0.4.1")
43+
optionalProp("${property("yalmm_version")}") {
44+
mappings("dev.lambdaurora:yalmm-mojbackward:${property("minecraft_version")}+build.$it")
45+
}
46+
})
47+
modImplementation("net.fabricmc:fabric-loader:${property("loader_version")}")
48+
modImplementation("org.polyfrost.oneconfig:${property("minecraft_version")}-fabric:1.0.0-alpha.181")
49+
modImplementation("org.polyfrost.oneconfig:commands:1.0.0-alpha.181")
50+
modImplementation("org.polyfrost.oneconfig:config:1.0.0-alpha.181")
51+
modImplementation("org.polyfrost.oneconfig:config-impl:1.0.0-alpha.181")
52+
modImplementation("org.polyfrost.oneconfig:events:1.0.0-alpha.181")
53+
modImplementation("org.polyfrost.oneconfig:internal:1.0.0-alpha.181")
54+
modImplementation("org.polyfrost.oneconfig:ui:1.0.0-alpha.181")
55+
modImplementation("org.polyfrost.oneconfig:utils:1.0.0-alpha.181")
56+
modImplementation("org.polyfrost.oneconfig:hud:1.0.0-alpha.181")
57+
58+
implementation("dev.deftu:commons-suncalc:0.1.0")!!
59+
}
3860

39-
// Turns off the server-side run configs, as we're building a client-sided mod.
40-
disableRunConfigs(GameSide.SERVER)
61+
bloom {
62+
replacement("@MOD_ID@", modid!!)
63+
replacement("@MOD_NAME@", modname!!)
64+
replacement("@MOD_VERSION@", modversion!!)
65+
}
4166

42-
// Defines the name of the Mixin refmap, which is used to map the Mixin classes to the obfuscated Minecraft classes.
43-
if (!mcData.isNeoForge) {
44-
useMixinRefMap(modData.id)
45-
}
67+
tasks.processResources {
68+
val props = mapOf(
69+
"mod_id" to modid,
70+
"mod_name" to modname,
71+
"mod_version" to modversion,
72+
"mc_version" to mcversion,
73+
"loader_version" to providers.gradleProperty("loader_version").get()
74+
)
4675

47-
if (mcData.isForge) {
48-
// Configures the Mixin tweaker if we are building for Forge.
49-
useForgeMixin(modData.id)
76+
inputs.properties(props)
77+
78+
filesMatching("fabric.mod.json") {
79+
expand(props)
5080
}
5181
}
5282

53-
dependencies {
54-
implementation(includeOrShade("dev.deftu:commons-suncalc:0.1.0")!!)
55-
56-
// Add Fabric Language Kotlin and (Legacy) Fabric API as dependencies (these are both optional but are particularly useful).
57-
if (mcData.isFabric) {
58-
if (mcData.isLegacyFabric) {
59-
// 1.8.9 - 1.13
60-
modImplementation("net.legacyfabric.legacy-fabric-api:legacy-fabric-api:${mcData.dependencies.legacyFabric.legacyFabricApiVersion}")
61-
} else {
62-
// 1.16.5+
63-
modImplementation("net.fabricmc.fabric-api:fabric-api:${mcData.dependencies.fabric.fabricApiVersion}")
64-
}
83+
tasks.withType<JavaCompile>().configureEach {
84+
options.release.set(21)
85+
}
86+
87+
tasks.withType<KotlinCompile>().configureEach {
88+
compilerOptions.jvmTarget.set(JvmTarget.JVM_21)
89+
}
90+
91+
java {
92+
withSourcesJar()
93+
sourceCompatibility = JavaVersion.VERSION_21
94+
targetCompatibility = JavaVersion.VERSION_21
95+
}
96+
97+
tasks.jar {
98+
inputs.property("archivesName", base.archivesName)
99+
100+
from("LICENSE") {
101+
rename { "${it}_${inputs.properties["archivesName"]}" }
65102
}
66103
}
104+
105+
fun <T> optionalProp(property: String, block: (String) -> T?): T? =
106+
findProperty(property)?.toString()?.takeUnless { it.isBlank() }?.let(block)
107+

gradle.properties

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1+
mod.name=PolyTime
2+
mod.id=polytime
3+
mod.version=1.1.0-alpha.2
4+
mod.group=org.polyfrost
5+
6+
loom_version=1.14-SNAPSHOT
7+
loader_version=0.18.4
8+
minecraft_version=[VERSIONED]
9+
parchment_version=[VERSIONED]
10+
yalmm_version=[VERSIONED]
11+
112
org.gradle.daemon=true
213
org.gradle.parallel=true
314
org.gradle.configureoncommand=true
415
org.gradle.parallel.threads=4
5-
org.gradle.jvmargs=-Xmx8G
6-
loom.ignoreDependencyLoomVersionValidation=true
16+
org.gradle.jvmargs=-Xmx2G
717

8-
mod.name=PolyTime
9-
mod.id=polytime
10-
mod.version=1.1.0-alpha.2
11-
mod.group=org.polyfrost
18+
# Fix YALMM
19+
fabric.loom.dropNonIntermediateRootMethods=true

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

root.gradle.kts

Lines changed: 0 additions & 52 deletions
This file was deleted.

settings.gradle.kts

Lines changed: 22 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,35 @@
1-
@file:Suppress("PropertyName")
2-
3-
import groovy.lang.MissingPropertyException
4-
51
pluginManagement {
62
repositories {
7-
// Releases
8-
maven("https://maven.deftu.dev/releases")
3+
mavenCentral()
4+
gradlePluginPortal()
95
maven("https://maven.fabricmc.net")
10-
maven("https://maven.architectury.dev/")
11-
maven("https://maven.minecraftforge.net")
12-
maven("https://repo.essential.gg/repository/maven-public")
13-
maven("https://server.bbkr.space/artifactory/libs-release/")
6+
maven("https://maven.kikugie.dev/snapshots")
7+
maven("https://maven.kikugie.dev/releases")
148
maven("https://jitpack.io/")
15-
16-
// Snapshots
9+
maven("https://maven.deftu.dev/releases")
1710
maven("https://maven.deftu.dev/snapshots")
18-
mavenLocal()
19-
20-
// Default
21-
gradlePluginPortal()
22-
mavenCentral()
23-
}
24-
25-
plugins {
26-
kotlin("jvm") version("2.2.10")
27-
id("dev.deftu.gradle.multiversion-root") version("2.55.0")
11+
maven("https://maven.architectury.dev")
12+
maven("https://repo.polyfrost.org/releases")
13+
maven("https://repo.polyfrost.org/snapshots")
2814
}
2915
}
3016

31-
val projectName: String = extra["mod.name"]?.toString()
32-
?: throw MissingPropertyException("mod.name has not been set.")
33-
34-
// Configures the root project Gradle name based on the value in `gradle.properties`
35-
rootProject.name = projectName
36-
rootProject.buildFileName = "root.gradle.kts"
37-
38-
// Adds all of our build target versions to the classpath if we need to add version-specific code.
39-
// Update this list if you want to remove/add a version and/or mod loader.
40-
// The format is: version-modloader (f.ex: 1.8.9-forge, 1.17.1-fabric, etc)
41-
// **REMEMBER TO ALSO UPDATE THE `root.gradle.kts` AND `build.gradle.kts` FILES WITH THE NEW VERSION(S).
42-
listOf(
43-
"1.8.9-forge",
44-
"1.8.9-fabric",
45-
46-
"1.12.2-forge",
47-
"1.12.2-fabric",
48-
49-
"1.16.5-forge",
50-
"1.16.5-fabric",
51-
52-
"1.20.1-forge",
53-
"1.20.1-fabric",
54-
55-
"1.20.4-forge",
56-
"1.20.4-neoforge",
57-
"1.20.4-fabric",
58-
59-
"1.21.1-neoforge",
60-
"1.21.1-fabric",
17+
plugins {
18+
id("dev.kikugie.stonecutter") version "0.7.10"
19+
}
6120

62-
"1.21.4-neoforge",
63-
"1.21.4-fabric",
21+
stonecutter {
22+
create(rootProject) {
23+
versions("1.21.1", "1.21.4", "1.21.8", "1.21.10")
6424

65-
"1.21.5-neoforge",
66-
"1.21.5-fabric",
25+
vcsVersion = "1.21.10"
26+
}
27+
}
6728

68-
"1.21.8-neoforge",
69-
"1.21.8-fabric",
70-
).forEach { version ->
71-
include(":$version")
72-
project(":$version").apply {
73-
projectDir = file("versions/$version")
74-
buildFileName = "../../build.gradle.kts"
29+
dependencyResolutionManagement {
30+
versionCatalogs {
31+
create("libs")
7532
}
7633
}
34+
35+
rootProject.name = "PolyTime"
Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
11
package org.polyfrost.polytime.mixin;
22

3-
import net.minecraft.client.multiplayer.WorldClient;
4-
import net.minecraft.client.renderer.RenderGlobal;
3+
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
4+
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
5+
import net.minecraft.client.multiplayer.ClientLevel;
6+
import net.minecraft.client.renderer.LevelRenderer;
7+
//? if >= 1.21.10
8+
import net.minecraft.client.renderer.SkyRenderer;
59
import org.polyfrost.polytime.client.PolyTimeConfig;
610
import org.polyfrost.polytime.client.realtime.RealTimeHandler;
711
import org.spongepowered.asm.mixin.Mixin;
812
import org.spongepowered.asm.mixin.injection.At;
9-
import org.spongepowered.asm.mixin.injection.Redirect;
1013

11-
@Mixin(RenderGlobal.class)
14+
//? if >= 1.21.10 {
15+
@Mixin(SkyRenderer.class)
16+
//?} else {
17+
/*@Mixin(LevelRenderer.class)
18+
*///?}
1219
public class Mixin_FixMoonPhases {
13-
@Redirect(method = "renderSky(FI)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/WorldClient;getMoonPhase()I"))
14-
private int polyweather$fixMoonPhase(WorldClient world) {
15-
if (PolyTimeConfig.isEnabled() && PolyTimeConfig.isIrlTime()) {
20+
@WrapOperation(method = /*? if >= 1.21.10 {*/ "extractRenderState" /*?} else if >= 1.21.4 {*/ /*"method_62215" *//*?} else {*/ /*"renderSky" *//*?}*/ , at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/ClientLevel;getMoonPhase()I"))
21+
private int polyweather$fixMoonPhase(ClientLevel instance, Operation<Integer> original) {
22+
if (PolyTimeConfig.isEnabled() && PolyTimeConfig.isIrlTime()) { // TODO: use irlLunarPhases instead?
1623
return RealTimeHandler.getCurrentLunarPhase();
1724
}
1825

19-
return world.getMoonPhase();
26+
return original.call(instance);
2027
}
21-
}
28+
}

0 commit comments

Comments
 (0)