Guide-API

Guide-API

76M Downloads

[1.12] GuideAPI crashed rendering ShapelessRecipes

desht opened this issue ยท 1 comments

commented

I got this when trying to render a shapeless recipe in my guide book:

Caused by: java.lang.IndexOutOfBoundsException: Index: 2, Size: 2
	at java.util.ArrayList.rangeCheck(ArrayList.java:653) ~[?:1.8.0_131]
	at java.util.ArrayList.get(ArrayList.java:429) ~[?:1.8.0_131]
	at net.minecraft.util.NonNullList.get(NonNullList.java:51) ~[NonNullList.class:?]
	at amerifrance.guideapi.page.reciperenderer.ShapelessRecipesRenderer.draw(ShapelessRecipesRenderer.java:33) ~[ShapelessRecipesRenderer.class:1.12-2.1.2-53]
	at amerifrance.guideapi.page.PageIRecipe.draw(PageIRecipe.java:59) ~[PageIRecipe.class:1.12-2.1.2-53]
	at amerifrance.guideapi.wrapper.PageWrapper.draw(PageWrapper.java:50) ~[PageWrapper.class:1.12-2.1.2-53]
	at amerifrance.guideapi.gui.GuiEntry.drawScreen(GuiEntry.java:82) ~[GuiEntry.class:1.12-2.1.2-53]
	at net.minecraftforge.client.ForgeHooksClient.drawScreen(ForgeHooksClient.java:382) ~[ForgeHooksClient.class:?]
	at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1168) ~[EntityRenderer.class:?]
	... 15 more

Looking at ShapelessRecipesRenderer, it appears to make an assumption that the recipe contains 9 ingredients:

for (int y = 0; y < 3; y++) {
            for (int x = 0; x < 3; x++) {
                int i = 3 * y + x;
                int stackX = (x + 1) * 17 + (guiLeft + 27) + x;
                int stackY = (y + 1) * 17 + (guiTop + 38) + y;

                Ingredient ingredient = recipe.getIngredients().get(i);

when my shapeless recipes generally only have 2 or 3 ingredients in them.

commented

Oh, I forgot to merge #72 when I got home yesterday