Revert mattery menu changes

This commit is contained in:
DBotThePony 2022-10-19 23:07:29 +07:00
parent 066921c981
commit e1be8dcfdb
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -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)
}
}