More specific methods in enhanced container interface
This commit is contained in:
parent
5422f0fec8
commit
c31549792e
@ -88,15 +88,27 @@ interface IEnhancedContainer : IContainer, RecipeInput, Iterable<ItemStack>, Sta
|
||||
}
|
||||
}
|
||||
|
||||
fun emptySlotIterator(allowedSlots: IntCollection = slotRange): IntIterator {
|
||||
fun emptySlotIndexIterator(): IntIterator {
|
||||
return emptySlotIndexIterator(slotRange)
|
||||
}
|
||||
|
||||
fun nonEmptySlotIndexIterator(): IntIterator {
|
||||
return nonEmptySlotIndexIterator(slotRange)
|
||||
}
|
||||
|
||||
fun emptySlotIndexIterator(allowedSlots: IntCollection): IntIterator {
|
||||
return slotIterator(allowedSlots) { it.isEmpty }
|
||||
}
|
||||
|
||||
fun nonEmptySlotIterator(allowedSlots: IntCollection = slotRange): IntIterator {
|
||||
fun nonEmptySlotIndexIterator(allowedSlots: IntCollection): IntIterator {
|
||||
return slotIterator(allowedSlots) { it.isNotEmpty }
|
||||
}
|
||||
|
||||
fun slotWithItemIterator(item: Item, allowedSlots: IntCollection = slotRange): IntIterator {
|
||||
fun slotWithItemIterator(item: Item): IntIterator {
|
||||
return slotWithItemIterator(item, slotRange)
|
||||
}
|
||||
|
||||
fun slotWithItemIterator(item: Item, allowedSlots: IntCollection): IntIterator {
|
||||
return slotIterator(allowedSlots) { it.isNotEmpty && it.item === item }
|
||||
}
|
||||
|
||||
@ -234,7 +246,7 @@ interface IEnhancedContainer : IContainer, RecipeInput, Iterable<ItemStack>, Sta
|
||||
|
||||
if (!onlyIntoExisting) {
|
||||
// двигаем в пустые слоты
|
||||
for (slot in emptySlotIterator(slots)) {
|
||||
for (slot in emptySlotIndexIterator(slots)) {
|
||||
val diff = copy.count.coerceAtMost(getMaxStackSize(slot, stack))
|
||||
|
||||
if (!simulate) {
|
||||
|
@ -2,12 +2,8 @@ package ru.dbotthepony.mc.otm.container
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.IntCollection
|
||||
import it.unimi.dsi.fastutil.ints.IntSet
|
||||
import net.minecraft.world.Container
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.neoforged.neoforge.items.IItemHandler
|
||||
import ru.dbotthepony.kommons.collect.any
|
||||
import ru.dbotthepony.mc.otm.core.collect.filter
|
||||
import ru.dbotthepony.mc.otm.core.collect.map
|
||||
|
||||
/**
|
||||
* Skeletal implementation for containers which revolve around [IContainerSlot]
|
||||
@ -80,7 +76,7 @@ interface ISlottedContainer : IEnhancedContainer {
|
||||
}
|
||||
|
||||
if (!onlyIntoExisting) {
|
||||
for (i in emptySlotIterator(slots)) {
|
||||
for (i in emptySlotIndexIterator(slots)) {
|
||||
val slot = containerSlot(i)
|
||||
|
||||
val condition: Boolean
|
||||
|
Loading…
Reference in New Issue
Block a user