From 1d6c6139ec3f5e56e266f2f2caccadd0a921374b Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Fri, 29 Dec 2017 18:12:04 +0000 Subject: [PATCH] Move JEI item pane out of the way if the slot config goes of the side of the screen. --- .../client/gui/slot/GuiSlotConfiguration.java | 13 ++++++++++ .../gui/slot/elements/ConfigSlotElement.java | 2 ++ .../client/gui/slot/elements/ElementBase.java | 8 ++++++ .../compat/jei/TechRebornJeiPlugin.java | 26 +++++++++++++++++++ 4 files changed, 49 insertions(+) diff --git a/src/main/java/techreborn/client/gui/slot/GuiSlotConfiguration.java b/src/main/java/techreborn/client/gui/slot/GuiSlotConfiguration.java index a27296e0c..62e1a5db7 100644 --- a/src/main/java/techreborn/client/gui/slot/GuiSlotConfiguration.java +++ b/src/main/java/techreborn/client/gui/slot/GuiSlotConfiguration.java @@ -39,6 +39,7 @@ import techreborn.client.gui.slot.elements.SlotType; import java.awt.*; import java.io.IOException; +import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -190,4 +191,16 @@ public class GuiSlotConfiguration { return clicked; } + public static List getExtraSpace(GuiBase guiBase){ + if(!GuiBase.showSlotConfig || slectedSlot == -1){ + return Collections.emptyList(); + } + List list = new ArrayList<>(); + ConfigSlotElement slotElement = slotElementMap.get(slectedSlot); + + //I have no idea why this works, but it does. pls fix if you know how. + list.add(new Rectangle(slotElement.adjustX(guiBase, slotElement.getX()) + guiBase.getGuiLeft(), slotElement.adjustY(guiBase, 0), slotElement.getWidth() - 20, slotElement.getHeight())); + return list; + } + } diff --git a/src/main/java/techreborn/client/gui/slot/elements/ConfigSlotElement.java b/src/main/java/techreborn/client/gui/slot/elements/ConfigSlotElement.java index ac6ee9987..1b198e3b8 100644 --- a/src/main/java/techreborn/client/gui/slot/elements/ConfigSlotElement.java +++ b/src/main/java/techreborn/client/gui/slot/elements/ConfigSlotElement.java @@ -84,6 +84,8 @@ public class ConfigSlotElement extends ElementBase { popupElement.filter = true; } } + setWidth(85); + setHeight(105 + (filter ? 15 : 0)); } @Override diff --git a/src/main/java/techreborn/client/gui/slot/elements/ElementBase.java b/src/main/java/techreborn/client/gui/slot/elements/ElementBase.java index 2183088f3..b4d064697 100644 --- a/src/main/java/techreborn/client/gui/slot/elements/ElementBase.java +++ b/src/main/java/techreborn/client/gui/slot/elements/ElementBase.java @@ -185,6 +185,14 @@ public class ElementBase { return height; } + public int getWidth() { + return width; + } + + public int getHeight() { + return height; + } + public ElementBase addHoverAction(ElementBase.Action action) { this.hoverActions.add(action); return this; diff --git a/src/main/java/techreborn/compat/jei/TechRebornJeiPlugin.java b/src/main/java/techreborn/compat/jei/TechRebornJeiPlugin.java index fab6a71b0..f5b3fe860 100644 --- a/src/main/java/techreborn/compat/jei/TechRebornJeiPlugin.java +++ b/src/main/java/techreborn/compat/jei/TechRebornJeiPlugin.java @@ -25,6 +25,7 @@ package techreborn.compat.jei; import mezz.jei.api.*; +import mezz.jei.api.gui.IAdvancedGuiHandler; import mezz.jei.api.recipe.IRecipeCategoryRegistration; import mezz.jei.api.recipe.VanillaRecipeCategoryUid; import mezz.jei.api.recipe.transfer.IRecipeTransferRegistry; @@ -56,6 +57,7 @@ import techreborn.api.recipe.ScrapboxRecipe; import techreborn.api.recipe.machines.*; import techreborn.blocks.cable.EnumCableType; import techreborn.client.gui.*; +import techreborn.client.gui.slot.GuiSlotConfiguration; import techreborn.compat.CompatManager; import techreborn.compat.jei.alloySmelter.AlloySmelterRecipeCategory; import techreborn.compat.jei.alloySmelter.AlloySmelterRecipeWrapper; @@ -102,6 +104,8 @@ import techreborn.init.ModItems; import techreborn.items.ItemParts; import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import java.awt.*; import java.util.ArrayList; import java.util.List; @@ -390,6 +394,8 @@ public class TechRebornJeiPlugin implements IModPlugin { registry.getJeiHelpers().getIngredientBlacklist().addIngredientToBlacklist(new ItemStack(ModBlocks.QUANTUM_TANK)); } + registry.addAdvancedGuiHandlers(new AdvancedGuiHandler()); + } @Override @@ -397,6 +403,26 @@ public class TechRebornJeiPlugin implements IModPlugin { recipesGui = jeiRuntime.getRecipesGui(); } + public static class AdvancedGuiHandler implements IAdvancedGuiHandler { + + @Override + public Class getGuiContainerClass() { + return GuiBase.class; + } + + @Nullable + @Override + public List getGuiExtraAreas(GuiBase guiContainer) { + return GuiSlotConfiguration.getExtraSpace(guiContainer); + } + + @Nullable + @Override + public Object getIngredientUnderMouse(GuiBase guiContainer, int mouseX, int mouseY) { + return null; + } + } + //Taken from JEI so we can have a custom impliemntation of it //This is done as I didnt see an easy way to disable the show recipes button when a certain condition is met