From d151fd6727e88f8315ffde64d28ba8bae7576c48 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 2 Mar 2023 20:55:41 +0700 Subject: [PATCH] Display equipment in energy servo, display curios in android station --- .../client/screen/ExoPackInventoryScreen.kt | 41 ++-------- .../mc/otm/client/screen/MatteryScreen.kt | 25 +----- .../screen/panels/PlayerEquipmentPanel.kt | 81 +++++++++++++++++++ .../screen/tech/AndroidStationScreen.kt | 12 +-- .../client/screen/tech/EnergyServoScreen.kt | 24 ++++-- .../mc/otm/compat/curios/CuriosCompat.kt | 11 +-- .../mc/otm/menu/ExoPackInventoryMenu.kt | 22 +++-- .../ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 41 ++++++++-- .../mc/otm/menu/tech/AndroidStationMenu.kt | 28 ++----- .../mc/otm/menu/tech/EnergyServoMenu.kt | 2 + 10 files changed, 171 insertions(+), 116 deletions(-) create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/PlayerEquipmentPanel.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt index d7d107bf2..5c2d28a0c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoPackInventoryScreen.kt @@ -97,18 +97,13 @@ class ExoPackInventoryScreen(menu: ExoPackInventoryMenu) : MatteryScreen 4) - ScrollbarBackgroundPanel.padded(this, frame, x, - width = curiosWidth, - height = curiosHeight, alwaysShowScrollbar = true) - else - BackgroundPanel.padded(this, frame, x, - width = curiosWidth, - height = curiosHeight) - - x -= curiosRect.width - curiosRect.x = x - - for ((slot, cosmetic) in menu.curiosSlots) { - val row = EditablePanel(this, if (curiosRect is ScrollbarBackgroundPanel) curiosRect.canvas else curiosRect, height = AbstractSlotPanel.SIZE) - row.dock = Dock.TOP - - SlotPanel(this, row, slot).dock = Dock.RIGHT - - if (cosmetic != null) { - SlotPanel(this, row, cosmetic).dock = Dock.LEFT - } - } + x -= curios.width + curios.x = x } EffectListPanel(this, frame, menu.ply, x - 56f, gridHeight = 6).tick() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatteryScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatteryScreen.kt index 41dee7093..1f7d24ad1 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatteryScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatteryScreen.kt @@ -29,6 +29,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.util.ScrollBarConstants import ru.dbotthepony.mc.otm.compat.cos.CosmeticToggleButton import ru.dbotthepony.mc.otm.core.math.integerDivisionDown import ru.dbotthepony.mc.otm.menu.MatteryMenu +import ru.dbotthepony.mc.otm.menu.PlayerSlot import java.util.Collections /** @@ -583,30 +584,6 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit } } - fun makeArmorStrip(slots: Collection>, parent: EditablePanel<*>? = null): EditablePanel<*> { - val armorSlotsStrip = EditablePanel(this, parent, width = 18f) - armorSlotsStrip.dock = Dock.LEFT - - for ((slot, cosmeticSlot) in slots) { - if (cosmeticSlot == null) { - SlotPanel(this, armorSlotsStrip, slot).also { - it.dock = Dock.TOP - } - } else { - FoldableSlotPanel(this, armorSlotsStrip, - SlotPanel(this, null, slot).also { - CosmeticToggleButton(this, it, slot.type) - }, - listOf(SlotPanel(this, null, cosmeticSlot)) - ).also { - it.dock = Dock.TOP - } - } - } - - return armorSlotsStrip - } - companion object { const val DEFAULT_FRAME_WIDTH = AbstractSlotPanel.SIZE * 9f + 16f const val DEFAULT_FRAME_HEIGHT = 100f diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/PlayerEquipmentPanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/PlayerEquipmentPanel.kt new file mode 100644 index 000000000..08bb2fbc0 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/PlayerEquipmentPanel.kt @@ -0,0 +1,81 @@ +package ru.dbotthepony.mc.otm.client.screen.panels + +import net.minecraft.world.inventory.Slot +import ru.dbotthepony.mc.otm.client.minecraft +import ru.dbotthepony.mc.otm.client.screen.MatteryScreen +import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.FoldableSlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.slot.SlotPanel +import ru.dbotthepony.mc.otm.client.screen.panels.util.BackgroundPanel +import ru.dbotthepony.mc.otm.compat.cos.CosmeticToggleButton +import ru.dbotthepony.mc.otm.menu.MatteryMenu +import ru.dbotthepony.mc.otm.menu.PlayerSlot + +fun > makeCuriosPanel(screen: S, parent: FramePanel, slots: List>, autoAlign: Boolean = false): EditablePanel? { + if (slots.isEmpty()) { + return null + } + + val curiosWidth = if (slots.any { it.cosmetic != null }) AbstractSlotPanel.SIZE * 2f else AbstractSlotPanel.SIZE + val curiosHeight = slots.size.coerceAtMost(4) * AbstractSlotPanel.SIZE + + val curiosRect = + if (slots.size > 4) + ScrollbarBackgroundPanel.padded(screen, parent, 0f, + width = curiosWidth, + height = curiosHeight, alwaysShowScrollbar = true) + else + BackgroundPanel.padded(screen, parent, 0f, + width = curiosWidth, + height = curiosHeight) + + if (autoAlign) { + curiosRect.x = -4f - curiosRect.width + } + + for ((slot, cosmetic) in slots) { + val row = EditablePanel(screen, if (curiosRect is ScrollbarBackgroundPanel) curiosRect.canvas else curiosRect, height = AbstractSlotPanel.SIZE) + row.dock = Dock.TOP + + SlotPanel(screen, row, slot).dock = Dock.RIGHT + + if (cosmetic != null) { + SlotPanel(screen, row, cosmetic).dock = Dock.LEFT + } + } + + return curiosRect +} + +@Suppress("LeakingThis") +open class PlayerEquipmentPanel>( + screen: S, + parent: EditablePanel<*>?, + x: Float = 0f, + y: Float = 0f, + val armorSlots: List> +) : EditablePanel(screen, parent, x, y, height = HEIGHT, width = WIDTH) { + val armorSlotsStrip = EditablePanel(screen, this, width = AbstractSlotPanel.SIZE) + val entityPanel = EntityRendererPanel(screen, this, minecraft.player!!) + + init { + entityPanel.dock = Dock.LEFT + armorSlotsStrip.dock = Dock.LEFT + + for ((slot, cosmeticSlot) in armorSlots) { + if (cosmeticSlot == null) { + SlotPanel(screen, armorSlotsStrip, slot).dock = Dock.TOP + } else { + FoldableSlotPanel(screen, armorSlotsStrip, + SlotPanel(screen, null, slot).also { CosmeticToggleButton(screen, it, slot.type) }, + listOf(SlotPanel(screen, null, cosmeticSlot))).dock = Dock.TOP + + } + } + } + + companion object { + val HEIGHT = EntityRendererPanel.ENTITY_RECTANGLE.height + val WIDTH = AbstractSlotPanel.SIZE + EntityRendererPanel.ENTITY_RECTANGLE.width + } +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/AndroidStationScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/AndroidStationScreen.kt index 1d3fbfa6e..0ed9bbfad 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/AndroidStationScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/AndroidStationScreen.kt @@ -707,17 +707,11 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I it.dockTop = 6f } - val playerStrip = EditablePanel(this, frame, height = 72f) + makeCuriosPanel(this, frame, menu.equipment.curiosSlots, autoAlign = true) + + val playerStrip = PlayerEquipmentPanel(this, frame, armorSlots = menu.equipment.armorSlots) playerStrip.dock = Dock.TOP - makeArmorStrip(menu.armorSlots, playerStrip).also { - it.dock = Dock.LEFT - } - - EntityRendererPanel(this, playerStrip, minecraft!!.player!!).also { - it.dock = Dock.LEFT - } - val androidStrip = EditablePanel(this, playerStrip, width = AbstractSlotPanel.SIZE) androidStrip.dock = Dock.LEFT diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt index 159c496cb..d3a0a114e 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/tech/EnergyServoScreen.kt @@ -7,9 +7,12 @@ import ru.dbotthepony.mc.otm.client.screen.MatteryScreen import ru.dbotthepony.mc.otm.client.screen.panels.slot.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.slot.BatterySlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.Dock +import ru.dbotthepony.mc.otm.client.screen.panels.DockResizeMode import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel +import ru.dbotthepony.mc.otm.client.screen.panels.PlayerEquipmentPanel import ru.dbotthepony.mc.otm.client.screen.panels.button.makeDeviceControls +import ru.dbotthepony.mc.otm.client.screen.panels.makeCuriosPanel import ru.dbotthepony.mc.otm.client.screen.widget.HorizontalPowerGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.ProgressGaugePanel import ru.dbotthepony.mc.otm.client.screen.widget.TallHorizontalPowerGaugePanel @@ -19,14 +22,23 @@ class EnergyServoScreen(menu: EnergyServoMenu, inventory: Inventory, title: Comp override fun makeMainFrame(): FramePanel> { val frame = FramePanel.padded(this, width = AbstractSlotPanel.SIZE * 2f + HorizontalPowerGaugePanel.GAUGE_BACKGROUND_TALL.width + 8f + ProgressGaugePanel.GAUGE_BACKGROUND.width * 2f, - AbstractSlotPanel.SIZE, title) + AbstractSlotPanel.SIZE + PlayerEquipmentPanel.HEIGHT + 4f, title) - BatterySlotPanel(this, frame, menu.dischargeSlot).also { + val equipment = PlayerEquipmentPanel(this, frame, armorSlots = menu.equipment.armorSlots) + equipment.dock = Dock.FILL + equipment.dockResize = DockResizeMode.NONE + + makeCuriosPanel(this, frame, menu.equipment.curiosSlots, autoAlign = true) + + val strip = EditablePanel(this, frame, height = AbstractSlotPanel.SIZE) + strip.dock = Dock.BOTTOM + + BatterySlotPanel(this, strip, menu.dischargeSlot).also { it.dock = Dock.LEFT it.dockRight = 2f } - object : EditablePanel(this@EnergyServoScreen, frame) { + object : EditablePanel(this@EnergyServoScreen, strip) { init { dock = Dock.LEFT dockRight = 2f @@ -39,12 +51,12 @@ class EnergyServoScreen(menu: EnergyServoMenu, inventory: Inventory, title: Comp } } - TallHorizontalPowerGaugePanel(this, frame, menu.powerGauge).also { + TallHorizontalPowerGaugePanel(this, strip, menu.powerGauge).also { it.dock = Dock.LEFT it.dockRight = 2f } - object : EditablePanel(this@EnergyServoScreen, frame) { + object : EditablePanel(this@EnergyServoScreen, strip) { init { dock = Dock.LEFT dockRight = 2f @@ -57,7 +69,7 @@ class EnergyServoScreen(menu: EnergyServoMenu, inventory: Inventory, title: Comp } } - BatterySlotPanel(this, frame, menu.chargeSlot).also { + BatterySlotPanel(this, strip, menu.chargeSlot).also { it.dock = Dock.LEFT it.dockRight } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt index 41f0ef33e..1c8306127 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/curios/CuriosCompat.kt @@ -10,6 +10,7 @@ import ru.dbotthepony.mc.otm.container.awareStream import ru.dbotthepony.mc.otm.container.stream import ru.dbotthepony.mc.otm.core.collect.AwareItemStack import ru.dbotthepony.mc.otm.core.orNull +import ru.dbotthepony.mc.otm.menu.PlayerSlot import top.theillusivec4.curios.api.CuriosApi import top.theillusivec4.curios.common.inventory.CosmeticCurioSlot import top.theillusivec4.curios.common.inventory.CurioSlot @@ -20,10 +21,10 @@ val isCuriosLoaded by lazy { ModList.get().isLoaded(CuriosApi.MODID) } -private fun Player.getCuriosSlotsImpl(): Collection> { +private fun Player.getCuriosSlotsImpl(): List> { val handler = getCapability(MatteryCapability.CURIOS_INVENTORY).orNull() ?: return listOf() - val result = ArrayList>() + val result = ArrayList>() val sortedIdentifiers = ArrayList(handler.curios.keys.size) sortedIdentifiers.addAll(handler.curios.keys) @@ -44,9 +45,9 @@ private fun Player.getCuriosSlotsImpl(): Collection> { if (curio.hasCosmetic()) { val cosmetic = CosmeticCurioSlot(this, curio.cosmeticStacks, slot, identifier, 0, 0) - result.add(regular to cosmetic) + result.add(PlayerSlot(regular, cosmetic)) } else { - result.add(regular to null) + result.add(PlayerSlot(regular)) } } } @@ -58,7 +59,7 @@ private fun Player.getCuriosSlotsImpl(): Collection> { /** * [Pair] */ -val Player.curiosSlots: Collection> get() { +val Player.curiosSlots: List> get() { if (!isCuriosLoaded) { return listOf() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt index 042c23baf..c13660f8d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoPackInventoryMenu.kt @@ -50,7 +50,10 @@ class ExoPackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen } } - val armorSlots: List> = makeArmorSlots() + init { + addInventorySlots(autoFrame = false) + craftingSlots.forEach(this::addSlot) + } val offhandSlot = object : InventorySlot(capability.ply.inventory, 40) { override fun getNoItemIcon(): Pair { @@ -58,19 +61,12 @@ class ExoPackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen } } + val armorSlots = makeArmorSlots() val allAccessibleSlots: List init { - addInventorySlots(autoFrame = false) - - craftingSlots.forEach(this::addSlot) addSlot(offhandSlot) - for ((a, b) in armorSlots) { - addSlot(a) - if (b != null) addSlot(b) - } - val builder = ImmutableList.builder() builder.addAll(playerInventorySlots) @@ -80,7 +76,7 @@ class ExoPackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen allAccessibleSlots = builder.build() } - val curiosSlots: List> = ImmutableList.copyOf(ply.curiosSlots) + val curiosSlots: ImmutableList> = ImmutableList.copyOf(ply.curiosSlots) init { for ((a, b) in curiosSlots) { @@ -163,10 +159,10 @@ class ExoPackInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen } for (slot in armorSlots) { - quickMoveMapping[slot.first] = ::playerInventorySlots + quickMoveMapping[slot.functional] = ::playerInventorySlots - if (slot.second != null) { - quickMoveMapping[slot.first] = ::playerInventorySlots + if (slot.cosmetic != null) { + quickMoveMapping[slot.cosmetic] = ::playerInventorySlots } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt index a04aaf714..1f3079afe 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -20,6 +20,7 @@ import net.minecraftforge.network.PacketDistributor import ru.dbotthepony.mc.otm.capability.matteryPlayer import ru.dbotthepony.mc.otm.client.minecraft import ru.dbotthepony.mc.otm.compat.cos.cosmeticArmorSlots +import ru.dbotthepony.mc.otm.compat.curios.curiosSlots import ru.dbotthepony.mc.otm.compat.curios.isCurioSlot import ru.dbotthepony.mc.otm.container.ItemFilter import ru.dbotthepony.mc.otm.container.ItemFilterNetworkSlot @@ -44,6 +45,13 @@ import java.util.function.Predicate import java.util.function.Supplier import kotlin.collections.ArrayList +data class PlayerSlot(val functional: A, val cosmetic: B? = null) + +data class EquipmentSlots( + val armorSlots: List>, + val curiosSlots: List> +) + abstract class MatteryMenu @JvmOverloads protected constructor( menuType: MenuType<*>?, containerId: Int, @@ -367,10 +375,16 @@ abstract class MatteryMenu @JvmOverloads protected constructor( abstract val storageSlots: Collection protected val quickMoveMapping = Reference2ObjectOpenHashMap Collection?>() + /** + * Marks slot as "storage" - shift clicking it will move its contents to Player's inventory + */ protected fun storage2Inventory(slot: Slot) { quickMoveMapping[slot] = ::playerInventorySlots } + /** + * Marks slot as "inventory" - shift clicking it will move its contents to menu's storage slots + */ protected fun inventory2Storage(slot: Slot) { quickMoveMapping[slot] = ::storageSlots } @@ -536,14 +550,31 @@ abstract class MatteryMenu @JvmOverloads protected constructor( super.addDataSlots(p_38885_) } - fun makeArmorSlots(): List> { + fun makeArmorSlots(): List> { val cosmetic = ply.cosmeticArmorSlots return ImmutableList.of( - EquipmentSlot(net.minecraft.world.entity.EquipmentSlot.HEAD) to cosmetic?.get(net.minecraft.world.entity.EquipmentSlot.HEAD), - EquipmentSlot(net.minecraft.world.entity.EquipmentSlot.CHEST) to cosmetic?.get(net.minecraft.world.entity.EquipmentSlot.CHEST), - EquipmentSlot(net.minecraft.world.entity.EquipmentSlot.LEGS) to cosmetic?.get(net.minecraft.world.entity.EquipmentSlot.LEGS), - EquipmentSlot(net.minecraft.world.entity.EquipmentSlot.FEET) to cosmetic?.get(net.minecraft.world.entity.EquipmentSlot.FEET), + PlayerSlot(EquipmentSlot(net.minecraft.world.entity.EquipmentSlot.HEAD), cosmetic?.get(net.minecraft.world.entity.EquipmentSlot.HEAD)), + PlayerSlot(EquipmentSlot(net.minecraft.world.entity.EquipmentSlot.CHEST), cosmetic?.get(net.minecraft.world.entity.EquipmentSlot.CHEST)), + PlayerSlot(EquipmentSlot(net.minecraft.world.entity.EquipmentSlot.LEGS), cosmetic?.get(net.minecraft.world.entity.EquipmentSlot.LEGS)), + PlayerSlot(EquipmentSlot(net.minecraft.world.entity.EquipmentSlot.FEET), cosmetic?.get(net.minecraft.world.entity.EquipmentSlot.FEET)), + ).also { + for ((a, b) in it) { + addSlot(a) + if (b != null) addSlot(b) + } + } + } + + fun makeEquipmentSlots(): EquipmentSlots { + return EquipmentSlots( + armorSlots = makeArmorSlots(), + curiosSlots = ImmutableList.copyOf(ply.curiosSlots).also { + for ((a, b) in it) { + addSlot(a) + if (b != null) addSlot(b) + } + } ) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidStationMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidStationMenu.kt index aafee79a1..168959471 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidStationMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/AndroidStationMenu.kt @@ -12,6 +12,7 @@ import net.minecraftforge.common.capabilities.ForgeCapabilities import ru.dbotthepony.mc.otm.block.entity.tech.AndroidStationBlockEntity import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability import ru.dbotthepony.mc.otm.capability.matteryPlayer +import ru.dbotthepony.mc.otm.core.immutableList import ru.dbotthepony.mc.otm.menu.MatteryPoweredMenu import ru.dbotthepony.mc.otm.menu.MatterySlot import ru.dbotthepony.mc.otm.registry.MMenus @@ -98,12 +99,12 @@ class AndroidStationMenu @JvmOverloads constructor( return super.mayPickup(player) && powerWidget.level >= AndroidStationBlockEntity.ENERGY_PER_OPERATION } - override fun mayPlace(p_40231_: ItemStack): Boolean { + override fun mayPlace(itemStack: ItemStack): Boolean { if (tile is AndroidStationBlockEntity) { - return tile.energy.batteryLevel >= AndroidStationBlockEntity.ENERGY_PER_OPERATION && condition.invoke(p_40231_) + return tile.energy.batteryLevel >= AndroidStationBlockEntity.ENERGY_PER_OPERATION && condition.invoke(itemStack) } - return powerWidget.level >= AndroidStationBlockEntity.ENERGY_PER_OPERATION && condition.invoke(p_40231_) + return powerWidget.level >= AndroidStationBlockEntity.ENERGY_PER_OPERATION && condition.invoke(itemStack) } } @@ -111,28 +112,15 @@ class AndroidStationMenu @JvmOverloads constructor( it.getCapability(ForgeCapabilities.ENERGY).isPresent } - override val storageSlots: ImmutableList - - val armorSlots = makeArmorSlots() + val equipment = makeEquipmentSlots() init { - for ((a, b) in armorSlots) { - addSlot(a) - if (b != null) addSlot(b) - } - addInventorySlots() - addSlot(androidBattery) + } - val builder = ImmutableList.builder() - - for ((a, _) in armorSlots) { - builder.add(a) - } - - builder.add(androidBattery) - storageSlots = builder.build() + override val storageSlots = immutableList { + accept(androidBattery) } override fun stillValid(player: Player): Boolean { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt index 04b0e8892..973327dc8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/EnergyServoMenu.kt @@ -33,6 +33,8 @@ class EnergyServoMenu @JvmOverloads constructor( } } + val equipment = makeEquipmentSlots() + val powerGauge = LevelGaugeWidget(this, tile?.energy) val itemConfig = ItemHandlerPlayerInput(this) val energyConfig = EnergyPlayerInput(this, true, true)