From 55c3c161724a52a86f46acc4b0e6f4d2d7e6c2d7 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 11 Mar 2025 21:10:19 +0700 Subject: [PATCH] Update Energy Interface to use SlottedContainer --- .../entity/tech/EnergyInterfaceBlockEntity.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyInterfaceBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyInterfaceBlockEntity.kt index 8a74c8afd..b99eda066 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyInterfaceBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/EnergyInterfaceBlockEntity.kt @@ -20,6 +20,8 @@ import ru.dbotthepony.mc.otm.capability.energy.ProfiledEnergyStorage import ru.dbotthepony.mc.otm.capability.moveEnergy import ru.dbotthepony.mc.otm.container.HandlerFilter import ru.dbotthepony.mc.otm.container.MatteryContainer +import ru.dbotthepony.mc.otm.container.slotted.AutomationFilters +import ru.dbotthepony.mc.otm.container.slotted.SlottedContainer import ru.dbotthepony.mc.otm.core.math.RelativeSide import ru.dbotthepony.mc.otm.core.multiblock.BlockEntityTag import ru.dbotthepony.mc.otm.core.multiblock.IMultiblockAccess @@ -56,13 +58,11 @@ class EnergyInterfaceBlockEntity( targets.invalidate() } - val container = object : MatteryContainer(::markDirtyFast, CAPACITY) { - override fun getMaxStackSize(slot: Int, itemStack: ItemStack): Int { - return 1 - } - }.also(::addDroppableContainer) + val container = SlottedContainer.simple( + CAPACITY, + if (isInput) AutomationFilters.DISCHARGABLE.limitedFilteredProvider else AutomationFilters.CHARGEABLE.limitedFilteredProvider, + ::markDirtyFast).also(::addDroppableContainer) - val itemHandler = container.handler(if (isInput) HandlerFilter.Dischargeable else HandlerFilter.Chargeable) private val neighbours = ArrayList>() override fun setRemoved() { @@ -75,7 +75,7 @@ class EnergyInterfaceBlockEntity( // it would cause a lot of frustration if hatches accept stuff only though one face exposeEnergyGlobally(energy) - exposeGlobally(Capabilities.ItemHandler.BLOCK, itemHandler) + exposeGlobally(Capabilities.ItemHandler.BLOCK, container) if (!isInput) { for (side in RelativeSide.entries) {