diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt index 14e06d1b0..61866d64f 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/AbstractSlotPanel.kt @@ -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> @JvmOverloads constru y: Float = 0f, width: Float = SIZE, height: Float = SIZE, - open var noItemIcon: IGUIRenderable? = null ) : EditablePanel(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> @JvmOverloads constru renderRegular(graphics, itemStack) if (itemStack.isEmpty) { - noItemIcon?.render(graphics, 0f, 0f, width, height) + slotBackgroundEmpty?.render(graphics, 0f, 0f, width, height) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/InventorySlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/InventorySlotPanel.kt index afbb6d4b1..03b4f9517 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/InventorySlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/InventorySlotPanel.kt @@ -18,8 +18,7 @@ open class InventorySlotPanel, out T : MatteryMenu.Inve slot: T, x: Float = 0f, y: Float = 0f, - noItemIcon: MatterySprite? = null -) : UserFilteredSlotPanel(screen, parent, slot, x, y, SIZE, SIZE, noItemIcon) { +) : UserFilteredSlotPanel(screen, parent, slot, x, y, SIZE, SIZE) { override var slotFilter: Item? get() = slot.filter?.get() set(value) { slot.filter?.accept(value) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/SlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/SlotPanel.kt index 98fe73aac..509a530d6 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/SlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/SlotPanel.kt @@ -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 T : Slot> @JvmOverloads const y: Float = 0f, width: Float = SIZE, height: Float = SIZE, - noItemIcon: IGUIRenderable? = null -) : AbstractSlotPanel(screen, parent, x, y, width, height, noItemIcon), ISlotPanel { +) : AbstractSlotPanel(screen, parent, x, y, width, height), ISlotPanel { override fun mouseClickedInner(x: Double, y: Double, button: Int): Boolean { screen.returnSlot = slot return true @@ -108,7 +104,7 @@ open class SlotPanel, 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 , 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 , T : Slot> EquipmentBatterySlotPanel( screen: S, @@ -143,7 +139,7 @@ fun , 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 , T : Slot> PatternSlotPanel( screen: S, @@ -153,7 +149,7 @@ fun , 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 , T : Slot> MatterCapacitorSlotPanel( screen: S, @@ -163,4 +159,4 @@ fun , 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 } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/UserFilteredSlotPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/UserFilteredSlotPanel.kt index 2c23eb01d..efdaea426 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/UserFilteredSlotPanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/slot/UserFilteredSlotPanel.kt @@ -32,8 +32,7 @@ abstract class UserFilteredSlotPanel, out T : Slot>( y: Float = 0f, width: Float = SIZE, height: Float = SIZE, - noItemIcon: MatterySprite? = null -) : SlotPanel(screen, parent, slot, x, y, width, height, noItemIcon) { +) : SlotPanel(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 T : Slot>( y: Float = 0f, width: Float = SIZE, height: Float = SIZE, - noItemIcon: MatterySprite? = null, filter: GetterSetter ): UserFilteredSlotPanel { - return object : UserFilteredSlotPanel(screen, parent, slot, x, y, width, height, noItemIcon) { + return object : UserFilteredSlotPanel(screen, parent, slot, x, y, width, height) { override var slotFilter: Item? by filter } } @@ -145,9 +143,8 @@ abstract class UserFilteredSlotPanel, out T : Slot>( y: Float = 0f, width: Float = SIZE, height: Float = SIZE, - noItemIcon: MatterySprite? = null ): UserFilteredSlotPanel { - return object : UserFilteredSlotPanel(screen, parent, slot, x, y, width, height, noItemIcon) { + return object : UserFilteredSlotPanel(screen, parent, slot, x, y, width, height) { override var slotFilter: Item? get() = slot.filter?.get() set(value) { slot.filter?.accept(value) }