diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/MatterHatchBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/MatterHatchBlockEntity.kt index f03a7aaf7..7a85e84e0 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/MatterHatchBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/tech/MatterHatchBlockEntity.kt @@ -17,6 +17,8 @@ import ru.dbotthepony.mc.otm.capability.moveMatter import ru.dbotthepony.mc.otm.config.MachinesConfig 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.Decimal import ru.dbotthepony.mc.otm.core.multiblock.BlockEntityTag import ru.dbotthepony.mc.otm.menu.tech.MatterHatchMenu @@ -28,26 +30,15 @@ class MatterHatchBlockEntity( blockPos: BlockPos, blockState: BlockState ) : MatteryDeviceBlockEntity(type, blockPos, blockState) { - 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.MATTER_PROVIDERS.limitedFilteredProvider else AutomationFilters.MATTER_CONSUMERS.limitedFilteredProvider, ::markDirtyFast).also(::addDroppableContainer) val matter = ProfiledMatterStorage(MatterStorageImpl(this::markDirtyFast, FlowDirection.input(isInput), MachinesConfig::MATTER_HATCH)) - val itemHandler = if (isInput) { - container.handler(HandlerFilter.MatterProviders) - } else { - container.handler(HandlerFilter.MatterConsumers) - } - init { savetables.stateful(::container, INVENTORY_KEY) savetables.stateful(::matter, MATTER_STORAGE_KEY) // it would cause a lot of frustration if hatches accept stuff only though one face - exposeGlobally(Capabilities.ItemHandler.BLOCK, itemHandler) + exposeGlobally(Capabilities.ItemHandler.BLOCK, container) exposeGlobally(MatteryCapability.MATTER_BLOCK, matter) } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt index 9042393d5..807822264 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/Slots.kt @@ -168,7 +168,7 @@ open class MatterContainerInputMenuSlot( x: Int = 0, y: Int = 0, val direction: FlowDirection = FlowDirection.BI_DIRECTIONAL -) : MatteryMenuSlot(container, index, x, y) { +) : UserFilteredMenuSlot(container, index, x, y) { override fun mayPlace(itemStack: ItemStack): Boolean { val handler = itemStack.getCapability(MatteryCapability.MATTER_ITEM) return handler != null && super.mayPlace(itemStack) && this.direction.test(handler.matterFlow) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/MatterHatchMenu.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/MatterHatchMenu.kt index db04cf5ea..f61088744 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/MatterHatchMenu.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/tech/MatterHatchMenu.kt @@ -6,6 +6,8 @@ import net.minecraft.world.entity.player.Inventory import ru.dbotthepony.mc.otm.block.entity.RedstoneSetting import ru.dbotthepony.mc.otm.block.entity.tech.MatterHatchBlockEntity import ru.dbotthepony.mc.otm.capability.FlowDirection +import ru.dbotthepony.mc.otm.container.slotted.AutomationFilters +import ru.dbotthepony.mc.otm.container.slotted.SlottedContainer import ru.dbotthepony.mc.otm.menu.MatterContainerInputMenuSlot import ru.dbotthepony.mc.otm.menu.MatteryMenu import ru.dbotthepony.mc.otm.menu.input.EnumInputWithFeedback @@ -19,7 +21,7 @@ class MatterHatchMenu( inventory: Inventory, tile: MatterHatchBlockEntity? = null ) : MatteryMenu(if (isInput) MMenus.MATTER_INPUT_HATCH else MMenus.MATTER_OUTPUT_HATCH, containerId, inventory, tile) { - val container: Container = tile?.container ?: SimpleContainer(MatterHatchBlockEntity.CAPACITY) + val container: Container = tile?.container ?: SlottedContainer.simple(MatterHatchBlockEntity.CAPACITY, if (isInput) AutomationFilters.MATTER_PROVIDERS.limitedFilteredProvider else AutomationFilters.MATTER_CONSUMERS.limitedFilteredProvider) val inputSlots = makeSlots(container) { a, b -> MatterContainerInputMenuSlot(a, b, direction = FlowDirection.input(isInput))