94 lines
3.2 KiB
Kotlin
94 lines
3.2 KiB
Kotlin
package codes.som.hibiscus
|
|
|
|
import codes.som.hibiscus.api.event.EventBus
|
|
import codes.som.hibiscus.api.event.EventPhase
|
|
import codes.som.hibiscus.api.keybinds.KeybindRegistry
|
|
import codes.som.hibiscus.commands.CommandRegistry
|
|
import codes.som.hibiscus.data.DataManager
|
|
import codes.som.hibiscus.events.KeyEvent
|
|
import codes.som.hibiscus.features.FeaturesRegistry
|
|
import codes.som.hibiscus.features.combat.Criticals
|
|
import codes.som.hibiscus.features.exploits.AntiGhost
|
|
import codes.som.hibiscus.features.player.NoFallDamage
|
|
import codes.som.hibiscus.features.player.NoSprintingPacket
|
|
import codes.som.hibiscus.gui.screens.AccountManagerUIScreen
|
|
import codes.som.hibiscus.gui.screens.InGameClientUIScreen
|
|
import codes.som.hibiscus.mixins.MixinExtMinecraftClient
|
|
import codes.som.hibiscus.subsystems.accounts.AccountsSubsystem
|
|
import codes.som.hibiscus.util.command.ChatCommandListener
|
|
import codes.som.hibiscus.util.input.KeybindDispatcher
|
|
import codes.som.hibiscus.util.netmoving.NetworkMovingDispatcher
|
|
import net.fabricmc.api.ModInitializer
|
|
import net.minecraft.client.gui.screen.TitleScreen
|
|
import org.lwjgl.glfw.GLFW
|
|
import org.lwjgl.glfw.GLFW.*
|
|
|
|
@Suppress("UNUSED")
|
|
object Hibiscus : ModInitializer {
|
|
private const val MOD_ID = "hibiscus_client"
|
|
|
|
@JvmStatic
|
|
@get:JvmName("bus")
|
|
val bus = EventBus()
|
|
|
|
val features = FeaturesRegistry()
|
|
val commands = CommandRegistry()
|
|
val keybinds = KeybindRegistry()
|
|
val data = DataManager()
|
|
|
|
override fun onInitialize() {
|
|
data.runMigrations()
|
|
|
|
for (feature in features.getAllFeatures()) {
|
|
commands.register(feature.createFeatureCommand())
|
|
}
|
|
|
|
bus.register { event: KeyEvent ->
|
|
if (event.key != GLFW_KEY_RIGHT_SHIFT || event.action != GLFW.GLFW_PRESS)
|
|
return@register
|
|
|
|
when (mc.currentScreen) {
|
|
null -> mc.setScreen(InGameClientUIScreen)
|
|
is TitleScreen -> mc.setScreen(AccountManagerUIScreen)
|
|
}
|
|
}
|
|
|
|
bus.register(NetworkMovingDispatcher(), EventPhase.AFTER)
|
|
bus.register(ChatCommandListener())
|
|
bus.register(KeybindDispatcher())
|
|
|
|
defaultConfig()
|
|
|
|
AccountsSubsystem.reload()
|
|
if (mc.session.accessToken == "FabricMC") { // Launched from IDE
|
|
try {
|
|
AccountsSubsystem.getAccounts().firstOrNull()?.let { account ->
|
|
AccountsSubsystem.signIn(account)
|
|
?.let(AccountsSubsystem::createSession)
|
|
?.let((mc as MixinExtMinecraftClient)::setSession)
|
|
}
|
|
} catch (_: Exception) {
|
|
}
|
|
}
|
|
}
|
|
|
|
fun shutdown() {
|
|
for (system in sequenceOf(bus, features, commands, keybinds)) {
|
|
system.reset()
|
|
}
|
|
}
|
|
|
|
fun defaultConfig() {
|
|
keybinds.register(GLFW_KEY_R, "fly")
|
|
keybinds.register(GLFW_KEY_O, "nofall")
|
|
keybinds.register(GLFW_KEY_G, "speed")
|
|
keybinds.register(GLFW_KEY_B, "freecam")
|
|
keybinds.register(GLFW_KEY_X, "xray")
|
|
|
|
features.getFeature<AntiGhost>().enabled = true
|
|
features.getFeature<NoFallDamage>().enabled = true
|
|
features.getFeature<Criticals>().enabled = true
|
|
features.getFeature<NoSprintingPacket>().enabled = true
|
|
}
|
|
}
|