Skip to content

Commit

Permalink
fix filter always requires nbt to match
Browse files Browse the repository at this point in the history
  • Loading branch information
deirn committed Feb 4, 2022
1 parent 16e4d04 commit 586ab6f
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,19 @@ class FilteredItemStorage(

}

private fun isValid(resource: ItemVariant) = if (filter.all { it.first.isEmpty }) true else {
val equals = filter.filter { resource.matches(it.first) }
private fun isValid(resource: ItemVariant): Boolean {
if (filter.all { it.first.isEmpty }) return true

if (equals.any { !it.second }) {
!blacklist
} else {
val nbt = equals.filter { it.second && resource.matches(it.first) }
if (blacklist) nbt.isEmpty() else nbt.isNotEmpty()
filter.forEach {
val stack = it.first
val matchNbt = it.second

if (resource.isOf(stack.item)) {
if (!matchNbt || resource.nbtMatches(stack.nbt)) return !blacklist
}
}

return blacklist
}

override fun canInsert(resource: ItemVariant) = (flag and FilterFlags.INSERT) == 0 || isValid(resource)
Expand Down

0 comments on commit 586ab6f

Please sign in to comment.