Skip to content

Commit 12ff687

Browse files
committed
🐛 增加对 null 值的过滤
1 parent 573967d commit 12ff687

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/main/kotlin/org/crashvibe/CalcStack/Command.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,11 @@ fun calculateStackInfo(quantity: Int, maxStackSize: Int, chestSize: Int): StackI
139139

140140
fun getIngredientsFromRecipe(recipe: Recipe): MutableList<ItemStack> {
141141
return when (recipe) {
142-
is ShapedRecipe -> recipe.choiceMap.values.mapNotNull { choice ->
143-
getRepresentativeItem(choice)
144-
}.toMutableList()
142+
is ShapedRecipe -> recipe.choiceMap.values
143+
.filterNotNull()
144+
.mapNotNull { choice ->
145+
getRepresentativeItem(choice)
146+
}.toMutableList()
145147

146148
is ShapelessRecipe -> recipe.choiceList.mapNotNull { choice ->
147149
getRepresentativeItem(choice)

0 commit comments

Comments
 (0)