mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-22 21:09:51 +00:00
Move JEI items out of the way of ledgers
This commit is contained in:
1 parent
ab0d1cf7fc
commit
f85b534389
4 files changed
+63
-38
No files matched your search
@@ -10,6 +10,8 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.gui;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.awt.Rectangle;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@@ -269,38 +271,8 @@ public abstract class GuiForestry<C extends Container, I extends IInventory> ext
|
||||
super.drawGradientRect(par1, par2, par3, par4, par5, par6);
|
||||
}
|
||||
|
||||
/* NEI */
|
||||
/*@Override
|
||||
@Optional.Method(modid = "NotEnoughItems")
|
||||
public VisiblityData modifyVisiblity(GuiContainer gui, VisiblityData currentVisibility) {
|
||||
return null;
|
||||
@Nonnull
|
||||
public List<Rectangle> getExtraGuiAreas() {
|
||||
return ledgerManager.getLedgerAreas();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "NotEnoughItems")
|
||||
public Iterable<Integer> getItemSpawnSlots(GuiContainer gui, ItemStack item) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "NotEnoughItems")
|
||||
public List<TaggedInventoryArea> getInventoryAreas(GuiContainer gui) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "NotEnoughItems")
|
||||
public boolean handleDragNDrop(GuiContainer gui, int mousex, int mousey, ItemStack draggedStack, int button) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "NotEnoughItems")
|
||||
public boolean hideItemPanelSlot(GuiContainer gui, int x, int y, int w, int h) {
|
||||
if (gui instanceof GuiForestry) {
|
||||
return ((GuiForestry) gui).ledgerManager.ledgerOverlaps(x, y, w, h);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
@@ -23,6 +23,7 @@ import org.lwjgl.opengl.GL11;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.config.SessionVars;
|
||||
import forestry.core.gui.GuiForestry;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.render.ForestryResource;
|
||||
|
||||
@@ -54,6 +55,8 @@ public abstract class Ledger {
|
||||
|
||||
protected float currentWidth = minWidth;
|
||||
protected float currentHeight = minHeight;
|
||||
private int x;
|
||||
private int y;
|
||||
|
||||
private final ResourceLocation texture;
|
||||
|
||||
@@ -78,6 +81,11 @@ public abstract class Ledger {
|
||||
maxTextWidth = maxWidth - 18;
|
||||
}
|
||||
|
||||
public Rectangle getArea() {
|
||||
GuiForestry gui = manager.gui;
|
||||
return new Rectangle(gui.getGuiLeft() + x, gui.getGuiTop() + y, (int) currentWidth, (int) currentHeight);
|
||||
}
|
||||
|
||||
// adjust the update's move amount to match the look of 60 fps (16.67 ms per update)
|
||||
private static final float msPerUpdate = 16.667f;
|
||||
private long lastUpdateTime = 0;
|
||||
@@ -131,6 +139,15 @@ public abstract class Ledger {
|
||||
return Math.round(currentWidth);
|
||||
}
|
||||
|
||||
public void setPosition(int x, int y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public final void draw() {
|
||||
draw(x, y);
|
||||
}
|
||||
|
||||
public abstract void draw(int x, int y);
|
||||
|
||||
public abstract String getTooltip();
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.gui.ledgers;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -110,6 +112,18 @@ public class LedgerManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public List<Rectangle> getLedgerAreas() {
|
||||
List<Rectangle> areas = new ArrayList<>();
|
||||
for (Ledger ledger : ledgers) {
|
||||
if (ledger.isVisible()) {
|
||||
Rectangle area = ledger.getArea();
|
||||
areas.add(area);
|
||||
}
|
||||
}
|
||||
return areas;
|
||||
}
|
||||
|
||||
public void drawLedgers() {
|
||||
int yPos = 8;
|
||||
for (Ledger ledger : ledgers) {
|
||||
@@ -120,7 +134,8 @@ public class LedgerManager {
|
||||
}
|
||||
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
ledger.draw(gui.getSizeX(), yPos);
|
||||
ledger.setPosition(gui.getSizeX(), yPos);
|
||||
ledger.draw();
|
||||
yPos += ledger.getHeight();
|
||||
}
|
||||
|
||||
@@ -184,10 +199,6 @@ public class LedgerManager {
|
||||
|
||||
}
|
||||
|
||||
public boolean ledgerOverlaps(int x, int y, int width, int height) {
|
||||
return getAtPosition(x + width, y + height) != null || getAtPosition(x + width, y) != null || getAtPosition(x, y + height) != null || getAtPosition(x, y) != null;
|
||||
}
|
||||
|
||||
public int getMaxWidth() {
|
||||
return maxWidth;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
package forestry.factory.recipes.jei;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
|
||||
import forestry.core.gui.GuiForestry;
|
||||
import forestry.core.recipes.jei.ForestryRecipeCategoryUid;
|
||||
import forestry.factory.gui.ContainerWorktable;
|
||||
import forestry.factory.recipes.jei.bottler.BottlerRecipeCategory;
|
||||
@@ -36,6 +43,7 @@ import mezz.jei.api.IGuiHelper;
|
||||
import mezz.jei.api.IJeiHelpers;
|
||||
import mezz.jei.api.IModRegistry;
|
||||
import mezz.jei.api.JEIPlugin;
|
||||
import mezz.jei.api.gui.IAdvancedGuiHandler;
|
||||
import mezz.jei.api.recipe.VanillaRecipeCategoryUid;
|
||||
import mezz.jei.api.recipe.transfer.IRecipeTransferRegistry;
|
||||
|
||||
@@ -77,5 +85,22 @@ public class FactoryJeiPlugin extends BlankModPlugin {
|
||||
|
||||
IRecipeTransferRegistry transferRegistry = registry.getRecipeTransferRegistry();
|
||||
transferRegistry.addRecipeTransferHandler(ContainerWorktable.class, VanillaRecipeCategoryUid.CRAFTING, 19, 9, 1, 36);
|
||||
|
||||
registry.addAdvancedGuiHandlers(new ForestryAdvancedGuiHandler());
|
||||
}
|
||||
|
||||
private static class ForestryAdvancedGuiHandler implements IAdvancedGuiHandler<GuiForestry> {
|
||||
@Nonnull
|
||||
@Override
|
||||
public Class<GuiForestry> getGuiContainerClass() {
|
||||
return GuiForestry.class;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public List<Rectangle> getGuiExtraAreas(GuiForestry guiContainer) {
|
||||
GuiForestry<?,?> guiForestry = (GuiForestry<?,?>) guiContainer;
|
||||
return guiForestry.getExtraGuiAreas();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user