Make CombinedContainer temporarily implement old IMatteryContainer so it no longer crashes
This commit is contained in:
parent
ffdd44357d
commit
30263bf30e
@ -23,7 +23,7 @@ import ru.dbotthepony.mc.otm.core.isNotEmpty
|
||||
import ru.dbotthepony.mc.otm.core.stream
|
||||
import java.util.stream.Stream
|
||||
|
||||
class CombinedContainer(containers: Stream<Pair<IEnhancedContainer, Iterable<Int>>>) : ISlottedContainer {
|
||||
class CombinedContainer(containers: Stream<Pair<IEnhancedContainer, Iterable<Int>>>) : ISlottedContainer, IMatteryContainer {
|
||||
constructor(vararg containers: IEnhancedContainer) : this(containers.stream().map { it to (0 until it.containerSize) })
|
||||
constructor(containers: Collection<IEnhancedContainer>) : this(containers.stream().map { it to (0 until it.containerSize) })
|
||||
|
||||
@ -116,12 +116,28 @@ class CombinedContainer(containers: Stream<Pair<IEnhancedContainer, Iterable<Int
|
||||
)
|
||||
}
|
||||
|
||||
override fun slotIterator(): Iterator<IContainerSlot> {
|
||||
return slots.iterator()
|
||||
override fun slotIterator(): Iterator<IFilteredContainerSlot> {
|
||||
return slots.iterator().map {
|
||||
if (it is IFilteredContainerSlot) it else IFilteredContainerSlot.Dummy(it)
|
||||
}
|
||||
}
|
||||
|
||||
override fun containerSlot(slot: Int): IContainerSlot {
|
||||
return slots[slot]
|
||||
override fun containerSlot(slot: Int): IFilteredContainerSlot {
|
||||
val getSlot = slots[slot]
|
||||
if (getSlot is IFilteredContainerSlot) return getSlot
|
||||
return IFilteredContainerSlot.Dummy(getSlot)
|
||||
}
|
||||
|
||||
override fun getMaxStackSize(slot: Int, itemStack: ItemStack): Int {
|
||||
return super<ISlottedContainer>.getMaxStackSize(slot, itemStack)
|
||||
}
|
||||
|
||||
override fun getSlotFilter(slot: Int): Item? {
|
||||
return containerSlot(slot).filter
|
||||
}
|
||||
|
||||
override fun clearSlotFilters() {
|
||||
|
||||
}
|
||||
|
||||
override fun setChanged(slot: Int) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package ru.dbotthepony.mc.otm.container
|
||||
|
||||
import net.minecraft.world.Container
|
||||
import net.minecraft.world.item.Item
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.item.Items
|
||||
@ -26,4 +27,11 @@ interface IFilteredContainerSlot : IContainerSlot {
|
||||
return filter === item
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated("Dummy implementation")
|
||||
class Dummy(parent: IContainerSlot) : IFilteredContainerSlot, IContainerSlot by parent {
|
||||
override var filter: Item?
|
||||
get() = null
|
||||
set(value) {}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user