diff options
author | inglettronald <inglettronald@gmail.com> | 2023-06-10 16:45:58 -0500 |
---|---|---|
committer | inglettronald <inglettronald@gmail.com> | 2023-06-10 16:45:58 -0500 |
commit | 22508bb83e8d5846a7a68dd5346e8a2013e1c710 (patch) | |
tree | c1d1cea4acd3a7560b6e813f0081fe7e89feb8a6 /src | |
parent | 8b69b68978e32d6f8e66fca06a8c7ed36523062f (diff) | |
download | DulkirMod-Fabric-22508bb83e8d5846a7a68dd5346e8a2013e1c710.tar.gz DulkirMod-Fabric-22508bb83e8d5846a7a68dd5346e8a2013e1c710.tar.bz2 DulkirMod-Fabric-22508bb83e8d5846a7a68dd5346e8a2013e1c710.zip |
more shortcuts stuff
Diffstat (limited to 'src')
-rw-r--r-- | src/main/kotlin/com/dulkirfabric/Registrations.kt | 11 | ||||
-rw-r--r-- | src/main/kotlin/com/dulkirfabric/config/ConfigHelper.kt (renamed from src/main/kotlin/com/dulkirfabric/config/ListHelper.kt) | 9 | ||||
-rw-r--r-- | src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt | 26 | ||||
-rw-r--r-- | src/main/kotlin/com/dulkirfabric/config/serializations/KeySerializer.kt | 3 | ||||
-rw-r--r-- | src/main/resources/fabric.mod.json | 4 |
5 files changed, 38 insertions, 15 deletions
diff --git a/src/main/kotlin/com/dulkirfabric/Registrations.kt b/src/main/kotlin/com/dulkirfabric/Registrations.kt index 8a90f7b..31b1eb1 100644 --- a/src/main/kotlin/com/dulkirfabric/Registrations.kt +++ b/src/main/kotlin/com/dulkirfabric/Registrations.kt @@ -3,9 +3,13 @@ package com.dulkirfabric import com.dulkirfabric.DulkirModFabric.EVENT_BUS import com.dulkirfabric.commands.ConfigCommand import com.dulkirfabric.commands.JoinDungeonCommands +import com.dulkirfabric.events.ChatReceivedEvent import com.dulkirfabric.events.ClientTickEvent +import com.dulkirfabric.events.OverlayReceivedEvent +import com.dulkirfabric.features.KeyShortCutImpl import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents +import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents /** @@ -35,6 +39,7 @@ object Registrations { fun registerEventListeners() { EVENT_BUS.subscribe(DulkirModFabric) + EVENT_BUS.subscribe(KeyShortCutImpl) } fun registerEvents() { @@ -42,5 +47,11 @@ object Registrations { ClientTickEvents.START_CLIENT_TICK.register( ClientTickEvents.StartTick { _ -> ClientTickEvent.post() } ) + ClientReceiveMessageEvents.ALLOW_GAME.register( + ClientReceiveMessageEvents.AllowGame { message, overlay -> + if (overlay) !OverlayReceivedEvent(message.toString()).post() + else !ChatReceivedEvent(message.toString()).post() + } + ) } }
\ No newline at end of file diff --git a/src/main/kotlin/com/dulkirfabric/config/ListHelper.kt b/src/main/kotlin/com/dulkirfabric/config/ConfigHelper.kt index 8f50943..4f12d27 100644 --- a/src/main/kotlin/com/dulkirfabric/config/ListHelper.kt +++ b/src/main/kotlin/com/dulkirfabric/config/ConfigHelper.kt @@ -9,7 +9,7 @@ import net.minecraft.text.Text import java.util.* import kotlin.reflect.KMutableProperty0 -object ListHelper { +object ConfigHelper { fun <T> mkConfigList( name: Text, property: KMutableProperty0<List<T>>, @@ -48,4 +48,11 @@ object ListHelper { .setKeySaveConsumer { prop.set(it) } .setDefaultValue(InputUtil.UNKNOWN_KEY) .build() + + fun ConfigEntryBuilder.mkToggle(text: Text, prop: KMutableProperty0<Boolean>, tooltip: Text = Text.literal("")) + = startBooleanToggle(text, prop.get()) + .setSaveConsumer { prop.set(it) } + .setDefaultValue(false) + .setTooltip(tooltip) + .build() }
\ 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 a34016d..9e3fbaf 100644 --- a/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt +++ b/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt @@ -14,8 +14,9 @@ package com.dulkirfabric.config import com.dulkirfabric.DulkirModFabric.mc -import com.dulkirfabric.config.ListHelper.mkKeyField -import com.dulkirfabric.config.ListHelper.mkStringField +import com.dulkirfabric.config.ConfigHelper.mkKeyField +import com.dulkirfabric.config.ConfigHelper.mkStringField +import com.dulkirfabric.config.ConfigHelper.mkToggle import kotlinx.serialization.Serializable import kotlinx.serialization.UseSerializers import kotlinx.serialization.decodeFromString @@ -48,10 +49,9 @@ class DulkirConfig { val entryBuilder = builder.entryBuilder() val general = builder.getOrCreateCategory(Text.literal("General")) general.addEntry( - entryBuilder.startBooleanToggle(Text.literal("Custom Inventory Scale Toggle"), configOptions.invScaleBool) - .setTooltip(Text.literal("WAHOO!")) - .setSaveConsumer { newValue -> configOptions.invScaleBool = newValue } - .build() + entryBuilder.mkToggle(Text.literal("Inventory Scale Toggle"), + configOptions::invScaleBool, + Text.literal("This is a tooltip")) ) general.addEntry( entryBuilder.startIntSlider(Text.literal("Inventory Scale"), configOptions.inventoryScale, 1, 5) @@ -59,10 +59,13 @@ class DulkirConfig { .setSaveConsumer { newValue -> configOptions.inventoryScale = newValue } .build() ) + general.addEntry( + entryBuilder.mkToggle(Text.literal("Ignore Reverse Third Person"), configOptions::ignoreReverseThirdPerson) + ) val shortcuts = builder.getOrCreateCategory(Text.literal("Shortcuts")) shortcuts.addEntry( - ListHelper.mkConfigList( + ConfigHelper.mkConfigList( Text.literal("Macros"), configOptions::macrosList, { Macro(UNKNOWN_KEY, "") }, @@ -80,10 +83,12 @@ class DulkirConfig { screen = builder.build() } + @Serializable data class ConfigOptions( - var invScaleBool: Boolean = true, - var inventoryScale: Int = 1, - var macrosList: List<Macro> = listOf(Macro(UNKNOWN_KEY, "")) + var invScaleBool: Boolean = false, + var inventoryScale: Int = 3, + var macrosList: List<Macro> = listOf(Macro(UNKNOWN_KEY, "")), + var ignoreReverseThirdPerson: Boolean = false ) @Serializable @@ -125,7 +130,6 @@ class DulkirConfig { } configOptions = json.decodeFromString<ConfigOptions>(configFile.readText()) } - } } diff --git a/src/main/kotlin/com/dulkirfabric/config/serializations/KeySerializer.kt b/src/main/kotlin/com/dulkirfabric/config/serializations/KeySerializer.kt index a737bf0..702dab5 100644 --- a/src/main/kotlin/com/dulkirfabric/config/serializations/KeySerializer.kt +++ b/src/main/kotlin/com/dulkirfabric/config/serializations/KeySerializer.kt @@ -7,13 +7,12 @@ import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder import net.minecraft.client.util.InputUtil -import org.lwjgl.glfw.GLFW object KeySerializer: KSerializer<InputUtil.Key> { override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("InputUtil.Key", PrimitiveKind.INT) override fun deserialize(decoder: Decoder): InputUtil.Key { - return InputUtil.fromKeyCode(GLFW.GLFW_KEY_UNKNOWN, decoder.decodeInt()) + return InputUtil.fromKeyCode(decoder.decodeInt(), 0) } override fun serialize(encoder: Encoder, value: InputUtil.Key) { diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 070d281..38818fa 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -5,7 +5,9 @@ "name": "DulkirMod-Fabric", "description": "Utility Mod for Hypixel Skyblock", "authors": [ - "inglettronald" + "inglettronald", + "nea89", + "Ilmars" ], "contact": { "homepage": "https://github.com/inglettronald", |