diff --git a/src/main/java/gregtech/api/recipes/RecipeMap.java b/src/main/java/gregtech/api/recipes/RecipeMap.java index bf5b7dd4a9d..b9dd46b2a98 100644 --- a/src/main/java/gregtech/api/recipes/RecipeMap.java +++ b/src/main/java/gregtech/api/recipes/RecipeMap.java @@ -18,7 +18,6 @@ import gregtech.api.gui.widgets.SlotWidget; import gregtech.api.gui.widgets.TankWidget; import gregtech.api.recipes.builders.IntCircuitRecipeBuilder; -import gregtech.api.recipes.builders.SimpleRecipeBuilder; import gregtech.api.recipes.crafttweaker.CTRecipe; import gregtech.api.recipes.crafttweaker.CTRecipeBuilder; import gregtech.api.unification.material.Material; @@ -407,8 +406,8 @@ protected void addInventorySlotGroup(ModularUI.Builder builder, IItemHandlerModi int itemSlotsToDown = inputSlotGrid[1]; int startInputsX = isOutputs ? 106 : 70 - itemSlotsToLeft * 18; int startInputsY = 33 - (int) (itemSlotsToDown / 2.0 * 18) + yOffset; - boolean wasGroupOutput = itemHandler.getSlots() + fluidHandler.getTanks() == 12; - if (wasGroupOutput && isOutputs) startInputsY -= 9; + boolean wasGroup = itemHandler.getSlots() + fluidHandler.getTanks() == 12; + if (wasGroup) startInputsY -= 9; if (itemHandler.getSlots() == 6 && fluidHandler.getTanks() == 2 && !isOutputs) startInputsY -= 9; for (int i = 0; i < itemSlotsToDown; i++) { for (int j = 0; j < itemSlotsToLeft; j++) { @@ -419,7 +418,7 @@ protected void addInventorySlotGroup(ModularUI.Builder builder, IItemHandlerModi addSlot(builder, x, y, slotIndex, itemHandler, fluidHandler, invertFluids, isOutputs); } } - if (wasGroupOutput) startInputsY += 2; + if (wasGroup) startInputsY += 2; if (fluidInputsCount > 0 || invertFluids) { if (itemSlotsToDown >= fluidInputsCount && itemSlotsToLeft < 3) { int startSpecX = isOutputs ? startInputsX + itemSlotsToLeft * 18 : startInputsX - 18; diff --git a/src/main/java/gregtech/integration/jei/recipe/RecipeMapCategory.java b/src/main/java/gregtech/integration/jei/recipe/RecipeMapCategory.java index 6f608617bdb..51b6e293f24 100644 --- a/src/main/java/gregtech/integration/jei/recipe/RecipeMapCategory.java +++ b/src/main/java/gregtech/integration/jei/recipe/RecipeMapCategory.java @@ -9,6 +9,7 @@ import gregtech.api.gui.widgets.ProgressWidget; import gregtech.api.gui.widgets.SlotWidget; import gregtech.api.gui.widgets.TankWidget; +import gregtech.api.recipes.Recipe; import gregtech.api.recipes.Recipe.ChanceEntry; import gregtech.api.recipes.RecipeMap; import gregtech.integration.jei.utils.render.FluidStackTextRenderer; @@ -41,9 +42,8 @@ public class RecipeMapCategory implements IRecipeCategory { private final FluidTankList importFluids, exportFluids; private final IDrawable backgroundDrawable; - private final int FONT_HEIGHT = 9; + private static final int FONT_HEIGHT = 9; private static final HashMap, RecipeMapCategory> categoryMap = new HashMap<>(); - private double timer = 0; public RecipeMapCategory(RecipeMap recipeMap, IGuiHelper guiHelper) { this.recipeMap = recipeMap; @@ -57,12 +57,10 @@ public RecipeMapCategory(RecipeMap recipeMap, IGuiHelper guiHelper) { (importItems = new ItemStackHandler(recipeMap.getMaxInputs())), (exportItems = new ItemStackHandler(recipeMap.getMaxOutputs())), (importFluids = new FluidTankList(false, importFluidTanks)), - (exportFluids = new FluidTankList(false, exportFluidTanks)), - (recipeMap.getMaxOutputs() >= 6 || recipeMap.getMaxInputs() >= 6 || - recipeMap.getMaxFluidOutputs() >= 6 || recipeMap.getMaxFluidInputs() >= 6) ? FONT_HEIGHT : 0 + (exportFluids = new FluidTankList(false, exportFluidTanks)), 0 ).build(new BlankUIHolder(), Minecraft.getMinecraft().player); this.modularUI.initWidgets(); - this.backgroundDrawable = guiHelper.createBlankDrawable(modularUI.getWidth(), modularUI.getHeight() * 2 / 3); + this.backgroundDrawable = guiHelper.createBlankDrawable(modularUI.getWidth(), modularUI.getHeight() * 2 / 3 + getPropertyShiftAmount(recipeMap)); categoryMap.put(recipeMap, this); } @@ -179,4 +177,20 @@ public void drawExtras(@Nonnull Minecraft minecraft) { public static HashMap, RecipeMapCategory> getCategoryMap() { return categoryMap; } + + private static boolean shouldShiftWidgets(@Nonnull RecipeMap recipeMap) { + return recipeMap.getMaxOutputs() >= 6 || recipeMap.getMaxInputs() >= 6 || + recipeMap.getMaxFluidOutputs() >= 6 || recipeMap.getMaxFluidInputs() >= 6; + } + + private static int getPropertyShiftAmount(@Nonnull RecipeMap recipeMap) { + int maxPropertyCount = 0; + if (shouldShiftWidgets(recipeMap)) { + for (Recipe recipe : recipeMap.getRecipeList()) { + if (recipe.getPropertyCount() > maxPropertyCount) + maxPropertyCount = recipe.getPropertyCount(); + } + } + return maxPropertyCount * FONT_HEIGHT; + } }