Move Matter Hatch to Slotted Container
This commit is contained in:
parent
55c3c16172
commit
4dad60dfbb
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user