Move JEI item pane out of the way if the slot config goes of the side of the screen.

This commit is contained in:
modmuss50 2017-12-29 18:12:04 +00:00
parent ff2ed99d14
commit 1d6c6139ec
No known key found for this signature in database
GPG key ID: 773D17BE8BF49C82
4 changed files with 49 additions and 0 deletions

View file

@ -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<Rectangle> getExtraSpace(GuiBase guiBase){
if(!GuiBase.showSlotConfig || slectedSlot == -1){
return Collections.emptyList();
}
List<Rectangle> 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;
}
}

View file

@ -84,6 +84,8 @@ public class ConfigSlotElement extends ElementBase {
popupElement.filter = true;
}
}
setWidth(85);
setHeight(105 + (filter ? 15 : 0));
}
@Override

View file

@ -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;

View file

@ -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<GuiBase> {
@Override
public Class<GuiBase> getGuiContainerClass() {
return GuiBase.class;
}
@Nullable
@Override
public List<Rectangle> 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