46 lines
1.5 KiB
Kotlin
46 lines
1.5 KiB
Kotlin
package net.shadowfacts.phycon.plugin.rei
|
|
|
|
import dev.architectury.event.EventResult
|
|
import dev.architectury.event.events.client.ClientScreenInputEvent
|
|
import me.shedaniel.math.Rectangle
|
|
import me.shedaniel.rei.api.client.REIRuntime
|
|
import me.shedaniel.rei.api.client.plugins.REIClientPlugin
|
|
import me.shedaniel.rei.api.client.registry.screen.ScreenRegistry
|
|
import net.fabricmc.api.ClientModInitializer
|
|
import net.minecraft.client.MinecraftClient
|
|
import net.shadowfacts.phycon.block.terminal.AbstractTerminalScreen
|
|
|
|
/**
|
|
* @author shadowfacts
|
|
*/
|
|
object PhyConPluginClient: ClientModInitializer, REIClientPlugin {
|
|
const val MODID = "phycon_rei"
|
|
|
|
override fun onInitializeClient() {
|
|
ClientScreenInputEvent.MOUSE_RELEASED_PRE.register { client, screen, mouseX, mouseY, button ->
|
|
if (screen is AbstractTerminalScreen<*, *>) {
|
|
REIRuntime.getInstance().searchTextField?.also {
|
|
if (it.isFocused) {
|
|
screen.terminalVC.searchField.resignFirstResponder()
|
|
} else {
|
|
screen.terminalVC.searchField.becomeFirstResponder()
|
|
}
|
|
}
|
|
}
|
|
EventResult.pass()
|
|
}
|
|
}
|
|
|
|
override fun registerScreens(registry: ScreenRegistry) {
|
|
registry.exclusionZones().register(AbstractTerminalScreen::class.java) {
|
|
val screen = MinecraftClient.getInstance().currentScreen as AbstractTerminalScreen<*, *>
|
|
val view = screen.terminalVC.settingsView
|
|
val rect = view.convert(view.bounds, to = null)
|
|
listOf(
|
|
Rectangle(rect.left.toInt(), rect.top.toInt(), 20, 20)
|
|
)
|
|
}
|
|
}
|
|
|
|
}
|