Finish hotkeys, clean up menu code.

This commit is contained in:
desyncfy
2024-06-13 20:14:30 -07:00
parent a5cf733d37
commit e8d36a7074
5 changed files with 67 additions and 20 deletions

View File

@@ -16,4 +16,5 @@ _Currently in super beta so don't expect something working for a while._
- Built-in guide (CANCELED) **This feature is being worked on in a different mod called "Mythicfy", so it will not be added to this one. We recommend you download that mod.** - Built-in guide (CANCELED) **This feature is being worked on in a different mod called "Mythicfy", so it will not be added to this one. We recommend you download that mod.**
- Auto-Welcome (20%) **WARNING: This feature may prove to be annoying, in which case we will remove it.** - Auto-Welcome (20%) **WARNING: This feature may prove to be annoying, in which case we will remove it.**
- City NPCs (Lively Mode) (0%) - City NPCs (Lively Mode) (0%)
- Fishing notifications (0%) - Fishing notifications (0%)
- Macros (100%)

View File

@@ -48,15 +48,15 @@ class Menu : Screen(Text.literal("SciFy Menu")) {
.tooltip(Tooltip.of(Text.literal("Fishing Notifications"))) .tooltip(Tooltip.of(Text.literal("Fishing Notifications")))
.build() .build()
warpHotkeys = ButtonWidget.builder(Text.literal("Toggle hotkeys")) { warpHotkeys = ButtonWidget.builder(Text.literal("Toggle hotkeys")) {
fishingnotif().toggleFishingNotif() // Call the function toggleFishingNotif() from the fishingnotif.kt module // I don't think we actually need this module at all. TODO: replace with something else
} }
.dimensions(width / 2 - 205, 60, 200, 20) .dimensions(width / 2 - 205, 60, 200, 20)
.tooltip(Tooltip.of(Text.literal("Enable/Disable hotkeys."))) .tooltip(Tooltip.of(Text.literal("Enable/Disable hotkeys.")))
.build() .build()
autoWelcome = ButtonWidget.builder(Text.literal("Auto-Welcome")) { autoWelcome = ButtonWidget.builder(Text.literal("Auto-Welcome")) {
fishingnotif().toggleFishingNotif() // Call the function toggleFishingNotif() from the fishingnotif.kt module autowelcome().toggleAutoWelcome() // Call the function toggleAutoWelcome() from the fishingnotif.kt module
} }
.dimensions(width / 2 + 5, 60, 200, 20) .dimensions(width / 2 - 205, 60, 200, 20)
.tooltip(Tooltip.of(Text.literal("Automatically welcomes new players."))) .tooltip(Tooltip.of(Text.literal("Automatically welcomes new players.")))
.build() .build()
livelyMode = ButtonWidget.builder(Text.literal("City NPCs (Lively Mode)")) { livelyMode = ButtonWidget.builder(Text.literal("City NPCs (Lively Mode)")) {
@@ -66,17 +66,17 @@ class Menu : Screen(Text.literal("SciFy Menu")) {
.tooltip(Tooltip.of(Text.literal("Replaces Villagers with player NPCs"))) .tooltip(Tooltip.of(Text.literal("Replaces Villagers with player NPCs")))
.build() .build()
resourcePack = ButtonWidget.builder(Text.literal("Toggle Resource Pack")) { resourcePack = ButtonWidget.builder(Text.literal("Toggle Resource Pack")) {
fishingnotif().toggleFishingNotif() // Call the function toggleFishingNotif() from the fishingnotif.kt module // TODO: Implement Resource pack
} }
.dimensions(width / 2 + 5, 100, 200, 20) .dimensions(width / 2 + 5, 60, 200, 20)
.tooltip(Tooltip.of(Text.literal("Toggles the community resource pack."))) .tooltip(Tooltip.of(Text.literal("Toggles the community resource pack.")))
.build() .build()
addDrawableChild(dynamicBars) addDrawableChild(dynamicBars)
addDrawableChild(fishingNotif) addDrawableChild(fishingNotif)
addDrawableChild(warpHotkeys) //addDrawableChild(warpHotkeys)
addDrawableChild(autoWelcome) addDrawableChild(autoWelcome)
addDrawableChild(livelyMode) //addDrawableChild(livelyMode)
addDrawableChild(resourcePack) addDrawableChild(resourcePack)
} }
} }

View File

@@ -1,14 +1,10 @@
package chickenmanfy.scify.Modules package chickenmanfy.scify.Modules
import net.minecraft.client.MinecraftClient
import net.minecraft.text.Text
fun autowelcome() {
val minecraftClient = MinecraftClient.getInstance() class autowelcome() {
val message: Text = Text.literal("Hi!") fun toggleAutoWelcome() {
if (minecraftClient?.player != null) { }
minecraftClient.player!!.sendMessage(message, false) fun autoWelcome() {
} else {
println("MinecraftClient or player is null!")
} }
} }

View File

@@ -1,9 +1,57 @@
package chickenmanfy.scify.Modules package chickenmanfy.scify.Modules
import net.fabricmc.fabric.impl.command.client.ClientCommandInternals.executeCommand import io.netty.buffer.ByteBuf
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper
import net.minecraft.client.MinecraftClient
import net.minecraft.client.option.KeyBinding
import net.minecraft.client.util.InputUtil
import net.minecraft.network.PacketByteBuf
import net.minecraft.network.packet.c2s.play.ChatMessageC2SPacket
import net.minecraft.text.Text
import org.lwjgl.glfw.GLFW
class hotkey { class hotkey {
fun hotkey() { fun hotkeys() {
// TODO: Implement hotkeys in this file.
// Register Keys
val warp = KeyBindingHelper.registerKeyBinding(
KeyBinding(
"Open Warp Menu (/warp)",
InputUtil.Type.KEYSYM,
GLFW.GLFW_KEY_V,
"SciFy"
)
)
val enderchest = KeyBindingHelper.registerKeyBinding(
KeyBinding(
"Open Ender Chest (/ec)",
InputUtil.Type.KEYSYM,
GLFW.GLFW_KEY_Z,
"SciFy"
)
)
val guide = KeyBindingHelper.registerKeyBinding(
KeyBinding(
"Open Guide Book (/guide)",
InputUtil.Type.KEYSYM,
GLFW.GLFW_KEY_SEMICOLON,
"SciFy"
)
)
ClientTickEvents.END_CLIENT_TICK.register(ClientTickEvents.EndTick { client: MinecraftClient ->
while (warp.wasPressed()) {
MinecraftClient.getInstance().networkHandler!!.sendChatCommand("warp")
}
while (enderchest.wasPressed()) {
MinecraftClient.getInstance().networkHandler!!.sendChatCommand("ec")
}
while (guide.wasPressed()) {
MinecraftClient.getInstance().networkHandler!!.sendChatCommand("guide")
}
})
} }
} }

View File

@@ -1,6 +1,7 @@
package chickenmanfy.scify package chickenmanfy.scify
import chickenmanfy.scify.Modules.Menu import chickenmanfy.scify.Modules.Menu
import chickenmanfy.scify.Modules.hotkey
import net.fabricmc.api.ClientModInitializer import net.fabricmc.api.ClientModInitializer
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper
@@ -14,6 +15,7 @@ import org.lwjgl.glfw.GLFW
object SciFyClient : ClientModInitializer { object SciFyClient : ClientModInitializer {
override fun onInitializeClient() { override fun onInitializeClient() {
hotkey().hotkeys()
// Open Menu Hotkey // Open Menu Hotkey
val menu = KeyBindingHelper.registerKeyBinding( val menu = KeyBindingHelper.registerKeyBinding(
KeyBinding( KeyBinding(