From 00e919b6c7d13065e394561410dab8873091e5cf Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Tue, 16 Jul 2024 16:15:36 +0200 Subject: [PATCH] Unusual Crafting - Fixed crash with JEI when a modded crafting recipe has an inconsistent ingredient list #6368 #6494 --- .../category/MechanicalCraftingCategory.java | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/simibubi/create/compat/jei/category/MechanicalCraftingCategory.java b/src/main/java/com/simibubi/create/compat/jei/category/MechanicalCraftingCategory.java index 33e0c52399..334c065dd8 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/MechanicalCraftingCategory.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/MechanicalCraftingCategory.java @@ -99,16 +99,21 @@ public void draw(CraftingRecipe recipe, IRecipeSlotsView iRecipeSlotsView, PoseS matrixStack.translate(getXPadding(recipe), getYPadding(recipe), 0); for (int row = 0; row < getHeight(recipe); row++) - for (int col = 0; col < getWidth(recipe); col++) - if (!recipe.getIngredients() - .get(row * getWidth(recipe) + col) - .isEmpty()) { - matrixStack.pushPose(); - matrixStack.translate(col * 19 * scale, row * 19 * scale, 0); - matrixStack.scale(scale, scale, scale); - AllGuiTextures.JEI_SLOT.render(matrixStack, 0, 0); - matrixStack.popPose(); - } + for (int col = 0; col < getWidth(recipe); col++) { + int pIndex = row * getWidth(recipe) + col; + if (pIndex >= recipe.getIngredients() + .size()) + break; + if (recipe.getIngredients() + .get(pIndex) + .isEmpty()) + continue; + matrixStack.pushPose(); + matrixStack.translate(col * 19 * scale, row * 19 * scale, 0); + matrixStack.scale(scale, scale, scale); + AllGuiTextures.JEI_SLOT.render(matrixStack, 0, 0); + matrixStack.popPose(); + } matrixStack.popPose();