From e1be8dcfdb53a1577ece299ed6a5f1cec88f98c6 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 19 Oct 2022 23:07:29 +0700 Subject: [PATCH] Revert mattery menu changes --- .../ru/dbotthepony/mc/otm/menu/MatteryMenu.kt | 46 +++++++++---------- 1 file changed, 22 insertions(+), 24 deletions(-) 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 ef80c3241..ebb3719b0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/MatteryMenu.kt @@ -154,38 +154,36 @@ abstract class MatteryMenu @JvmOverloads protected constructor( protected fun addInventorySlots(autoFrame: Boolean = !ply.isSpectator) { check(_playerInventorySlots.isEmpty()) { "Already created inventory slots" } + autoCreateInventoryFrame = autoFrame + + for (i in 9 .. 35) { + val slot = InventorySlot(inventory, i) + + _playerInventorySlots.add(slot) + _playerMainSlots.add(slot) + _playerCombinedInventorySlots.add(slot) + addSlot(slot) + } val mattery = ply.matteryPlayer - // trick minecraft's code into thinking that slots come from contiguous container - val proxyBuilder = ContainerProxy.Builder() - - proxyBuilder.add(inventory, 0 .. 35) - if (mattery != null && mattery.hasExoSuit) { - proxyBuilder.add(mattery.exoSuitContainer) + for (i in 0 until mattery.exoSuitContainer.containerSize) { + val slot = InventorySlot(mattery.exoSuitContainer, i) + + _playerInventorySlots.add(slot) + _playerExoSuitSlots.add(slot) + _playerCombinedInventorySlots.add(slot) + addSlot(slot) + } } - val proxy = proxyBuilder.build() + for (i in 0..8) { + val slot = InventorySlot(inventory, i) - autoCreateInventoryFrame = autoFrame - - for (slotId in 0 until proxy.containerSize) { - val slot = InventorySlot(proxy, slotId) - - if (slotId in 0 .. 8) { - _playerHotbarSlots.add(slot) - addSlot(slot) - continue - } else if (slotId in 9 .. 35) { - _playerMainSlots.add(slot) - } else { - _playerExoSuitSlots.add(slot) - } - - _playerInventorySlots.add(slot) - _playerCombinedInventorySlots.add(slot) addSlot(slot) + _playerInventorySlots.add(slot) + _playerHotbarSlots.add(slot) } }