From 88a2da60ac3a074dd93fa13f262775b05573548f Mon Sep 17 00:00:00 2001 From: inglettronald Date: Fri, 9 Jun 2023 13:38:48 -0500 Subject: . --- src/main/kotlin/com/dulkirfabric/Registrations.kt | 11 ++--------- src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt | 16 +++++++++------- src/main/kotlin/com/dulkirfabric/config/ListHelper.kt | 10 +++++++++- .../kotlin/com/dulkirfabric/events/ServerTickEvent.kt | 8 -------- .../kotlin/com/dulkirfabric/events/WorldLoadEvent.kt | 8 ++++++++ 5 files changed, 28 insertions(+), 25 deletions(-) delete mode 100644 src/main/kotlin/com/dulkirfabric/events/ServerTickEvent.kt create mode 100644 src/main/kotlin/com/dulkirfabric/events/WorldLoadEvent.kt (limited to 'src') 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> = 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) = startStrField(text, prop.get()) .setSaveConsumer { prop.set(it) } + .setDefaultValue("") .build() fun ConfigEntryBuilder.mkIntField(text: Text, prop: KMutableProperty0) = startIntField(text, prop.get()) .setSaveConsumer { prop.set(it) } + .setDefaultValue(0) + .build() + + fun ConfigEntryBuilder.mkKeyField(text: Text, prop: KMutableProperty0) = 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/ServerTickEvent.kt deleted file mode 100644 index e1f4d21..0000000 --- a/src/main/kotlin/com/dulkirfabric/events/ServerTickEvent.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.dulkirfabric.events - -object ServerTickEvent { - @JvmStatic - fun get(): ServerTickEvent { - return this - } -} \ No newline at end of file diff --git a/src/main/kotlin/com/dulkirfabric/events/WorldLoadEvent.kt b/src/main/kotlin/com/dulkirfabric/events/WorldLoadEvent.kt new file mode 100644 index 0000000..99039a8 --- /dev/null +++ b/src/main/kotlin/com/dulkirfabric/events/WorldLoadEvent.kt @@ -0,0 +1,8 @@ +package com.dulkirfabric.events + +object WorldLoadEvent { + @JvmStatic + fun get(): WorldLoadEvent { + return this + } +} \ No newline at end of file -- cgit