Misc improvements for CombinedContainer
This commit is contained in:
parent
6747d5f471
commit
6764af0dcc
@ -93,27 +93,7 @@ class CombinedContainer(containers: Stream<Pair<IEnhancedContainer, Iterable<Int
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun isEmpty(): Boolean {
|
override fun isEmpty(): Boolean {
|
||||||
if (fullCoverage.isNotEmpty())
|
return fullCoverage.all { it.isEmpty } && notFullCoverage.values.all { it.all { it.isEmpty } }
|
||||||
for (container in fullCoverage)
|
|
||||||
if (!container.isEmpty)
|
|
||||||
return false
|
|
||||||
|
|
||||||
if (notFullCoverage.isNotEmpty())
|
|
||||||
for (slots in notFullCoverage.values)
|
|
||||||
for (slot in slots)
|
|
||||||
if (!slot.isEmpty)
|
|
||||||
return false
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getItem(slot: Int): ItemStack {
|
|
||||||
// do not violate contract of getItem not throwing exceptions when index is invalid
|
|
||||||
return slots.getOrNull(slot)?.item ?: ItemStack.EMPTY
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun setItem(slot: Int, itemStack: ItemStack) {
|
|
||||||
slots.getOrNull(slot)?.item = itemStack
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setChanged() {
|
override fun setChanged() {
|
||||||
@ -123,11 +103,7 @@ class CombinedContainer(containers: Stream<Pair<IEnhancedContainer, Iterable<Int
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun stillValid(player: Player): Boolean {
|
override fun stillValid(player: Player): Boolean {
|
||||||
for (container in containers)
|
return containers.all { it.stillValid(player) }
|
||||||
if (!container.stillValid(player))
|
|
||||||
return false
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun iterator(): Iterator<ItemStack> {
|
override fun iterator(): Iterator<ItemStack> {
|
||||||
|
Loading…
Reference in New Issue
Block a user