Derive hasEmptySlots, isEmpty, countItem from other methods

This commit is contained in:
DBotThePony 2025-03-14 23:10:25 +07:00
parent 69d9aaab50
commit 8b38504a26
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -219,17 +219,11 @@ interface IEnhancedContainer<out S : IContainerSlot> : Container, RecipeInput, I
} }
override fun isEmpty(): Boolean { override fun isEmpty(): Boolean {
return super.isEmpty() return nextNonEmptySlot(0) != -1
} }
val hasEmptySlots: Boolean get() { val hasEmptySlots: Boolean get() {
for (i in 0 until containerSize) { return nextEmptySlot(0) != -1
if (this[i].isEmpty) {
return true
}
}
return false
} }
override fun size(): Int { override fun size(): Int {
@ -239,11 +233,8 @@ interface IEnhancedContainer<out S : IContainerSlot> : Container, RecipeInput, I
override fun countItem(item: Item): Int { override fun countItem(item: Item): Int {
var count = 0 var count = 0
for (stack in this) { for (slot in slotWithItemIterator(item))
if (stack.item === item) { count += slot.item.count
count += stack.count
}
}
return count return count
} }