diff --git a/src/main/java/fi/dy/masa/itemscroller/event/KeybindCallbacks.java b/src/main/java/fi/dy/masa/itemscroller/event/KeybindCallbacks.java index 7b3c4e038..602e49822 100644 --- a/src/main/java/fi/dy/masa/itemscroller/event/KeybindCallbacks.java +++ b/src/main/java/fi/dy/masa/itemscroller/event/KeybindCallbacks.java @@ -227,13 +227,10 @@ public void onClientTick(MinecraftClient mc) } RecipePattern recipe = RecipeStorage.getInstance().getSelectedRecipe(); - if (recipe.getVanillaRecipe() == null) { - recipe.lookupVanillaRecipe(mc.world); - } int limit = Configs.Generic.MASS_CRAFT_ITERATIONS.getIntegerValue(); - if (Configs.Generic.MASS_CRAFT_RECIPE_BOOK.getBooleanValue() && recipe.getVanillaRecipe() != null) + if (Configs.Generic.MASS_CRAFT_RECIPE_BOOK.getBooleanValue() && recipe.lookupVanillaRecipe(mc.world) != null) { InventoryUtils.dontUpdateRecipeBook = true; for (int i = 0; i < limit; ++i) diff --git a/src/main/java/fi/dy/masa/itemscroller/recipes/RecipePattern.java b/src/main/java/fi/dy/masa/itemscroller/recipes/RecipePattern.java index 5480b7e32..085cea30d 100644 --- a/src/main/java/fi/dy/masa/itemscroller/recipes/RecipePattern.java +++ b/src/main/java/fi/dy/masa/itemscroller/recipes/RecipePattern.java @@ -55,7 +55,9 @@ public void ensureRecipeSizeAndClearRecipe(int size) this.clearRecipe(); } - public void lookupVanillaRecipe(World world) { + @Nullable + public Recipe lookupVanillaRecipe(World world) { + //Assume all recipes here are of type CraftingRecipe this.vanillaRecipe = null; var mc = MinecraftClient.getInstance(); int recipeSize; @@ -69,7 +71,7 @@ else if (recipe.length == 9) } else { - return; + return null; } for (RecipeEntry match : mc.world.getRecipeManager().getAllMatches(RecipeType.CRAFTING, CraftingRecipeInput.create(recipeSize, recipeSize, Arrays.asList(recipe)), world)) @@ -77,9 +79,10 @@ else if (recipe.length == 9) if (InventoryUtils.areStacksEqual(result, match.value().getResult(world.getRegistryManager()))) { this.vanillaRecipe = match; - return; + return (Recipe) match.value(); } } + return null; } public void storeCraftingRecipe(Slot slot, HandledScreen gui, boolean clearIfEmpty) @@ -224,7 +227,7 @@ public RecipeEntry getVanillaRecipeEntry() @Nullable public Recipe getVanillaRecipe() { - if (vanillaRecipe == null) + if (recipe == null) { return null; }