#my custom screen doesn't render slots...!
2 messages · Page 1 of 1 (latest)
ScreenHandler class:
class DeathboxScreenHandler : ScreenHandler {
private val inventory: Inventory
constructor(syncId: Int, playerInventory: PlayerInventory): super(ModScreenHandlers.DEATHBOX_SCREEN_HANDLER, syncId) {
this.inventory = SimpleInventory(1)
}
constructor(syncId: Int, playerInventory: PlayerInventory, inventory: Inventory): super(ModScreenHandlers.DEATHBOX_SCREEN_HANDLER, syncId) {
this.inventory = inventory
for (i in 0..3) {
for (j in 0..9) {
this.addSlot(Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18))
}
}
for (i in 0..8) {
this.addSlot(Slot(playerInventory, i, 8 + (i * 18), 142))
}
}
override fun quickMove(player: PlayerEntity?, slot: Int): ItemStack {
return ItemStack.EMPTY
}
override fun canUse(player: PlayerEntity?): Boolean {
return true
}
}
Screen class:
class DeathboxScreen(
handler: DeathboxScreenHandler,
inventory: PlayerInventory,
title: Text
) : HandledScreen<DeathboxScreenHandler>(
handler,
inventory,
title
) {
private val TEXTURE = Identifier("dubacraftcoremod", "textures/gui/deathbox.png")
init {
this.backgroundWidth = 220
this.backgroundHeight = 166
}
override fun drawBackground(ctx: DrawContext, delta: Float, mouseX: Int, mouseY: Int) {
val x = (this.width - this.backgroundWidth) / 2
val y = (this.height - this.backgroundHeight) / 2
ctx.drawTexture(TEXTURE, x, y, 0, 0, this.backgroundWidth, this.backgroundHeight)
}
override fun render(ctx: DrawContext, mouseX: Int, mouseY: Int, delta: Float) {
super.render(ctx, mouseX, mouseY, delta)
this.drawMouseoverTooltip(ctx, mouseX, mouseY)
}
override fun drawForeground(context: DrawContext?, mouseX: Int, mouseY: Int) {
}
}