Skip to content

Commit

Permalink
Fix crash in Fishing Port when no recipe is found (GTNewHorizons#3547)
Browse files Browse the repository at this point in the history
Co-authored-by: Maya <[email protected]>
  • Loading branch information
wlhlm and serenibyss authored Nov 24, 2024
1 parent 9ce867e commit 4124309
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main/java/gtPlusPlus/core/util/data/ArrayUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import java.util.Collections;
import java.util.List;

import javax.annotation.Nonnull;

import net.minecraft.item.ItemStack;

public class ArrayUtils {
Expand All @@ -21,13 +23,13 @@ public static <V> V[] insertElementAtIndex(V[] aArray, int aIndex, V aObjectToIn
return newArray;
}

public static Object[] removeNulls(final Object[] v) {
public static Object[] removeNulls(@Nonnull final Object[] v) {
List<Object> list = new ArrayList<>(Arrays.asList(v));
list.removeAll(Collections.singleton(null));
return list.toArray(new Object[0]);
}

public static ItemStack[] removeNulls(final ItemStack[] v) {
public static ItemStack[] removeNulls(@Nonnull final ItemStack[] v) {
List<ItemStack> list = new ArrayList<>(Arrays.asList(v));
list.removeAll(Collections.singleton((ItemStack) null));
return list.toArray(new ItemStack[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@ protected boolean filtersFluid() {
setModeFromInputStacks(tItemInputs);

ItemStack[] mFishOutput = generateLoot();
if (mFishOutput == null) {
return CheckRecipeResultRegistry.NO_RECIPE;
}

mFishOutput = removeNulls(mFishOutput);
GTRecipe g = new GTRecipe(
true,
Expand Down

0 comments on commit 4124309

Please sign in to comment.