Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to 1.21.1 #384

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ bin/
# fabric

run/
.kotlin
97 changes: 0 additions & 97 deletions build.gradle

This file was deleted.

127 changes: 127 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
@file:Suppress("PropertyName")

import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

val minecraft_version: String by project
val yarn_version: String by project
val loader_version: String by project
val meteor_version: String by project
val baritone_version: String by project
val kotlin_loader_version: String by project

plugins {
kotlin("jvm") version "2.0.21"
id("fabric-loom") version "1.7-SNAPSHOT"
id("com.google.devtools.ksp") version "2.0.21-1.0.25"
}

version = project.property("mod_version") as String
group = project.property("maven_group") as String

base {
archivesName.set(project.property("archives_base_name") as String)
}

val targetJavaVersion = 21
java {
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
withSourcesJar()
}

repositories {
mavenCentral()
mavenLocal()
maven { url = uri("https://maven.meteordev.org/releases") }
maven { url = uri("https://maven.meteordev.org/snapshots") }
maven { url = uri("https://maven.seedfinding.com/") }
maven { url = uri("https://maven-snapshots.seedfinding.com/") }
maven { url = uri("https://jitpack.io") }
maven { url = uri("https://maven.duti.dev/releases") }
}

val extraLibs: Configuration by configurations.creating
configurations {
// configuration that holds jars to include in the jar
implementation {
extendsFrom(extraLibs)
}
}

dependencies {
// This will make it work on most platforms. It automatically chooses the right dependencies at runtime.
val cubiomesVersion = "dev.duti.acheong:cubiomes:1.22.3"
listOf("linux64", "osx", "windows64").forEach { os ->
extraLibs("$cubiomesVersion:$os") { isTransitive = false }
}
extraLibs(cubiomesVersion) { isTransitive = false }
// To change the versions see the gradle.properties file
minecraft("com.mojang:minecraft:$minecraft_version")
mappings("net.fabricmc:yarn:$yarn_version:v2")
modImplementation("net.fabricmc:fabric-loader:$loader_version")
modImplementation("net.fabricmc:fabric-language-kotlin:$kotlin_loader_version")

modImplementation("meteordevelopment:meteor-client:$meteor_version-SNAPSHOT")
modCompileOnly("meteordevelopment:baritone:$baritone_version-SNAPSHOT")

// seed .locate and ore sim
val seedFindingDependencies = setOf(
"com.seedfinding:mc_math:ffd2edcfcc0d18147549c88cc7d8ec6cf21b5b91",
"com.seedfinding:mc_seed:1ead6fcefe7e8de4b3d60cd6c4e993f1e8f33409",
"com.seedfinding:mc_core:d64d5f90be66300da41ef58f4f1736db2499784f",
"com.seedfinding:mc_noise:7e3ba65e181796c4a2a1c8881d840b2254b92962",
"com.seedfinding:mc_biome:41a42cb9019a552598f12089059538853e18ec78",
"com.seedfinding:mc_terrain:b4246cbd5880c4f8745ccb90e1b102bde3448126",
"com.seedfinding:mc_feature:919b7e513cc1e87e029a9cd703fc4e2dc8686229",
)
seedFindingDependencies.forEach { dependency ->
extraLibs(dependency) { isTransitive = false }
}
// seedcracker api
implementation("com.github.19MisterX98.SeedcrackerX:seedcrackerx-api:2.10.1") { isTransitive = false }
// implementation (include('com.github.19MisterX98.SeedcrackerX:seedcrackerx-api:master-SNAPSHOT')) {transitive = false}
ksp(project(":processor"))
}

loom {
accessWidenerPath = file("src/main/resources/meteor-rejects.accesswidener")
}

tasks.processResources {
inputs.property("version", project.version)
inputs.property("minecraft_version", minecraft_version)
inputs.property("loader_version", loader_version)
filteringCharset = "UTF-8"


filesMatching("fabric.mod.json") {
expand(
"version" to project.version,
"mc_version" to minecraft_version,
"gh_hash" to (System.getenv("GITHUB_SHA") ?: ""),
"kotlin_loader_version" to kotlin_loader_version,
)
}
}

tasks.jar {
from("LICENSE") {
rename { "${it}_${project.base.archivesName}" }
}
from(extraLibs.map { if (it.isDirectory) it else zipTree(it) })
}

tasks.withType<Jar>() {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}

tasks.withType<KotlinCompile>().configureEach {
compilerOptions.jvmTarget.set(JvmTarget.fromTarget(targetJavaVersion.toString()))
}

tasks.withType<JavaCompile>().configureEach {
options.encoding = "UTF-8"
if(JavaVersion.current().isJava9Compatible){
options.release.set(targetJavaVersion)
}
}
9 changes: 5 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx2G
org.gradle.jvmargs=-Xmx4G

# Fabric Properties
minecraft_version=1.21
yarn_version=1.21+build.2
minecraft_version=1.21.1
yarn_version=1.21.1+build.3
loader_version=0.15.11
kotlin_loader_version=1.12.3+kotlin.2.0.21

# Mod Properties
mod_version = 0.3
maven_group = anticope.rejects
archives_base_name = meteor-rejects-addon

meteor_version=0.5.8
baritone_version=1.20.6
baritone_version=1.21.1
15 changes: 15 additions & 0 deletions processor/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
plugins {
kotlin("jvm")
id("com.google.devtools.ksp")
}

group = "com.github.shu"
version = "0.0.1"

repositories {
mavenCentral()
}

dependencies {
implementation("com.google.devtools.ksp:symbol-processing-api:2.0.21-1.0.25")
}
46 changes: 46 additions & 0 deletions processor/src/main/kotlin/com/github/shu/AutoRegisterProcessor.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.github.shu

import com.google.devtools.ksp.getConstructors
import com.google.devtools.ksp.processing.*
import com.google.devtools.ksp.symbol.KSAnnotated
import com.google.devtools.ksp.symbol.KSClassDeclaration

/**
* A KSP (Kotlin Symbol Processing) processor that processes class annotated with `@AutoRegister`.
* This processor checks if the annotated classes have a no-argument constructor or if all their
* constructor parameters hava default values. If neither condition is met, an error is logged.
*
* @param logger The KSP logger used for logging errors during processing.
*/
class AutoRegisterProcessor(private val logger: KSPLogger) : SymbolProcessor {

override fun process(resolver: Resolver): List<KSAnnotated> {
val autoRegisterClasses = resolver.getSymbolsWithAnnotation("anticope.rejects.annotation.AutoRegister")
autoRegisterClasses.forEach { classSymbol ->
if (classSymbol is KSClassDeclaration) {
validateClass(classSymbol)
}
}
return emptyList()
}

private fun validateClass(classSymbol: KSClassDeclaration) {
val constructors = classSymbol.getConstructors()
val hasDefaultConstructor = constructors.any { constructor ->
constructor.parameters.isEmpty() || constructor.parameters.all { it.hasDefault }
}
if (!hasDefaultConstructor) {
val message =
"${classSymbol.simpleName.asString()} must have a no-arg constructor or " +
"all parameters must have default values"
logger.error(message)
}
}
}

class AutoRegisterProcessorProvider : SymbolProcessorProvider {

override fun create(environment: SymbolProcessorEnvironment): SymbolProcessor {
return AutoRegisterProcessor(environment.logger)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
com.github.shu.AutoRegisterProcessorProvider
9 changes: 0 additions & 9 deletions settings.gradle

This file was deleted.

10 changes: 10 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
pluginManagement {
repositories {
maven("https://maven.fabricmc.net/") {
name = "Fabric"
}
gradlePluginPortal()
google()
}
}
include("processor")
Loading
Loading