2021-03-09 01:53:25 +00:00
|
|
|
package net.shadowfacts.phycon.plugin.rei
|
|
|
|
|
|
|
|
import me.shedaniel.math.Rectangle
|
|
|
|
import me.shedaniel.rei.api.BaseBoundsHandler
|
|
|
|
import me.shedaniel.rei.api.DisplayHelper
|
2021-03-22 21:50:48 +00:00
|
|
|
import me.shedaniel.rei.api.REIHelper
|
2021-03-09 01:53:25 +00:00
|
|
|
import me.shedaniel.rei.api.plugins.REIPluginV0
|
2021-03-22 21:50:48 +00:00
|
|
|
import net.fabricmc.api.ClientModInitializer
|
2021-03-09 01:53:25 +00:00
|
|
|
import net.minecraft.client.MinecraftClient
|
|
|
|
import net.minecraft.util.Identifier
|
2021-03-27 14:22:18 +00:00
|
|
|
import net.shadowfacts.phycon.block.terminal.AbstractTerminalScreen
|
2021-03-09 01:53:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @author shadowfacts
|
|
|
|
*/
|
2021-03-22 21:50:48 +00:00
|
|
|
object PhyConPlugin: ClientModInitializer, REIPluginV0 {
|
2021-03-09 01:53:25 +00:00
|
|
|
const val MODID = "phycon_rei"
|
|
|
|
|
2021-03-22 21:50:48 +00:00
|
|
|
override fun onInitializeClient() {
|
2021-03-27 14:22:18 +00:00
|
|
|
AbstractTerminalScreen.registerClickHandler { mouseX, mouseY, button ->
|
2021-03-22 21:50:48 +00:00
|
|
|
REIHelper.getInstance().searchTextField?.also {
|
|
|
|
if (it.bounds.contains(mouseX, mouseY)) {
|
|
|
|
this.terminalVC.searchField.resignFirstResponder()
|
|
|
|
} else {
|
|
|
|
this.terminalVC.searchField.becomeFirstResponder()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-09 01:53:25 +00:00
|
|
|
override fun getPluginIdentifier() = Identifier(MODID, "rei_plugin")
|
|
|
|
|
|
|
|
override fun registerBounds(helper: DisplayHelper) {
|
2021-03-27 14:22:18 +00:00
|
|
|
BaseBoundsHandler.getInstance().registerExclusionZones(AbstractTerminalScreen::class.java) {
|
|
|
|
val screen = MinecraftClient.getInstance().currentScreen as AbstractTerminalScreen<*, *>
|
2021-03-24 21:28:03 +00:00
|
|
|
val view = screen.terminalVC.settingsView
|
|
|
|
val rect = view.convert(view.bounds, to = null)
|
2021-03-09 01:53:25 +00:00
|
|
|
listOf(
|
2021-03-21 02:31:53 +00:00
|
|
|
Rectangle(rect.left.toInt(), rect.top.toInt(), 20, 20)
|
2021-03-09 01:53:25 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
2021-03-29 23:18:15 +00:00
|
|
|
|
2021-03-09 01:53:25 +00:00
|
|
|
}
|