mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-27 23:46:05 +00:00
NEI item manager overlay integration (#38)
* New: NEI item manager overly integration * update buildscript * apply spotless * Making nei really optional * Fix wildcard * Stream chain simplify * Fix: NPE when events outside the Gui * Fix: drag and mouse event * Fix: call mouse event
This commit is contained in:
1 parent
6e6e806476
commit
c00e1b39da
15 files changed
+250
-34
No files matched your search
@@ -11,6 +11,7 @@ import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.JsonToNBT;
|
||||
import net.minecraft.nbt.NBTException;
|
||||
@@ -30,6 +31,8 @@ import binnie.core.craftgui.events.EventMouse;
|
||||
import binnie.core.craftgui.geometry.IArea;
|
||||
import binnie.core.craftgui.geometry.IBorder;
|
||||
import binnie.core.craftgui.geometry.IPoint;
|
||||
import binnie.core.craftgui.minecraft.control.ControlSlot;
|
||||
import binnie.core.nei.NEIHook;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -76,6 +79,8 @@ public class GuiCraftGUI extends GuiContainer {
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float par3) {
|
||||
NEIHook.preDraw();
|
||||
|
||||
window.setMousePosition(mouseX - (int) window.getPosition().x(), mouseY - (int) window.getPosition().y());
|
||||
drawDefaultBackground();
|
||||
|
||||
@@ -89,6 +94,9 @@ public class GuiCraftGUI extends GuiContainer {
|
||||
window.render();
|
||||
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
|
||||
NEIHook.renderObjects(window, mouseX, mouseY);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(32826); // GL_RESCALE_NORMAL_EXT
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0f, 240.0f);
|
||||
@@ -111,6 +119,8 @@ public class GuiCraftGUI extends GuiContainer {
|
||||
window.getTooltip(tooltip);
|
||||
}
|
||||
|
||||
NEIHook.renderToolTips(mouseX, mouseY);
|
||||
|
||||
if (tooltip.exists()) {
|
||||
renderTooltip(new IPoint(mouseX, mouseY), tooltip);
|
||||
}
|
||||
@@ -219,6 +229,8 @@ public class GuiCraftGUI extends GuiContainer {
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int x, int y, int button) {
|
||||
NEIHook.mouseClicked(x, y, button);
|
||||
|
||||
IWidget origin = window;
|
||||
if (window.getMousedOverWidget() != null) {
|
||||
origin = window.getMousedOverWidget();
|
||||
@@ -228,6 +240,8 @@ public class GuiCraftGUI extends GuiContainer {
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char c, int key) {
|
||||
NEIHook.lastKeyTyped(key, c);
|
||||
|
||||
if (key == 1 || (key == mc.gameSettings.keyBindInventory.getKeyCode() && window.getFocusedWidget() == null)) {
|
||||
mc.thePlayer.closeScreen();
|
||||
}
|
||||
@@ -241,6 +255,7 @@ public class GuiCraftGUI extends GuiContainer {
|
||||
if (button != -1) {
|
||||
window.callEvent(new EventMouse.Up(origin, x, y, button));
|
||||
}
|
||||
NEIHook.mouseUp(x, y, button);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -250,6 +265,8 @@ public class GuiCraftGUI extends GuiContainer {
|
||||
if (dWheel != 0) {
|
||||
window.callEvent(new EventMouse.Wheel(window, dWheel));
|
||||
}
|
||||
|
||||
NEIHook.handleMouseWheel();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -506,4 +523,9 @@ public class GuiCraftGUI extends GuiContainer {
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
public ItemStack getStackUnderMouse(int x, int y) {
|
||||
return window.calculateMousedOverWidgets().stream().filter(widget -> widget instanceof ControlSlot).findFirst()
|
||||
.map(w -> ((ControlSlot) w).slot).map(Slot::getStack).orElse(null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package binnie.core.nei;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import binnie.core.craftgui.minecraft.GuiCraftGUI;
|
||||
import codechicken.nei.guihook.IContainerObjectHandler;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
|
||||
@Optional.Interface(
|
||||
iface = "codechicken.nei.guihook.IContainerObjectHandler",
|
||||
modid = "NotEnoughItems",
|
||||
striprefs = true)
|
||||
public final class ContainerObjectHandler implements IContainerObjectHandler {
|
||||
|
||||
@Override
|
||||
public void guiTick(GuiContainer gui) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refresh(GuiContainer gui) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(GuiContainer gui) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackUnderMouse(GuiContainer gui, int mousex, int mousey) {
|
||||
if (gui instanceof GuiCraftGUI) {
|
||||
return ((GuiCraftGUI) gui).getStackUnderMouse(mousex, mousey);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean objectUnderMouse(GuiContainer gui, int mousex, int mousey) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldShowTooltip(GuiContainer gui) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package binnie.core.nei;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import binnie.core.craftgui.minecraft.Window;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public final class NEIHook {
|
||||
|
||||
public static boolean enabled = false;
|
||||
|
||||
static {
|
||||
if (Loader.isModLoaded("NotEnoughItems")) {
|
||||
enabled = true;
|
||||
addHandler();
|
||||
}
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "NotEnoughItems")
|
||||
private static void addHandler() {
|
||||
GuiContainerManager.addObjectHandler(new ContainerObjectHandler());
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "NotEnoughItems")
|
||||
private static GuiContainerManager getManager() {
|
||||
return GuiContainerManager.getManager();
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "NotEnoughItems")
|
||||
private static void preDrawImpl() {
|
||||
GuiContainerManager manager = getManager();
|
||||
if (manager != null) manager.preDraw();
|
||||
}
|
||||
|
||||
public static void preDraw() {
|
||||
if (enabled) preDrawImpl();
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "NotEnoughItems")
|
||||
private static void renderObjectsImpl(Window window, int mouseX, int mouseY) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(window.x(), window.y(), 0.0f);
|
||||
GuiContainerManager manager = getManager();
|
||||
if (manager != null) manager.renderObjects(mouseX, mouseY);
|
||||
GL11.glTranslatef(-window.x(), -window.y(), 0.0f);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public static void renderObjects(Window window, int mouseX, int mouseY) {
|
||||
if (enabled) renderObjectsImpl(window, mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "NotEnoughItems")
|
||||
private static void renderToolTipsImpl(int mouseX, int mouseY) {
|
||||
GuiContainerManager manager = getManager();
|
||||
if (manager != null) manager.renderToolTips(mouseX, mouseY);
|
||||
}
|
||||
|
||||
public static void renderToolTips(int mouseX, int mouseY) {
|
||||
if (enabled) renderToolTipsImpl(mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "NotEnoughItems")
|
||||
private static void mouseClickedImpl(int x, int y, int button) {
|
||||
GuiContainerManager manager = getManager();
|
||||
if (manager != null) manager.mouseClicked(x, y, button);
|
||||
}
|
||||
|
||||
public static void mouseClicked(int x, int y, int button) {
|
||||
if (enabled) mouseClickedImpl(x, y, button);
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "NotEnoughItems")
|
||||
private static void lastKeyTypedImpl(int k, char c) {
|
||||
GuiContainerManager manager = getManager();
|
||||
if (manager != null) manager.lastKeyTyped(k, c);
|
||||
}
|
||||
|
||||
public static void lastKeyTyped(int k, char c) {
|
||||
if (enabled) lastKeyTypedImpl(k, c);
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "NotEnoughItems")
|
||||
private static void handleMouseWheelImpl() {
|
||||
GuiContainerManager manager = getManager();
|
||||
if (manager != null) manager.handleMouseWheel();
|
||||
}
|
||||
|
||||
public static void handleMouseWheel() {
|
||||
if (enabled) handleMouseWheelImpl();
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "NotEnoughItems")
|
||||
private static void mouseUpImpl(int mouseX, int mouseY, int button) {
|
||||
GuiContainerManager manager = getManager();
|
||||
if (manager != null) manager.mouseUp(mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
public static void mouseUp(int mouseX, int mouseY, int button) {
|
||||
if (enabled) mouseUpImpl(mouseX, mouseY, button);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,11 @@ package binnie.core.nei;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.*;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidBlock;
|
||||
import net.minecraftforge.fluids.IFluidContainerItem;
|
||||
|
||||
public class NEIUtils {
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package binnie.core.nei;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package binnie.core.nei;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package binnie.core.nei;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -4,7 +4,9 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import binnie.extrabees.genetics.requirements.*;
|
||||
import binnie.extrabees.genetics.requirements.DummyMutationCondition;
|
||||
import binnie.extrabees.genetics.requirements.IMutationRequirement;
|
||||
import binnie.extrabees.genetics.requirements.RequirementPerson;
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.apiculture.IAlleleBeeSpecies;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package binnie.extratrees.nei;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package binnie.genetics.nei;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package binnie.genetics.nei;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package binnie.genetics.nei;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package binnie.genetics.nei;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package binnie.genetics.nei;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
Reference in new issue
Block a user