package net.shadowfacts.phycon.screen import com.mojang.blaze3d.systems.RenderSystem import net.minecraft.client.gui.screen.Screen import net.minecraft.client.gui.widget.ButtonWidget import net.minecraft.client.util.math.MatrixStack import net.shadowfacts.phycon.network.DeviceBlockEntity import net.shadowfacts.phycon.network.component.ActivationController import net.shadowfacts.phycon.networking.C2SConfigureActivationMode import net.shadowfacts.phycon.util.ActivationMode import net.shadowfacts.phycon.util.next import org.lwjgl.glfw.GLFW /** * @author shadowfacts */ class ActivatableDeviceConsoleScreen( val device: T ): Screen(device.cachedState.block.name) where T: DeviceBlockEntity, T: ActivationController.ActivatableDevice { private val backgroundWidth = 252 private val backgroundHeight = 222 override fun init() { super.init() buttons.clear() val minX = (width - backgroundWidth) / 2 val minY = (height - backgroundHeight) / 2 val mode = EnumButton(device.controller::activationMode, minX + 5, minY + 25, 55, 20) { client!!.player!!.networkHandler.sendPacket(C2SConfigureActivationMode(device)) } addButton(mode) } override fun isPauseScreen() = false override fun keyPressed(key: Int, j: Int, k: Int): Boolean { if (key == GLFW.GLFW_KEY_E) { onClose() return true } return super.keyPressed(key, j, k) } override fun render(matrixStack: MatrixStack, mouseX: Int, mouseY: Int, delta: Float) { renderBackground(matrixStack) val minX = (width - backgroundWidth) / 2 val minY = (height - backgroundHeight) / 2 RenderSystem.color4f(1f, 1f, 1f, 1f) client!!.textureManager.bindTexture(DeviceConsoleScreen.BACKGROUND) drawTexture(matrixStack, minX, minY, 0, 0, backgroundWidth, backgroundHeight) super.render(matrixStack, mouseX, mouseY, delta) textRenderer.draw(matrixStack, "IP Address: ${device.ipAddress}", minX + 5f, minY + 5f, 0x404040) textRenderer.draw(matrixStack, "MAC Address: ${device.macAddress}", minX + 5f, minY + 15f, 0x404040) } }