Skip to content

Commit

Permalink
multiversion (almost) and yarn in one commit?!
Browse files Browse the repository at this point in the history
  • Loading branch information
not-coded committed Dec 7, 2024
1 parent 8c3e78b commit 20d2f3b
Show file tree
Hide file tree
Showing 30 changed files with 445 additions and 295 deletions.
3 changes: 2 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# What's changed?
- moved to stonecutter (backend rewrite)
- moved to stonecutter (backend rewrite)
- multiple versions now supported
5 changes: 3 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# to-do
- [ ] add versions 1.16.5, 1.17.1, 1.18.2, 1.19.4, 1.21, etc.
- [x] add versions 1.16.5, 1.17.1, 1.18.2, 1.19.4, 1.21, etc.
- [ ] test if every version works (create a test mod)
- [ ] perhaps add a config with cool customizability thing
- [ ] [use simple structuring like with autoconfig](https://shedaniel.gitbook.io/cloth-config/auto-config/creating-a-config-class)
- [use simple structuring like with autoconfig](https://shedaniel.gitbook.io/cloth-config/auto-config/creating-a-config-class)
- [ ] add java docs as a github page
- [ ] fix maven
- [ ] possibly use annotations in mixins to specify which version they should be run on? (possibly with the help of mixin plugins)?
Expand Down
146 changes: 0 additions & 146 deletions build.gradle

This file was deleted.

101 changes: 101 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import org.gradle.internal.impldep.org.apache.http.client.methods.RequestBuilder.options

plugins {
id("fabric-loom") version "1.9.2"
id("com.modrinth.minotaur") version "2.+"
id("net.ltgt.errorprone") version "4.1.0"
id("maven-publish")
}

val modName = property("mod.name").toString()
version = "${property("mod.version")}" + "+" + "${property("mod.version_name")}"
group = property("mod.maven_group").toString()

base {
archivesName.set(modName)
}

dependencies {
minecraft("com.mojang:minecraft:${property("deps.minecraft")}")
mappings("net.fabricmc:yarn:${property("deps.yarn_mappings")}:v2")
modImplementation("net.fabricmc:fabric-loader:${property("deps.fabric_loader")}")

errorprone("com.google.errorprone:error_prone_core:${property("deps.errorprone")}")
}

loom {
decompilers {
get("vineflower").apply { // Adds names to lambdas - useful for mixins
options.put("mark-corresponding-synthetics", "1")
}
}

runConfigs.all {
ideConfigGenerated(true)
vmArgs("-Dmixin.debug.export=true")
runDir = "../../run"
}
}

val target = ">=${property("mod.min_target")}- <=${property("mod.max_target")}"

tasks.processResources {
val expandProps = mapOf(
"version" to project.version,
"minecraftVersion" to target,
"javaVersion" to project.property("deps.java")
)

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

inputs.properties(expandProps)
}

java {
withSourcesJar()
withJavadocJar()

val javaVersion = if (project.property("deps.java") == "8") JavaVersion.VERSION_1_8 else JavaVersion.VERSION_17

sourceCompatibility = javaVersion
targetCompatibility = javaVersion
}


tasks.withType<JavaCompile> {
options.encoding = "UTF-8"

// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
options.release.set(Integer.parseInt(project.property("deps.java").toString()))

// Fixes Error Prone INIT policy
options.compilerArgs.add("--should-stop=ifError=FLOW")
}

tasks.register<Copy>("buildAndCollect") {
group = "build"
from(tasks.remapJar.get().archiveFile)
into(rootProject.layout.buildDirectory.file("libs"))
dependsOn("build")
}

modrinth {
token.set(System.getenv("MODRINTH_TOKEN"))
projectId.set("wayfix")
versionNumber.set(version.toString())
versionName.set("v$version")
versionType.set("release")
uploadFile.set(tasks.remapJar)
gameVersions.addAll(property("publishing.supported_versions").toString().split(","))
loaders.addAll("fabric", "quilt")
//featured = true

dependencies {
required.project("cloth-config")
optional.project("modmenu")
}

changelog = rootProject.file("CHANGES.md").readText()
}
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
#org.gradle.parallel=true
org.gradle.caching=true
org.gradle.caching.debug=false

mod.version=2.0.0
mod.name=codelib
Expand All @@ -13,6 +11,8 @@ mod.version_name=[VERSIONED]
mod.min_target=[VERSIONED]
mod.max_target=[VERSIONED]

publishing.supported_versions=[VERSIONED]

# Dependencies
# https://fabricmc.net/develop
deps.yarn=[VERSIONED]
Expand Down
24 changes: 0 additions & 24 deletions settings.gradle

This file was deleted.

26 changes: 26 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
pluginManagement {
repositories {
maven("https://maven.fabricmc.net/")

gradlePluginPortal()
maven("https://maven.kikugie.dev/snapshots")
}
}

plugins {
id("dev.kikugie.stonecutter") version "0.5-beta.5"
}

stonecutter {
kotlinController = true
centralScript = "build.gradle.kts"

shared {
versions("1.16.5", "1.17.1", "1.18.2", "1.19.4", "1.20.1", "1.21")
vcsVersion = "1.21"
}

create(rootProject)
}

rootProject.name = "codelib"
4 changes: 4 additions & 0 deletions src/main/java/net/notcoded/codelib/CodeLib.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
package net.notcoded.codelib;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public class CodeLib {
public static final Logger LOGGER = LogManager.getLogger(CodeLib.class);
}
6 changes: 3 additions & 3 deletions src/main/java/net/notcoded/codelib/client/CodeLibClient.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package net.notcoded.codelib.client;

import net.fabricmc.api.ClientModInitializer;
import net.minecraft.client.Minecraft;
import net.minecraft.client.MinecraftClient;

public class CodeLibClient implements ClientModInitializer {
public static Minecraft client;
public static MinecraftClient client;

@Override
public void onInitializeClient() {
client = Minecraft.getInstance();
client = MinecraftClient.getInstance();
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package net.notcoded.codelib.common.minecraft;

import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import net.notcoded.codelib.common.util.http.HttpAPI;
import org.jetbrains.annotations.NotNull;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Locale;
Expand Down Expand Up @@ -45,7 +42,7 @@ public static String getUUID(String name) {
return uuid;
}

return response;
return null;
}

/**
Expand All @@ -55,6 +52,7 @@ public static String getUUID(String name) {
*/

public static String getName(String uuid) {
if(!(uuid.length() == 32) && !(uuid.length() == 36)) return null;
if (cachedNames.containsKey(uuid.toLowerCase(Locale.ROOT))) return cachedNames.get(uuid.toLowerCase(Locale.ROOT));

String response;
Expand Down
Loading

0 comments on commit 20d2f3b

Please sign in to comment.