46 lines
1.4 KiB
Kotlin
46 lines
1.4 KiB
Kotlin
package net.shadowfacts.phycon.plugin.rei
|
|
|
|
import me.shedaniel.math.Rectangle
|
|
import me.shedaniel.rei.api.BaseBoundsHandler
|
|
import me.shedaniel.rei.api.DisplayHelper
|
|
import me.shedaniel.rei.api.REIHelper
|
|
import me.shedaniel.rei.api.plugins.REIPluginV0
|
|
import net.fabricmc.api.ClientModInitializer
|
|
import net.minecraft.client.MinecraftClient
|
|
import net.minecraft.util.Identifier
|
|
import net.shadowfacts.phycon.block.terminal.AbstractTerminalScreen
|
|
|
|
/**
|
|
* @author shadowfacts
|
|
*/
|
|
object PhyConPlugin: ClientModInitializer, REIPluginV0 {
|
|
const val MODID = "phycon_rei"
|
|
|
|
override fun onInitializeClient() {
|
|
AbstractTerminalScreen.registerClickHandler { mouseX, mouseY, button ->
|
|
REIHelper.getInstance().searchTextField?.also {
|
|
if (it.bounds.contains(mouseX, mouseY)) {
|
|
this.terminalVC.searchField.resignFirstResponder()
|
|
} else {
|
|
this.terminalVC.searchField.becomeFirstResponder()
|
|
}
|
|
}
|
|
null
|
|
}
|
|
}
|
|
|
|
override fun getPluginIdentifier() = Identifier(MODID, "rei_plugin")
|
|
|
|
override fun registerBounds(helper: DisplayHelper) {
|
|
BaseBoundsHandler.getInstance().registerExclusionZones(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)
|
|
)
|
|
}
|
|
}
|
|
|
|
}
|