Make battery slot be filterable

This commit is contained in:
DBotThePony 2025-03-07 10:24:50 +07:00
parent d88da8f244
commit 51be2c89f4
Signed by: DBot
GPG Key ID: DCC23B5715498507
3 changed files with 3 additions and 3 deletions

View File

@ -12,7 +12,7 @@ import ru.dbotthepony.mc.otm.container.slotted.SlottedContainer
import ru.dbotthepony.mc.otm.core.math.Decimal
abstract class MatteryPoweredBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: BlockPos, p_155230_: BlockState) : MatteryDeviceBlockEntity(p_155228_, p_155229_, p_155230_) {
val batteryContainer = SlottedContainer.simple(1, AutomationFilters.DISCHARGABLE.simpleProvider, ::markDirtyFast).also(::addDroppableContainer)
val batteryContainer = SlottedContainer.simple(1, AutomationFilters.DISCHARGABLE.filteredProvider, ::markDirtyFast).also(::addDroppableContainer)
open val energy: IMatteryEnergyStorage?
get() = null

View File

@ -16,7 +16,7 @@ abstract class MatteryPoweredMenu protected constructor(
tile: MatteryPoweredBlockEntity? = null
) : MatteryMenu(menuType, containerID, inventory, tile) {
val energyWidget = LevelGaugeWidget(this, tile?.energy)
val batterySlot = BatteryMenuSlot(tile?.batteryContainer ?: SlottedContainer.simple(1), 0)
val batterySlot = BatteryMenuSlot(tile?.batteryContainer ?: SlottedContainer.filtered(1), 0)
val redstoneConfig = EnumInputWithFeedback<RedstoneSetting>(this)
init {

View File

@ -140,7 +140,7 @@ open class OutputMenuSlot(container: Container, index: Int, x: Int = 0, y: Int =
}
}
open class BatteryMenuSlot(container: Container, index: Int, x: Int = 0, y: Int = 0) : MatteryMenuSlot(container, index, x, y) {
open class BatteryMenuSlot(container: Container, index: Int, x: Int = 0, y: Int = 0) : UserFilteredMenuSlot(container, index, x, y) {
override fun mayPlace(itemStack: ItemStack): Boolean {
return super.mayPlace(itemStack) && (itemStack.energy?.canExtract() ?: false)
}