diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/AndroidStationScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/AndroidStationScreen.kt index ba12944ba..f51d30da0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/AndroidStationScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/AndroidStationScreen.kt @@ -706,11 +706,8 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I val playerStrip = EditablePanel(this, frame, height = 72f) playerStrip.dock = Dock.TOP - val armorStrip = EditablePanel(this, playerStrip, width = AbstractSlotPanel.SIZE) - armorStrip.dock = Dock.LEFT - - for (slot in menu.armorSlots) { - SlotPanel(this, armorStrip, slot).also { it.dock = Dock.TOP } + makeArmorStrip(menu.armorSlots, playerStrip).also { + it.dock = Dock.LEFT } EntityRendererPanel(this, playerStrip, minecraft!!.player!!).also { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoSuitInventoryScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoSuitInventoryScreen.kt index 6f2414fcd..6980f74fd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoSuitInventoryScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/ExoSuitInventoryScreen.kt @@ -101,26 +101,8 @@ class ExoSuitInventoryScreen(menu: ExoSuitInventoryMenu) : 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/menu/AndroidStationMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/AndroidStationMenu.kt index 2267d6c65..c1a8c141c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/AndroidStationMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/AndroidStationMenu.kt @@ -117,13 +117,21 @@ class AndroidStationMenu @JvmOverloads constructor( val armorSlots = makeArmorSlots() init { - armorSlots.forEach(this::addSlot) + for ((a, b) in armorSlots) { + addSlot(a) + if (b != null) addSlot(b) + } + addInventorySlots() addSlot(androidBattery) val builder = ImmutableList.builder() - builder.addAll(armorSlots) + + for ((a, _) in armorSlots) { + builder.add(a) + } + builder.add(androidBattery) storageSlots = builder.build() } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoSuitInventoryMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoSuitInventoryMenu.kt index 5cc6ab842..d3a31b0f5 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoSuitInventoryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/ExoSuitInventoryMenu.kt @@ -51,7 +51,7 @@ class ExoSuitInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen } } - val armorSlots: List = makeArmorSlots() + val armorSlots: List> = makeArmorSlots() val offhandSlot = object : InventorySlot(capability.ply.inventory, 40) { override fun getNoItemIcon(): Pair { @@ -66,7 +66,11 @@ class ExoSuitInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen craftingSlots.forEach(this::addSlot) addSlot(offhandSlot) - armorSlots.forEach(this::addSlot) + + for ((a, b) in armorSlots) { + addSlot(a) + if (b != null) addSlot(b) + } val builder = ImmutableList.builder() @@ -86,8 +90,6 @@ class ExoSuitInventoryMenu(val capability: MatteryPlayerCapability) : MatteryMen } } - val cosmeticArmorSlots: Map = ply.cosmeticArmorSlots?.also { it.values.forEach(this::addSlot) } ?: mapOf() - override fun slotsChanged(container: Container) { super.slotsChanged(container) 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 546bca1aa..b3a675162 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -18,6 +18,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.AbstractSlotPanel import ru.dbotthepony.mc.otm.client.screen.panels.Dock import ru.dbotthepony.mc.otm.client.screen.panels.EditablePanel import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel +import ru.dbotthepony.mc.otm.compat.cos.cosmeticArmorSlots import ru.dbotthepony.mc.otm.container.ItemFilter import ru.dbotthepony.mc.otm.container.ItemFilterNetworkSlot import ru.dbotthepony.mc.otm.menu.widget.AbstractWidget @@ -431,12 +432,16 @@ abstract class MatteryMenu @JvmOverloads protected constructor( super.addDataSlots(p_38885_) } - fun makeArmorSlots(): List = ImmutableList.of( - EquipmentSlot(net.minecraft.world.entity.EquipmentSlot.HEAD), - EquipmentSlot(net.minecraft.world.entity.EquipmentSlot.CHEST), - EquipmentSlot(net.minecraft.world.entity.EquipmentSlot.LEGS), - EquipmentSlot(net.minecraft.world.entity.EquipmentSlot.FEET), - ) + 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), + ) + } companion object { val TEXTURE_EMPTY_SLOTS: List = ImmutableList.of(