diff options
author | Linnea Gräf <nea@nea.moe> | 2024-03-31 22:08:44 +0200 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-03-31 22:08:44 +0200 |
commit | 8d32601d891cefe11e3e261343e84aab1a40c341 (patch) | |
tree | 4ec227b83fe4538cab72abe1648691e2cc48d149 | |
parent | 0414b87e02e51b51cf9ef0c165e5ed61e5193160 (diff) | |
download | veloxcaelo-8d32601d891cefe11e3e261343e84aab1a40c341.tar.gz veloxcaelo-8d32601d891cefe11e3e261343e84aab1a40c341.tar.bz2 veloxcaelo-8d32601d891cefe11e3e261343e84aab1a40c341.zip |
Add config ui
-rw-r--r-- | build.gradle.kts | 32 | ||||
-rw-r--r-- | buildSrc/src/FixMixins.kt | 23 | ||||
-rw-r--r-- | src/main/java/moe/nea/caelo/Caelo.kt | 9 | ||||
-rw-r--r-- | src/main/java/moe/nea/caelo/CaeloCommand.kt | 3 | ||||
-rw-r--r-- | src/main/java/moe/nea/caelo/config/CConfig.kt | 12 | ||||
-rw-r--r-- | src/main/java/moe/nea/caelo/config/ConfigData.kt | 20 | ||||
-rw-r--r-- | src/main/java/moe/nea/caelo/config/OptiCache.kt | 13 | ||||
-rw-r--r-- | src/main/java/moe/nea/caelo/optifine/OptifineCustomItemCache.kt | 3 |
8 files changed, 98 insertions, 17 deletions
diff --git a/build.gradle.kts b/build.gradle.kts index 45bdb49..ae55296 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,6 +3,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { kotlin("jvm") version "1.9.22" `maven-publish` + id("com.github.johnrengelman.shadow") version "7.1.2" id("xyz.wagyourtail.unimined") version "1.2.0-SNAPSHOT" } @@ -12,6 +13,7 @@ version = "1.0-SNAPSHOT" repositories { maven("https://jitpack.io") maven("https://repo.polyfrost.cc/releases") + maven("https://maven.notenoughupdates.org/releases/") mavenCentral() } @@ -27,7 +29,10 @@ unimined.minecraft { } runs { this.config("client") { - this.args.addAll(listOf("--tweakClass", "org.spongepowered.asm.launch.MixinTweaker")) + this.args.addAll(listOf( + "--tweakClass", "org.spongepowered.asm.launch.MixinTweaker", + "--tweakClass", "io.github.notenoughupdates.moulconfig.tweaker.DevelopmentResourceTweaker", + )) this.env.put( "LD_LIBRARY_PATH", ":/nix/store/agp6lqznayysqvqkx4k1ggr8n1rsyi8c-gcc-13.2.0-lib/lib:/nix/store/ldi0rb00gmbdg6915lhch3k3b3ib460z-libXcursor-1.2.2/lib:/nix/store/8xbbv82pabjcbj30vrna4gcz4g9q97z4-libXrandr-1.5.4/lib:/nix/store/smrb2g0addhgahkfjjl3k8rfd30gdc29-libXxf86vm-1.1.5/lib:/nix/store/lpqy1z1h8li6h3cp9ax6vifl71dks1ff-libglvnd-1.7.0/lib" @@ -51,10 +56,17 @@ val downloadOptifine by tasks.creating { } } } +val shadowModImpl by configurations.creating { + configurations.named("modImplementation").get().extendsFrom(this) +} +val shadowImpl by configurations.creating { + configurations.implementation.get().extendsFrom(this) +} dependencies { testImplementation("org.jetbrains.kotlin:kotlin-test") - implementation("org.spongepowered:mixin:0.7.11-SNAPSHOT") + shadowImpl("org.spongepowered:mixin:0.7.11-SNAPSHOT") + shadowModImpl("org.notenoughupdates.moulconfig:legacy:3.0.0-beta.5") compileOnly(project.files(downloadOptifine)) compileOnly("org.jetbrains:annotations:24.1.0") } @@ -69,11 +81,7 @@ sourceSets.main { } tasks.processResources { filesMatching("*.mixins.json") { - this.filter( - mapOf("sourceRoots" to sourceSets.main.get().allSource.srcDirs - .filter { it.exists() }.joinToString(":") { it.absolutePath }), - MixinFilterReader::class.java - )//TODO: keep old existing class names in mixins array + this.autoDiscoverMixins(sourceSets.main.get()) } } @@ -104,4 +112,12 @@ tasks.withType(Jar::class) { this["TweakClass"] = "org.spongepowered.asm.launch.MixinTweaker" this["MixinConfigs"] = "veloxcaelo.mixins.json" } -}
\ No newline at end of file +} + + +tasks.shadowJar { + archiveClassifier.set("dep-dev") + configurations = listOf(shadowImpl, shadowModImpl) + relocate("io.github.notenoughupdates.moulconfig","moe.nea.velox.moulconfig") + mergeServiceFiles() +} diff --git a/buildSrc/src/FixMixins.kt b/buildSrc/src/FixMixins.kt index ea5f031..f662290 100644 --- a/buildSrc/src/FixMixins.kt +++ b/buildSrc/src/FixMixins.kt @@ -1,22 +1,23 @@ -import com.google.gson.Gson +import com.google.gson.GsonBuilder import com.google.gson.JsonArray import com.google.gson.JsonObject import com.google.gson.JsonPrimitive import org.apache.tools.ant.filters.BaseParamFilterReader +import org.gradle.api.file.FileCopyDetails +import org.gradle.api.tasks.SourceSet import java.io.File import java.io.Reader import java.io.StringReader class MixinFilterReader(reader: Reader) : BaseParamFilterReader() { - lateinit var sourceRoots: String + lateinit var sourceRoots: Collection<File> + val gson = GsonBuilder().setPrettyPrinting().create() val betterReader: StringReader by lazy { StringReader(run { - val json = Gson().fromJson(reader.readText(), JsonObject::class.java) + val json = gson.fromJson(reader.readText(), JsonObject::class.java) val mixinPackage = (json["package"] as JsonPrimitive).asString - val allMixins = JsonArray() + val allMixins = (json["mixins"] as JsonArray?)?.map { it.asString }?.toMutableSet() ?: mutableSetOf() sourceRoots - .split(":") - .map { File(it) } .forEach { base -> base.walk() .filter { it.isFile } @@ -31,8 +32,10 @@ class MixinFilterReader(reader: Reader) : BaseParamFilterReader() { ) } } - json.add("mixins", allMixins) - Gson().toJson(json) + json.add("mixins", JsonArray().also { jsonAllMixins -> + allMixins.forEach { jsonAllMixins.add(it) } + }) + gson.toJson(json) }) } @@ -41,3 +44,7 @@ class MixinFilterReader(reader: Reader) : BaseParamFilterReader() { return betterReader.read() } } + +fun FileCopyDetails.autoDiscoverMixins(sourceSet: SourceSet) { + filter(mapOf("sourceRoots" to sourceSet.allSource.srcDirs), MixinFilterReader::class.java) +} diff --git a/src/main/java/moe/nea/caelo/Caelo.kt b/src/main/java/moe/nea/caelo/Caelo.kt index 76e56bf..f39a08e 100644 --- a/src/main/java/moe/nea/caelo/Caelo.kt +++ b/src/main/java/moe/nea/caelo/Caelo.kt @@ -6,6 +6,7 @@ import moe.nea.caelo.optifine.OptifineCustomItemCache import moe.nea.caelo.util.InterModUtil import moe.nea.caelo.util.MC import net.minecraft.client.Minecraft +import net.minecraft.client.gui.GuiScreen import net.minecraftforge.client.ClientCommandHandler import net.minecraftforge.common.MinecraftForge import net.minecraftforge.fml.common.Mod @@ -23,6 +24,14 @@ class Caelo { if (Minecraft.getMinecraft().thePlayer == null) return MinecraftForge.EVENT_BUS.post(NeaTickEvent(tickCount++)) + if (toOpen != null) { + Minecraft.getMinecraft().displayGuiScreen(toOpen) + toOpen = null + } + } + + companion object { + var toOpen: GuiScreen? = null } var tickCount = 0 diff --git a/src/main/java/moe/nea/caelo/CaeloCommand.kt b/src/main/java/moe/nea/caelo/CaeloCommand.kt index b5a1688..e355540 100644 --- a/src/main/java/moe/nea/caelo/CaeloCommand.kt +++ b/src/main/java/moe/nea/caelo/CaeloCommand.kt @@ -1,5 +1,6 @@ package moe.nea.caelo +import moe.nea.caelo.config.CConfig import moe.nea.caelo.util.MC import net.minecraft.command.CommandBase import net.minecraft.command.ICommandSender @@ -41,7 +42,7 @@ object CaeloCommand : CommandBase() { override fun processCommand(iCommandSender: ICommandSender?, args: Array<String>) { if (args.isEmpty()) { - MC.display("§cMissing subcommand. Check the tab completions.") + Caelo.toOpen = CConfig.managed.getGui() return } val subCommand = subcommands[args[0]] diff --git a/src/main/java/moe/nea/caelo/config/CConfig.kt b/src/main/java/moe/nea/caelo/config/CConfig.kt new file mode 100644 index 0000000..25deb26 --- /dev/null +++ b/src/main/java/moe/nea/caelo/config/CConfig.kt @@ -0,0 +1,12 @@ +package moe.nea.caelo.config + +import io.github.notenoughupdates.moulconfig.managed.ManagedConfig +import java.io.File + +object CConfig { + val managed = ManagedConfig.create( + File("veloxcaelo/config.json").absoluteFile, + ConfigData::class.java + ) + val config get() = managed.instance +}
\ No newline at end of file diff --git a/src/main/java/moe/nea/caelo/config/ConfigData.kt b/src/main/java/moe/nea/caelo/config/ConfigData.kt new file mode 100644 index 0000000..aaaccce --- /dev/null +++ b/src/main/java/moe/nea/caelo/config/ConfigData.kt @@ -0,0 +1,20 @@ +package moe.nea.caelo.config + +import com.google.gson.annotations.Expose +import io.github.notenoughupdates.moulconfig.Config +import io.github.notenoughupdates.moulconfig.annotations.Category + +class ConfigData : Config() { + + @Category(name = "OptiCache", desc = "Optifine speed improvements") + @JvmField + @Expose + val optiCache = OptiCache() + override fun saveNow() { + CConfig.managed.saveToFile() + } + + override fun getTitle(): String { + return "§bVelox Caelo§7 by §anea89" + } +}
\ No newline at end of file diff --git a/src/main/java/moe/nea/caelo/config/OptiCache.kt b/src/main/java/moe/nea/caelo/config/OptiCache.kt new file mode 100644 index 0000000..365ce2d --- /dev/null +++ b/src/main/java/moe/nea/caelo/config/OptiCache.kt @@ -0,0 +1,13 @@ +package moe.nea.caelo.config + +import com.google.gson.annotations.Expose +import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean +import io.github.notenoughupdates.moulconfig.annotations.ConfigOption + +class OptiCache { + @ConfigEditorBoolean + @ConfigOption(name = "Enable CIT cache", desc = "Cache CIT property lookups") + @Expose + @JvmField + var citCache = true +} diff --git a/src/main/java/moe/nea/caelo/optifine/OptifineCustomItemCache.kt b/src/main/java/moe/nea/caelo/optifine/OptifineCustomItemCache.kt index 0bd6d78..ffe6627 100644 --- a/src/main/java/moe/nea/caelo/optifine/OptifineCustomItemCache.kt +++ b/src/main/java/moe/nea/caelo/optifine/OptifineCustomItemCache.kt @@ -1,6 +1,7 @@ package moe.nea.caelo.optifine import moe.nea.caelo.CaeloCommand +import moe.nea.caelo.config.CConfig import moe.nea.caelo.event.NeaTickEvent import moe.nea.caelo.util.Histogram import moe.nea.caelo.util.MC @@ -56,6 +57,8 @@ object OptifineCustomItemCache { type: Int, cir: CallbackInfoReturnable<CustomItemProperties?> ) { + if (!CConfig.config.optiCache.citCache) + return val key = CacheKey(itemStack, type) if (!map.containsKey(key)) { cacheStats.cacheMisses++ |