CombinedItemHandler no longer checks underlying handlers if they are mattery container handlers
This commit is contained in:
parent
d47e5b3d7a
commit
5b1d52489e
@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.capability
|
||||
import com.google.common.collect.ImmutableList
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraftforge.items.IItemHandler
|
||||
import ru.dbotthepony.mc.otm.container.ContainerHandler
|
||||
import java.util.stream.Stream
|
||||
|
||||
class CombinedItemHandler(val handlers: ImmutableList<IItemHandler>) : IItemHandler {
|
||||
@ -10,12 +11,20 @@ class CombinedItemHandler(val handlers: ImmutableList<IItemHandler>) : IItemHand
|
||||
constructor(handlers: Collection<IItemHandler>) : this(ImmutableList.copyOf(handlers))
|
||||
constructor(vararg handlers: IItemHandler) : this(ImmutableList.copyOf(handlers))
|
||||
|
||||
private val needsChecking = handlers.any { it !is ContainerHandler }
|
||||
private val lastSizes = IntArray(this.handlers.size)
|
||||
private var totalSize = 0
|
||||
private val mappings = ArrayList<Mapping>()
|
||||
private data class Mapping(val handler: IItemHandler, val slot: Int)
|
||||
|
||||
private fun check() {
|
||||
init {
|
||||
check(true)
|
||||
}
|
||||
|
||||
private fun check(force: Boolean = false) {
|
||||
if (!needsChecking && !force)
|
||||
return
|
||||
|
||||
for ((i, handler) in handlers.withIndex()) {
|
||||
var oldSize = lastSizes[i]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user