PhysicalConnectivity/src/main/kotlin/net/shadowfacts/phycon/screen/DeviceConsoleScreen.kt

41 lines
1.2 KiB
Kotlin
Raw Normal View History

2021-02-14 17:07:05 +00:00
package net.shadowfacts.phycon.screen
import net.minecraft.client.gui.screen.Screen
import net.minecraft.client.util.math.MatrixStack
import net.minecraft.text.TranslatableText
2021-02-24 03:05:05 +00:00
import net.minecraft.util.Identifier
import net.shadowfacts.phycon.PhysicalConnectivity
2021-02-14 17:07:05 +00:00
import net.shadowfacts.phycon.network.DeviceBlockEntity
import org.lwjgl.glfw.GLFW
/**
* @author shadowfacts
*/
class DeviceConsoleScreen(
val device: DeviceBlockEntity,
2021-02-24 03:05:05 +00:00
): Screen(TranslatableText("item.phycon.console")) {
2021-02-14 17:07:05 +00:00
2021-02-24 03:05:05 +00:00
companion object {
val BACKGROUND = Identifier(PhysicalConnectivity.MODID, "textures/gui/console.png")
2021-02-14 17:07:05 +00:00
}
override fun isPauseScreen() = false
override fun keyPressed(key: Int, j: Int, k: Int): Boolean {
if (key == GLFW.GLFW_KEY_E) {
2021-02-24 03:05:05 +00:00
onClose()
return true
2021-02-14 17:07:05 +00:00
}
return super.keyPressed(key, j, k)
}
override fun render(matrixStack: MatrixStack, mouseX: Int, mouseY: Int, delta: Float) {
renderBackground(matrixStack)
super.render(matrixStack, mouseX, mouseY, delta)
drawCenteredString(matrixStack, textRenderer, device.macAddress.toString(), width / 2, height / 2 - 5, 0xffffff)
drawCenteredString(matrixStack, textRenderer, device.ipAddress.toString(), width / 2, height / 2 + 5, 0xffffff)
}
2021-02-24 03:05:05 +00:00
}