mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-17 11:05:07 +00:00
Use shortcut key to trigger overlay recipe (#248)
* Use shortcut key to trigger overlay recipe * Add a way to remove overlay renderer * Change of implementation * Fix crash
This commit is contained in:
1 parent
91e9b2a5ae
commit
d735cc2a38
6 files changed
+94
-63
No files matched your search
@@ -1,29 +1,29 @@
|
||||
package codechicken.nei.recipe;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.ItemPanels;
|
||||
import codechicken.nei.LayoutManager;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.NEIClientUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.guihook.IContainerInputHandler;
|
||||
import codechicken.nei.PositionedStack;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
|
||||
public class RecipeItemInputHandler implements IContainerInputHandler
|
||||
{
|
||||
public class RecipeItemInputHandler implements IContainerInputHandler {
|
||||
@Override
|
||||
public boolean lastKeyTyped(GuiContainer gui, char keyChar, int keyCode)
|
||||
{
|
||||
public boolean lastKeyTyped(GuiContainer gui, char keyChar, int keyCode) {
|
||||
ItemStack stackover = GuiContainerManager.getStackMouseOver(gui);
|
||||
if(stackover == null)
|
||||
return false;
|
||||
if (stackover == null) return false;
|
||||
|
||||
if(keyCode == NEIClientConfig.getKeyBinding("gui.recipe"))
|
||||
if (keyCode == NEIClientConfig.getKeyBinding("gui.recipe"))
|
||||
return GuiCraftingRecipe.openRecipeGui("item", stackover.copy());
|
||||
|
||||
if(keyCode == NEIClientConfig.getKeyBinding("gui.usage"))
|
||||
if (keyCode == NEIClientConfig.getKeyBinding("gui.usage"))
|
||||
return GuiUsageRecipe.openRecipeGui("item", stackover.copy());
|
||||
|
||||
if (keyCode == NEIClientConfig.getKeyBinding("gui.bookmark")) {
|
||||
@@ -39,68 +39,68 @@ public class RecipeItemInputHandler implements IContainerInputHandler
|
||||
ItemPanels.bookmarkPanel.addOrRemoveItem(stackover.copy(), handlerName, ingredients);
|
||||
}
|
||||
|
||||
if (keyCode == NEIClientConfig.getKeyBinding("gui.overlay")) {
|
||||
if (NEIClientUtils.controlKey()) {
|
||||
LayoutManager.overlayRenderer = null;
|
||||
return true;
|
||||
}
|
||||
if (!NEIClientConfig.saveCurrentRecipeInBookmarksEnabled()) return false;
|
||||
final BookmarkRecipeId mouseOverRecipeId = ItemPanels.bookmarkPanel.getBookmarkMouseOverRecipeId();
|
||||
if (mouseOverRecipeId == null || mouseOverRecipeId.ingredients == null || mouseOverRecipeId.ingredients.isEmpty())
|
||||
return false;
|
||||
return GuiCraftingRecipe.openRecipeGui("item", true, stackover.copy());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(GuiContainer gui, int mousex, int mousey, int button)
|
||||
{
|
||||
public boolean mouseClicked(GuiContainer gui, int mousex, int mousey, int button) {
|
||||
ItemStack stackover = GuiContainerManager.getStackMouseOver(gui);
|
||||
|
||||
if(stackover == null)
|
||||
return false;
|
||||
if (stackover == null) return false;
|
||||
|
||||
if (!(gui instanceof GuiRecipe))
|
||||
return false;
|
||||
if (!(gui instanceof GuiRecipe)) return false;
|
||||
|
||||
//disabled open recipe gui if hold shift (player have move recipe)
|
||||
if (button == 0 && ItemPanels.bookmarkPanel.getStackMouseOver(mousex, mousey) != null && NEIClientUtils.shiftKey()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(button == 0)
|
||||
return GuiCraftingRecipe.openRecipeGui("item", stackover.copy());
|
||||
if (button == 0) return GuiCraftingRecipe.openRecipeGui("item", stackover.copy());
|
||||
|
||||
if(button == 1)
|
||||
return GuiUsageRecipe.openRecipeGui("item", stackover.copy());
|
||||
if (button == 1) return GuiUsageRecipe.openRecipeGui("item", stackover.copy());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onKeyTyped(GuiContainer gui, char keyChar, int keyID)
|
||||
{
|
||||
public void onKeyTyped(GuiContainer gui, char keyChar, int keyID) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseClicked(GuiContainer gui, int mousex, int mousey, int button)
|
||||
{
|
||||
public void onMouseClicked(GuiContainer gui, int mousex, int mousey, int button) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseUp(GuiContainer gui, int mousex, int mousey, int button)
|
||||
{
|
||||
public void onMouseUp(GuiContainer gui, int mousex, int mousey, int button) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyTyped(GuiContainer gui, char keyChar, int keyID)
|
||||
{
|
||||
public boolean keyTyped(GuiContainer gui, char keyChar, int keyID) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseScrolled(GuiContainer gui, int mousex, int mousey, int scrolled)
|
||||
{
|
||||
public boolean mouseScrolled(GuiContainer gui, int mousex, int mousey, int scrolled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseScrolled(GuiContainer gui, int mousex, int mousey, int scrolled)
|
||||
{
|
||||
public void onMouseScrolled(GuiContainer gui, int mousex, int mousey, int scrolled) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseDragged(GuiContainer gui, int mousex, int mousey, int button, long heldTime)
|
||||
{
|
||||
public void onMouseDragged(GuiContainer gui, int mousex, int mousey, int button, long heldTime) {
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user