fix: shell screen layout
This commit is contained in:
parent
d88f110fe5
commit
680d4d76e1
@ -1,11 +1,11 @@
|
||||
package quaedam.shell
|
||||
|
||||
import dev.architectury.utils.GameInstance
|
||||
import net.minecraft.client.gui.GuiGraphics
|
||||
import net.minecraft.client.gui.components.Button
|
||||
import net.minecraft.client.gui.components.StringWidget
|
||||
import net.minecraft.client.gui.layouts.GridLayout
|
||||
import net.minecraft.client.gui.screens.Screen
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.world.level.Level
|
||||
@ -14,10 +14,15 @@ import quaedam.shell.network.ServerboundPSHLockReleasePacket
|
||||
class ProjectionShellScreen(val level: Level, val pos: BlockPos, val shell: ProjectionEffectShell) :
|
||||
Screen(Component.translatable("quaedam.screen.projection_shell")) {
|
||||
|
||||
val layout = GridLayout()
|
||||
companion object {
|
||||
const val BORDER = 15
|
||||
}
|
||||
|
||||
var layout = GridLayout()
|
||||
|
||||
override fun init() {
|
||||
super.init()
|
||||
layout = GridLayout()
|
||||
layout.spacing(4)
|
||||
val rows = layout.createRowHelper(2)
|
||||
val renderContext = ShellRenderContext(this)
|
||||
@ -32,17 +37,31 @@ class ProjectionShellScreen(val level: Level, val pos: BlockPos, val shell: Proj
|
||||
if (block is ProjectionShellBlock) {
|
||||
block.applyFromShell(level, pos, shell)
|
||||
}
|
||||
GameInstance.getClient().setScreen(null)
|
||||
}.build())
|
||||
}
|
||||
layout.arrangeElements()
|
||||
layout.x = (width - layout.width) / 2
|
||||
layout.y = (height - layout.height) / 2
|
||||
layout.visitWidgets(::addRenderableWidget)
|
||||
}
|
||||
|
||||
fun getFont() = font
|
||||
|
||||
override fun render(guiGraphics: GuiGraphics, mouseX: Int, mouseY: Int, partialTick: Float) {
|
||||
renderBackground(guiGraphics)
|
||||
super.render(guiGraphics, mouseX, mouseY, partialTick)
|
||||
}
|
||||
|
||||
override fun renderBackground(guiGraphics: GuiGraphics) {
|
||||
super.renderBackground(guiGraphics)
|
||||
guiGraphics.blit(AbstractContainerScreen.INVENTORY_LOCATION, width / 2, height / 2, 0, 0, 176, 166)
|
||||
guiGraphics.fill(
|
||||
layout.x - BORDER,
|
||||
layout.y - BORDER,
|
||||
layout.x + layout.width + BORDER,
|
||||
layout.y + layout.height + BORDER,
|
||||
0x11c6c6c6
|
||||
)
|
||||
}
|
||||
|
||||
override fun removed() {
|
||||
|
Loading…
Reference in New Issue
Block a user