Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 89 additions & 48 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,66 +1,107 @@
@file:Suppress("UnstableApiUsage", "PropertyName")

import dev.deftu.gradle.utils.GameSide
import dev.deftu.gradle.utils.includeOrShade
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
java
kotlin("jvm")
id("dev.deftu.gradle.multiversion") // Applies preprocessing for multiple versions of Minecraft and/or multiple mod loaders.
id("dev.deftu.gradle.tools") // Applies several configurations to things such as the Java version, project name/version, etc.
id("dev.deftu.gradle.tools.resources") // Applies resource processing so that we can replace tokens, such as our mod name/version, in our resources.
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.
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!
id("dev.deftu.gradle.tools.minecraft.loom") // Applies the Loom plugin, which automagically configures Essential's Architectury Loom plugin for you.
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.
id("net.fabricmc.fabric-loom-remap") version "1.14-SNAPSHOT"
id("org.jetbrains.kotlin.jvm") version "2.3.0"
id("dev.deftu.gradle.bloom") version "0.2.0"
}

toolkitMultiversion {
moveBuildsToRootProject = true
val modid = property("mod.id")
val modname = property("mod.name")
val modversion = property("mod.version")
val mcversion = property("minecraft_version")

base {
archivesName.set(property("mod.id") as String)
}

toolkitLoomHelper {
useOneConfig {
version = "1.0.0-alpha.153"
loaderVersion = "1.1.0-alpha.49"
repositories {
maven("https://maven.parchmentmc.org")
maven("https://repo.polyfrost.org/releases")
maven("https://repo.polyfrost.org/snapshots")
maven("https://maven.gegy.dev/releases")
}

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

applyLoaderTweaker = true
runConfigs.remove(runConfigs["server"]) // Removes server run configs
}

for (module in arrayOf("commands", "config", "config-impl", "events", "internal", "ui", "utils")) {
+module
dependencies {
minecraft("com.mojang:minecraft:${property("minecraft_version")}")
@Suppress("UnstableApiUsage")
mappings(loom.layered {
officialMojangMappings()
optionalProp("${property("parchment_version")}") {
parchment("org.parchmentmc.data:parchment-${property("minecraft_version")}:$it@zip")
}
}
useDevAuth("1.2.1")
useMixinExtras("0.4.1")
optionalProp("${property("yalmm_version")}") {
mappings("dev.lambdaurora:yalmm-mojbackward:${property("minecraft_version")}+build.$it")
}
})
modImplementation("net.fabricmc:fabric-loader:${property("loader_version")}")
modImplementation("org.polyfrost.oneconfig:${property("minecraft_version")}-fabric:1.0.0-alpha.181")
modImplementation("org.polyfrost.oneconfig:commands:1.0.0-alpha.181")
modImplementation("org.polyfrost.oneconfig:config:1.0.0-alpha.181")
modImplementation("org.polyfrost.oneconfig:config-impl:1.0.0-alpha.181")
modImplementation("org.polyfrost.oneconfig:events:1.0.0-alpha.181")
modImplementation("org.polyfrost.oneconfig:internal:1.0.0-alpha.181")
modImplementation("org.polyfrost.oneconfig:ui:1.0.0-alpha.181")
modImplementation("org.polyfrost.oneconfig:utils:1.0.0-alpha.181")
modImplementation("org.polyfrost.oneconfig:hud:1.0.0-alpha.181")

implementation("dev.deftu:commons-suncalc:0.1.0")!!
}

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

// Defines the name of the Mixin refmap, which is used to map the Mixin classes to the obfuscated Minecraft classes.
if (!mcData.isNeoForge) {
useMixinRefMap(modData.id)
}
tasks.processResources {
val props = mapOf(
"mod_id" to modid,
"mod_name" to modname,
"mod_version" to modversion,
"mc_version" to mcversion,
"loader_version" to providers.gradleProperty("loader_version").get()
)

if (mcData.isForge) {
// Configures the Mixin tweaker if we are building for Forge.
useForgeMixin(modData.id)
inputs.properties(props)

filesMatching("fabric.mod.json") {
expand(props)
}
}

dependencies {
implementation(includeOrShade("dev.deftu:commons-suncalc:0.1.0")!!)

// Add Fabric Language Kotlin and (Legacy) Fabric API as dependencies (these are both optional but are particularly useful).
if (mcData.isFabric) {
if (mcData.isLegacyFabric) {
// 1.8.9 - 1.13
modImplementation("net.legacyfabric.legacy-fabric-api:legacy-fabric-api:${mcData.dependencies.legacyFabric.legacyFabricApiVersion}")
} else {
// 1.16.5+
modImplementation("net.fabricmc.fabric-api:fabric-api:${mcData.dependencies.fabric.fabricApiVersion}")
}
tasks.withType<JavaCompile>().configureEach {
options.release.set(21)
}

tasks.withType<KotlinCompile>().configureEach {
compilerOptions.jvmTarget.set(JvmTarget.JVM_21)
}

java {
withSourcesJar()
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

tasks.jar {
inputs.property("archivesName", base.archivesName)

from("LICENSE") {
rename { "${it}_${inputs.properties["archivesName"]}" }
}
}

fun <T> optionalProp(property: String, block: (String) -> T?): T? =
findProperty(property)?.toString()?.takeUnless { it.isBlank() }?.let(block)

20 changes: 14 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
mod.name=PolyTime
mod.id=polytime
mod.version=1.1.0-alpha.2
mod.group=org.polyfrost

loom_version=1.14-SNAPSHOT
loader_version=0.18.4
minecraft_version=[VERSIONED]
parchment_version=[VERSIONED]
yalmm_version=[VERSIONED]

org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.configureoncommand=true
org.gradle.parallel.threads=4
org.gradle.jvmargs=-Xmx8G
loom.ignoreDependencyLoomVersionValidation=true
org.gradle.jvmargs=-Xmx2G

mod.name=PolyTime
mod.id=polytime
mod.version=1.1.0-alpha.2
mod.group=org.polyfrost
# Fix YALMM
fabric.loom.dropNonIntermediateRootMethods=true
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.11.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
52 changes: 0 additions & 52 deletions root.gradle.kts

This file was deleted.

85 changes: 22 additions & 63 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,76 +1,35 @@
@file:Suppress("PropertyName")

import groovy.lang.MissingPropertyException

pluginManagement {
repositories {
// Releases
maven("https://maven.deftu.dev/releases")
mavenCentral()
gradlePluginPortal()
maven("https://maven.fabricmc.net")
maven("https://maven.architectury.dev/")
maven("https://maven.minecraftforge.net")
maven("https://repo.essential.gg/repository/maven-public")
maven("https://server.bbkr.space/artifactory/libs-release/")
maven("https://maven.kikugie.dev/snapshots")
maven("https://maven.kikugie.dev/releases")
maven("https://jitpack.io/")

// Snapshots
maven("https://maven.deftu.dev/releases")
maven("https://maven.deftu.dev/snapshots")
mavenLocal()

// Default
gradlePluginPortal()
mavenCentral()
}

plugins {
kotlin("jvm") version("2.2.10")
id("dev.deftu.gradle.multiversion-root") version("2.55.0")
maven("https://maven.architectury.dev")
maven("https://repo.polyfrost.org/releases")
maven("https://repo.polyfrost.org/snapshots")
}
}

val projectName: String = extra["mod.name"]?.toString()
?: throw MissingPropertyException("mod.name has not been set.")

// Configures the root project Gradle name based on the value in `gradle.properties`
rootProject.name = projectName
rootProject.buildFileName = "root.gradle.kts"

// Adds all of our build target versions to the classpath if we need to add version-specific code.
// Update this list if you want to remove/add a version and/or mod loader.
// The format is: version-modloader (f.ex: 1.8.9-forge, 1.17.1-fabric, etc)
// **REMEMBER TO ALSO UPDATE THE `root.gradle.kts` AND `build.gradle.kts` FILES WITH THE NEW VERSION(S).
listOf(
"1.8.9-forge",
"1.8.9-fabric",

"1.12.2-forge",
"1.12.2-fabric",

"1.16.5-forge",
"1.16.5-fabric",

"1.20.1-forge",
"1.20.1-fabric",

"1.20.4-forge",
"1.20.4-neoforge",
"1.20.4-fabric",

"1.21.1-neoforge",
"1.21.1-fabric",
plugins {
id("dev.kikugie.stonecutter") version "0.7.10"
}

"1.21.4-neoforge",
"1.21.4-fabric",
stonecutter {
create(rootProject) {
versions("1.21.1", "1.21.4", "1.21.8", "1.21.10")

"1.21.5-neoforge",
"1.21.5-fabric",
vcsVersion = "1.21.10"
}
}

"1.21.8-neoforge",
"1.21.8-fabric",
).forEach { version ->
include(":$version")
project(":$version").apply {
projectDir = file("versions/$version")
buildFileName = "../../build.gradle.kts"
dependencyResolutionManagement {
versionCatalogs {
create("libs")
}
}

rootProject.name = "PolyTime"
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
package org.polyfrost.polytime.mixin;

import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.client.renderer.RenderGlobal;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.renderer.LevelRenderer;
//? if >= 1.21.10
import net.minecraft.client.renderer.SkyRenderer;
import org.polyfrost.polytime.client.PolyTimeConfig;
import org.polyfrost.polytime.client.realtime.RealTimeHandler;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(RenderGlobal.class)
//? if >= 1.21.10 {
@Mixin(SkyRenderer.class)
//?} else {
/*@Mixin(LevelRenderer.class)
*///?}
public class Mixin_FixMoonPhases {
@Redirect(method = "renderSky(FI)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/WorldClient;getMoonPhase()I"))
private int polyweather$fixMoonPhase(WorldClient world) {
if (PolyTimeConfig.isEnabled() && PolyTimeConfig.isIrlTime()) {
@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"))
private int polyweather$fixMoonPhase(ClientLevel instance, Operation<Integer> original) {
if (PolyTimeConfig.isEnabled() && PolyTimeConfig.isIrlTime()) { // TODO: use irlLunarPhases instead?
return RealTimeHandler.getCurrentLunarPhase();
}

return world.getMoonPhase();
return original.call(instance);
}
}
}
Loading