aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-03-31 22:08:44 +0200
committerLinnea Gräf <nea@nea.moe>2024-03-31 22:08:44 +0200
commit8d32601d891cefe11e3e261343e84aab1a40c341 (patch)
tree4ec227b83fe4538cab72abe1648691e2cc48d149 /src/main
parent0414b87e02e51b51cf9ef0c165e5ed61e5193160 (diff)
downloadveloxcaelo-8d32601d891cefe11e3e261343e84aab1a40c341.tar.gz
veloxcaelo-8d32601d891cefe11e3e261343e84aab1a40c341.tar.bz2
veloxcaelo-8d32601d891cefe11e3e261343e84aab1a40c341.zip
Add config ui
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/moe/nea/caelo/Caelo.kt9
-rw-r--r--src/main/java/moe/nea/caelo/CaeloCommand.kt3
-rw-r--r--src/main/java/moe/nea/caelo/config/CConfig.kt12
-rw-r--r--src/main/java/moe/nea/caelo/config/ConfigData.kt20
-rw-r--r--src/main/java/moe/nea/caelo/config/OptiCache.kt13
-rw-r--r--src/main/java/moe/nea/caelo/optifine/OptifineCustomItemCache.kt3
6 files changed, 59 insertions, 1 deletions
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++