Move empty slot background from constructor to mutable property
This commit is contained in:
parent
f598cc7bbd
commit
86feb87a53
@ -1,7 +1,6 @@
|
||||
package ru.dbotthepony.mc.otm.client.screen.panels.slot
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import net.minecraft.client.gui.GuiGraphics
|
||||
import net.minecraft.client.gui.screens.Screen.getTooltipFromItem
|
||||
import net.minecraft.client.renderer.GameRenderer
|
||||
@ -21,9 +20,9 @@ abstract class AbstractSlotPanel<out S : MatteryScreen<*>> @JvmOverloads constru
|
||||
y: Float = 0f,
|
||||
width: Float = SIZE,
|
||||
height: Float = SIZE,
|
||||
open var noItemIcon: IGUIRenderable? = null
|
||||
) : EditablePanel<S>(screen, parent, x, y, width, height), IItemStackPanel {
|
||||
open var slotBackground: IGUIRenderable? = null
|
||||
open var slotBackgroundEmpty: IGUIRenderable? = null
|
||||
|
||||
protected open fun renderSlotBackground(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {
|
||||
SLOT_BACKGROUND.render(graphics, width = width, height = height)
|
||||
@ -54,7 +53,7 @@ abstract class AbstractSlotPanel<out S : MatteryScreen<*>> @JvmOverloads constru
|
||||
renderRegular(graphics, itemStack)
|
||||
|
||||
if (itemStack.isEmpty) {
|
||||
noItemIcon?.render(graphics, 0f, 0f, width, height)
|
||||
slotBackgroundEmpty?.render(graphics, 0f, 0f, width, height)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,8 +18,7 @@ open class InventorySlotPanel<out S : MatteryScreen<*>, out T : MatteryMenu.Inve
|
||||
slot: T,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f,
|
||||
noItemIcon: MatterySprite? = null
|
||||
) : UserFilteredSlotPanel<S, T>(screen, parent, slot, x, y, SIZE, SIZE, noItemIcon) {
|
||||
) : UserFilteredSlotPanel<S, T>(screen, parent, slot, x, y, SIZE, SIZE) {
|
||||
override var slotFilter: Item?
|
||||
get() = slot.filter?.get()
|
||||
set(value) { slot.filter?.accept(value) }
|
||||
|
@ -3,7 +3,6 @@
|
||||
package ru.dbotthepony.mc.otm.client.screen.panels.slot
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem
|
||||
import com.mojang.blaze3d.vertex.PoseStack
|
||||
import net.minecraft.ChatFormatting
|
||||
import net.minecraft.client.gui.GuiGraphics
|
||||
import net.minecraft.client.renderer.GameRenderer
|
||||
@ -11,8 +10,6 @@ import net.minecraft.world.inventory.AbstractContainerMenu
|
||||
import net.minecraft.world.inventory.Slot
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import ru.dbotthepony.mc.otm.client.minecraft
|
||||
import ru.dbotthepony.mc.otm.client.render.IGUIRenderable
|
||||
import ru.dbotthepony.mc.otm.client.render.MatterySprite
|
||||
import ru.dbotthepony.mc.otm.client.render.Widgets18
|
||||
import ru.dbotthepony.mc.otm.client.render.drawRect
|
||||
import ru.dbotthepony.mc.otm.client.render.setDrawColor
|
||||
@ -30,8 +27,7 @@ open class SlotPanel<out S : MatteryScreen<*>, out T : Slot> @JvmOverloads const
|
||||
y: Float = 0f,
|
||||
width: Float = SIZE,
|
||||
height: Float = SIZE,
|
||||
noItemIcon: IGUIRenderable? = null
|
||||
) : AbstractSlotPanel<S>(screen, parent, x, y, width, height, noItemIcon), ISlotPanel<T> {
|
||||
) : AbstractSlotPanel<S>(screen, parent, x, y, width, height), ISlotPanel<T> {
|
||||
override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean {
|
||||
screen.returnSlot = slot
|
||||
return true
|
||||
@ -108,7 +104,7 @@ open class SlotPanel<out S : MatteryScreen<*>, out T : Slot> @JvmOverloads const
|
||||
RenderSystem.setShaderTexture(0, texture.atlasLocation())
|
||||
graphics.blit(1, 1, 0, 16, 16, texture)
|
||||
} else {
|
||||
noItemIcon?.render(graphics, 0f, 0f, width = width, height = height)
|
||||
slotBackgroundEmpty?.render(graphics, 0f, 0f, width = width, height = height)
|
||||
}
|
||||
}
|
||||
|
||||
@ -133,7 +129,7 @@ fun <S : MatteryScreen<*>, T : Slot> BatterySlotPanel(
|
||||
y: Float = 0f,
|
||||
width: Float = AbstractSlotPanel.SIZE,
|
||||
height: Float = AbstractSlotPanel.SIZE,
|
||||
) = SlotPanel(screen, parent, slot, x, y, width, height, Widgets18.BATTERY_SLOT_BACKGROUND)
|
||||
) = SlotPanel(screen, parent, slot, x, y, width, height).also { it.slotBackgroundEmpty = Widgets18.BATTERY_SLOT_BACKGROUND }
|
||||
|
||||
fun <S : MatteryScreen<*>, T : Slot> EquipmentBatterySlotPanel(
|
||||
screen: S,
|
||||
@ -143,7 +139,7 @@ fun <S : MatteryScreen<*>, T : Slot> EquipmentBatterySlotPanel(
|
||||
y: Float = 0f,
|
||||
width: Float = AbstractSlotPanel.SIZE,
|
||||
height: Float = AbstractSlotPanel.SIZE,
|
||||
) = SlotPanel(screen, parent, slot, x, y, width, height, Widgets18.EQUIPMENT_BATTERY_SLOT_BACKGROUND)
|
||||
) = SlotPanel(screen, parent, slot, x, y, width, height).also { it.slotBackgroundEmpty = Widgets18.EQUIPMENT_BATTERY_SLOT_BACKGROUND }
|
||||
|
||||
fun <S : MatteryScreen<*>, T : Slot> PatternSlotPanel(
|
||||
screen: S,
|
||||
@ -153,7 +149,7 @@ fun <S : MatteryScreen<*>, T : Slot> PatternSlotPanel(
|
||||
y: Float = 0f,
|
||||
width: Float = AbstractSlotPanel.SIZE,
|
||||
height: Float = AbstractSlotPanel.SIZE,
|
||||
) = SlotPanel(screen, parent, slot, x, y, width, height, Widgets18.PATTERN_SLOT_BACKGROUND)
|
||||
) = SlotPanel(screen, parent, slot, x, y, width, height).also { it.slotBackgroundEmpty = Widgets18.PATTERN_SLOT_BACKGROUND }
|
||||
|
||||
fun <S : MatteryScreen<*>, T : Slot> MatterCapacitorSlotPanel(
|
||||
screen: S,
|
||||
@ -163,4 +159,4 @@ fun <S : MatteryScreen<*>, T : Slot> MatterCapacitorSlotPanel(
|
||||
y: Float = 0f,
|
||||
width: Float = AbstractSlotPanel.SIZE,
|
||||
height: Float = AbstractSlotPanel.SIZE,
|
||||
) = SlotPanel(screen, parent, slot, x, y, width, height, Widgets18.MATTER_CAPACITOR_SLOT_BACKGROUND)
|
||||
) = SlotPanel(screen, parent, slot, x, y, width, height).also { it.slotBackgroundEmpty = Widgets18.MATTER_CAPACITOR_SLOT_BACKGROUND }
|
||||
|
@ -32,8 +32,7 @@ abstract class UserFilteredSlotPanel<out S : MatteryScreen<*>, out T : Slot>(
|
||||
y: Float = 0f,
|
||||
width: Float = SIZE,
|
||||
height: Float = SIZE,
|
||||
noItemIcon: MatterySprite? = null
|
||||
) : SlotPanel<S, T>(screen, parent, slot, x, y, width, height, noItemIcon) {
|
||||
) : SlotPanel<S, T>(screen, parent, slot, x, y, width, height) {
|
||||
abstract var slotFilter: Item?
|
||||
|
||||
protected open fun renderBackgroundBeforeFilter(graphics: GuiGraphics, mouseX: Float, mouseY: Float, partialTick: Float) {}
|
||||
@ -129,10 +128,9 @@ abstract class UserFilteredSlotPanel<out S : MatteryScreen<*>, out T : Slot>(
|
||||
y: Float = 0f,
|
||||
width: Float = SIZE,
|
||||
height: Float = SIZE,
|
||||
noItemIcon: MatterySprite? = null,
|
||||
filter: GetterSetter<Item?>
|
||||
): UserFilteredSlotPanel<S, T> {
|
||||
return object : UserFilteredSlotPanel<S, T>(screen, parent, slot, x, y, width, height, noItemIcon) {
|
||||
return object : UserFilteredSlotPanel<S, T>(screen, parent, slot, x, y, width, height) {
|
||||
override var slotFilter: Item? by filter
|
||||
}
|
||||
}
|
||||
@ -145,9 +143,8 @@ abstract class UserFilteredSlotPanel<out S : MatteryScreen<*>, out T : Slot>(
|
||||
y: Float = 0f,
|
||||
width: Float = SIZE,
|
||||
height: Float = SIZE,
|
||||
noItemIcon: MatterySprite? = null
|
||||
): UserFilteredSlotPanel<S, T> {
|
||||
return object : UserFilteredSlotPanel<S, T>(screen, parent, slot, x, y, width, height, noItemIcon) {
|
||||
return object : UserFilteredSlotPanel<S, T>(screen, parent, slot, x, y, width, height) {
|
||||
override var slotFilter: Item?
|
||||
get() = slot.filter?.get()
|
||||
set(value) { slot.filter?.accept(value) }
|
||||
|
Loading…
Reference in New Issue
Block a user