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