Files
NotEnoughItems/src/main/java/codechicken/nei/recipe/RecipeItemInputHandler.java
T

100 lines
3.0 KiB
Java
Raw Normal View History

2014-04-29 10:54:20 +10:00
package codechicken.nei.recipe;
2019-12-24 13:37:41 -08:00
import codechicken.nei.ItemPanels;
2014-04-29 10:54:20 +10:00
import codechicken.nei.NEIClientConfig;
import codechicken.nei.NEIClientUtils;
import codechicken.nei.guihook.GuiContainerManager;
import codechicken.nei.guihook.IContainerInputHandler;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
public class RecipeItemInputHandler implements IContainerInputHandler
{
@Override
public boolean lastKeyTyped(GuiContainer gui, char keyChar, int keyCode)
{
ItemStack stackover = GuiContainerManager.getStackMouseOver(gui);
if(stackover == null)
return false;
2014-04-29 10:54:20 +10:00
if(keyCode == NEIClientConfig.getKeyBinding("gui.recipe"))
return GuiCraftingRecipe.openRecipeGui("item", stackover.copy());
2019-12-24 13:37:41 -08:00
if(keyCode == NEIClientConfig.getKeyBinding("gui.usage"))
return GuiUsageRecipe.openRecipeGui("item", stackover.copy());
2019-12-24 13:37:41 -08:00
if(keyCode == NEIClientConfig.getKeyBinding("gui.bookmark")) {
NEIClientConfig.logger.debug("Adding or removing {} from bookmarks", stackover.getDisplayName());
2021-11-22 05:31:02 +02:00
BookmarkRecipeId recipeId = null;
if (gui instanceof GuiRecipe && NEIClientConfig.saveCurrentRecipeInBookmarksEnabled())
recipeId = ((GuiRecipe)gui).getFocusedRecipeId();
ItemPanels.bookmarkPanel.addOrRemoveItem(stackover.copy(), recipeId);
2019-12-24 13:37:41 -08:00
}
2014-04-29 10:54:20 +10:00
return false;
}
@Override
public boolean mouseClicked(GuiContainer gui, int mousex, int mousey, int button)
{
ItemStack stackover = GuiContainerManager.getStackMouseOver(gui);
2020-02-02 10:44:48 -08:00
if(stackover == null)
return false;
2020-02-02 10:44:48 -08:00
if (!(gui instanceof GuiRecipe))
2014-04-29 10:54:20 +10:00
return false;
2020-02-02 10:44:48 -08:00
2021-11-22 05:31:02 +02:00
//disabled open recipe gui if hold shift (player have move recipe)
if (button == 0 && ItemPanels.bookmarkPanel.getStackMouseOver(mousex, mousey) != null && NEIClientUtils.shiftKey()) {
return false;
}
2014-04-29 10:54:20 +10:00
if(button == 0)
return GuiCraftingRecipe.openRecipeGui("item", stackover.copy());
if(button == 1)
return GuiUsageRecipe.openRecipeGui("item", stackover.copy());
2021-11-22 05:31:02 +02:00
2014-04-29 10:54:20 +10:00
return false;
}
@Override
2021-11-22 05:31:02 +02:00
public void onKeyTyped(GuiContainer gui, char keyChar, int keyID)
2014-04-29 10:54:20 +10:00
{
}
@Override
2021-11-22 05:31:02 +02:00
public void onMouseClicked(GuiContainer gui, int mousex, int mousey, int button)
2014-04-29 10:54:20 +10:00
{
}
@Override
2021-11-22 05:31:02 +02:00
public void onMouseUp(GuiContainer gui, int mousex, int mousey, int button)
2014-04-29 10:54:20 +10:00
{
}
@Override
public boolean keyTyped(GuiContainer gui, char keyChar, int keyID)
{
return false;
}
2021-11-22 05:31:02 +02:00
2014-04-29 10:54:20 +10:00
@Override
public boolean mouseScrolled(GuiContainer gui, int mousex, int mousey, int scrolled)
{
return false;
}
2021-11-22 05:31:02 +02:00
2014-04-29 10:54:20 +10:00
@Override
public void onMouseScrolled(GuiContainer gui, int mousex, int mousey, int scrolled)
{
}
2021-11-22 05:31:02 +02:00
2014-04-29 10:54:20 +10:00
@Override
public void onMouseDragged(GuiContainer gui, int mousex, int mousey, int button, long heldTime)
{
}
}