Merge ChargeMenuSlot into BatteryMenuSlot

This commit is contained in:
DBotThePony 2025-03-12 16:49:19 +07:00
parent 4dad60dfbb
commit e699147f9f
Signed by: DBot
GPG Key ID: DCC23B5715498507
2 changed files with 5 additions and 8 deletions

View File

@ -33,6 +33,7 @@ import ru.dbotthepony.kommons.util.Delegate
import ru.dbotthepony.kommons.util.getValue
import ru.dbotthepony.kommons.util.setValue
import ru.dbotthepony.mc.otm.OverdriveThatMatters
import ru.dbotthepony.mc.otm.capability.FlowDirection
import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage
import ru.dbotthepony.mc.otm.capability.matteryPlayer
import ru.dbotthepony.mc.otm.compat.cos.cosmeticArmorSlots
@ -311,10 +312,10 @@ abstract class MatteryMenu(
}
if (mattery.hasExopack) {
_exopackChargeSlots.add(BatteryMenuSlot(mattery.exopackEnergy.parent, 0).also { mapQuickMoveToExternal(it); mapQuickMoveToInventory(it); addSlot(it) })
_exopackChargeSlots.add(BatteryMenuSlot(mattery.exopackEnergy.parent, 0, direction = FlowDirection.OUTPUT).also { mapQuickMoveToExternal(it); mapQuickMoveToInventory(it); addSlot(it) })
for (i in 0 until mattery.exopackChargeSlots.containerSize)
_exopackChargeSlots.add(ChargeMenuSlot(mattery.exopackChargeSlots, i).also { mapQuickMoveToExternal(it); mapQuickMoveToInventory(it); addSlot(it) })
_exopackChargeSlots.add(BatteryMenuSlot(mattery.exopackChargeSlots, i, direction = FlowDirection.INPUT).also { mapQuickMoveToExternal(it); mapQuickMoveToInventory(it); addSlot(it) })
}
sortInventoryInput = SortInput(mattery.inventoryAndExopackNoHotbar, playerSortSettings)

View File

@ -16,6 +16,7 @@ import ru.dbotthepony.mc.otm.capability.IMatteryUpgrade
import ru.dbotthepony.mc.otm.capability.MatteryCapability
import ru.dbotthepony.mc.otm.capability.UpgradeType
import ru.dbotthepony.mc.otm.capability.energy
import ru.dbotthepony.mc.otm.capability.energy.IMatteryEnergyStorage
import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.container.EnhancedContainer
import ru.dbotthepony.mc.otm.container.IEnhancedContainer
@ -146,6 +147,7 @@ open class BatteryMenuSlot(container: Container, index: Int, x: Int = 0, y: Int
return false
val energy = itemStack.energy ?: return false
if (energy is IMatteryEnergyStorage) return direction.test(energy.energyFlow)
return direction.test(FlowDirection.of(energy.canReceive(), energy.canExtract()))
}
}
@ -156,12 +158,6 @@ open class ChemicalFuelMenuSlot(container: Container, index: Int, x: Int = 0, y:
}
}
open class ChargeMenuSlot(container: Container, index: Int, x: Int = 0, y: Int = 0) : MatteryMenuSlot(container, index, x, y) {
override fun mayPlace(itemStack: ItemStack): Boolean {
return super.mayPlace(itemStack) && (itemStack.energy?.canReceive() ?: false)
}
}
open class MatterContainerInputMenuSlot(
container: Container,
index: Int,