aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com/dulkirfabric
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/com/dulkirfabric')
-rw-r--r--src/main/kotlin/com/dulkirfabric/Registrations.kt11
-rw-r--r--src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt16
-rw-r--r--src/main/kotlin/com/dulkirfabric/config/ListHelper.kt10
-rw-r--r--src/main/kotlin/com/dulkirfabric/events/WorldLoadEvent.kt (renamed from src/main/kotlin/com/dulkirfabric/events/ServerTickEvent.kt)4
4 files changed, 22 insertions, 19 deletions
diff --git a/src/main/kotlin/com/dulkirfabric/Registrations.kt b/src/main/kotlin/com/dulkirfabric/Registrations.kt
index b221971..1d99640 100644
--- a/src/main/kotlin/com/dulkirfabric/Registrations.kt
+++ b/src/main/kotlin/com/dulkirfabric/Registrations.kt
@@ -4,12 +4,8 @@ import com.dulkirfabric.DulkirModFabric.EVENT_BUS
import com.dulkirfabric.commands.ConfigCommand
import com.dulkirfabric.commands.JoinDungeonCommands
import com.dulkirfabric.events.ClientTickEvent
-import com.dulkirfabric.events.ServerTickEvent
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents
-import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents
-import net.minecraft.server.MinecraftServer
-import net.minecraft.util.profiling.jfr.event.WorldLoadFinishedEvent
/**
@@ -42,13 +38,10 @@ object Registrations {
}
fun registerEvents() {
- // Register Custom Tick events so we can use them like 1.8.9 forge
- ServerTickEvents.START_SERVER_TICK.register(
- ServerTickEvents.StartTick { _ -> EVENT_BUS.post(ServerTickEvent.get()) }
- )
+ // Register Custom Tick event, so we can use it like 1.8.9 forge
ClientTickEvents.START_CLIENT_TICK.register(
ClientTickEvents.StartTick { _ -> EVENT_BUS.post(ClientTickEvent.get()) }
)
- // WorldLoadFinishedEvent
+ // WorldLoadFinishedEvent TODO
}
} \ No newline at end of file
diff --git a/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt b/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt
index 4f3c328..9aeb190 100644
--- a/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt
+++ b/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt
@@ -14,13 +14,14 @@
package com.dulkirfabric.config
import com.dulkirfabric.DulkirModFabric.mc
-import com.dulkirfabric.config.ListHelper.mkIntField
+import com.dulkirfabric.config.ListHelper.mkKeyField
import com.dulkirfabric.config.ListHelper.mkStringField
import com.google.gson.Gson
import kotlinx.serialization.Serializable
import me.shedaniel.cloth.clothconfig.shadowed.blue.endless.jankson.annotation.SerializedName
import me.shedaniel.clothconfig2.api.ConfigBuilder
import net.minecraft.client.gui.screen.Screen
+import net.minecraft.client.util.InputUtil
import net.minecraft.text.LiteralTextContent
import net.minecraft.text.MutableText
import net.minecraft.text.Text
@@ -51,22 +52,23 @@ class DulkirConfig {
.build()
)
general.addEntry(
- entryBuilder.startFloatField(Text.literal("Inventory Scale"), inventoryScale)
+ entryBuilder.startIntSlider(Text.literal("Inventory Scale"), inventoryScale, 1, 5)
.setTooltip(Text.literal("Size of GUI whenever you're in an inventory screen"))
.setSaveConsumer { newValue -> inventoryScale = newValue }
.build()
)
+
val shortcuts = builder.getOrCreateCategory(Text.literal("Shortcuts"))
shortcuts.addEntry(
ListHelper.mkConfigList(
Text.literal("Macros"),
ListHelper.Holder::macros,
- { Macro(-2, "") },
+ { Macro(InputUtil.UNKNOWN_KEY, "") },
Text.literal("Macro"),
{ value ->
listOf(
entryBuilder.mkStringField(Text.literal("Command"), value::command),
- entryBuilder.mkIntField(Text.literal("KeyBinding"), value::keyBinding)
+ entryBuilder.mkKeyField(Text.literal("KeyBinding"), value::keyBinding)
)
}
)
@@ -81,12 +83,12 @@ class DulkirConfig {
val invScaleBool: Boolean,
@SerializedName("inventoryScale")
- val inventoryScale: Float
+ val inventoryScale: Int
)
@Serializable
data class Macro(
- var keyBinding: Int,
+ var keyBinding: InputUtil.Key,
var command: String,
)
@@ -95,7 +97,7 @@ class DulkirConfig {
*/
companion object ConfigVars {
var invScaleBool: Boolean = true
- var inventoryScale: Float = 1f
+ var inventoryScale: Int = 1
var value: List<Pair<Int, Int>> = listOf(Pair(1, 2), Pair(3, 4))
diff --git a/src/main/kotlin/com/dulkirfabric/config/ListHelper.kt b/src/main/kotlin/com/dulkirfabric/config/ListHelper.kt
index b99787f..3476bcc 100644
--- a/src/main/kotlin/com/dulkirfabric/config/ListHelper.kt
+++ b/src/main/kotlin/com/dulkirfabric/config/ListHelper.kt
@@ -4,6 +4,7 @@ import me.shedaniel.clothconfig2.api.AbstractConfigListEntry
import me.shedaniel.clothconfig2.api.ConfigEntryBuilder
import me.shedaniel.clothconfig2.gui.entries.MultiElementListEntry
import me.shedaniel.clothconfig2.gui.entries.NestedListListEntry
+import net.minecraft.client.util.InputUtil
import net.minecraft.text.Text
import java.util.*
import kotlin.reflect.KMutableProperty0
@@ -35,13 +36,20 @@ object ListHelper {
}
object Holder {
- var macros = listOf(DulkirConfig.Macro(-1, "Hello World"))
+ var macros = listOf(DulkirConfig.Macro(InputUtil.UNKNOWN_KEY, "Hello World"))
}
fun ConfigEntryBuilder.mkStringField(text: Text, prop: KMutableProperty0<String>) = startStrField(text, prop.get())
.setSaveConsumer { prop.set(it) }
+ .setDefaultValue("")
.build()
fun ConfigEntryBuilder.mkIntField(text: Text, prop: KMutableProperty0<Int>) = startIntField(text, prop.get())
.setSaveConsumer { prop.set(it) }
+ .setDefaultValue(0)
+ .build()
+
+ fun ConfigEntryBuilder.mkKeyField(text: Text, prop: KMutableProperty0<InputUtil.Key>) = startKeyCodeField(text, prop.get())
+ .setKeySaveConsumer { prop.set(it) }
+ .setDefaultValue(InputUtil.UNKNOWN_KEY)
.build()
} \ No newline at end of file
diff --git a/src/main/kotlin/com/dulkirfabric/events/ServerTickEvent.kt b/src/main/kotlin/com/dulkirfabric/events/WorldLoadEvent.kt
index e1f4d21..99039a8 100644
--- a/src/main/kotlin/com/dulkirfabric/events/ServerTickEvent.kt
+++ b/src/main/kotlin/com/dulkirfabric/events/WorldLoadEvent.kt
@@ -1,8 +1,8 @@
package com.dulkirfabric.events
-object ServerTickEvent {
+object WorldLoadEvent {
@JvmStatic
- fun get(): ServerTickEvent {
+ fun get(): WorldLoadEvent {
return this
}
} \ No newline at end of file