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

101 lines
3.8 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;
import codechicken.nei.LayoutManager;
2014-04-29 10:54:20 +10:00
import codechicken.nei.NEIClientConfig;
import codechicken.nei.NEIClientUtils;
import codechicken.nei.PositionedStack;
2014-04-29 10:54:20 +10:00
import codechicken.nei.guihook.GuiContainerManager;
import codechicken.nei.guihook.IContainerInputHandler;
import java.util.List;
2014-04-29 10:54:20 +10:00
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
public class RecipeItemInputHandler implements IContainerInputHandler {
2014-04-29 10:54:20 +10:00
@Override
public boolean lastKeyTyped(GuiContainer gui, char keyChar, int keyCode) {
2014-04-29 10:54:20 +10:00
ItemStack stackover = GuiContainerManager.getStackMouseOver(gui);
if (stackover == null) return false;
if (keyCode == NEIClientConfig.getKeyBinding("gui.recipe"))
2014-04-29 10:54:20 +10:00
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());
2022-01-02 23:30:54 +02:00
if (keyCode == NEIClientConfig.getKeyBinding("gui.bookmark")) {
2019-12-24 13:37:41 -08:00
NEIClientConfig.logger.debug("Adding or removing {} from bookmarks", stackover.getDisplayName());
2022-01-02 23:30:54 +02:00
List<PositionedStack> ingredients = null;
String handlerName = "";
2021-11-22 05:31:02 +02:00
2022-01-02 23:30:54 +02:00
if (gui instanceof GuiRecipe && NEIClientConfig.saveCurrentRecipeInBookmarksEnabled()) {
ingredients = ((GuiRecipe<?>) gui).getFocusedRecipeIngredients();
handlerName = ((GuiRecipe<?>) gui).getHandlerName();
2022-01-02 23:30:54 +02:00
}
2021-11-22 05:31:02 +02:00
2022-01-02 23:30:54 +02:00
ItemPanels.bookmarkPanel.addOrRemoveItem(stackover.copy(), handlerName, ingredients);
2019-12-24 13:37:41 -08:00
}
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());
}
2014-04-29 10:54:20 +10:00
return false;
}
@Override
public boolean mouseClicked(GuiContainer gui, int mousex, int mousey, int button) {
2014-04-29 10:54:20 +10:00
ItemStack stackover = GuiContainerManager.getStackMouseOver(gui);
if (stackover == null) return false;
if (!(gui instanceof GuiRecipe)) return false;
2020-02-02 10:44:48 -08:00
// disabled open recipe gui if hold shift (player have move recipe)
if (button == 0
&& ItemPanels.bookmarkPanel.getStackMouseOver(mousex, mousey) != null
&& NEIClientUtils.shiftKey()) {
2021-11-22 05:31:02 +02:00
return false;
}
if (button == 0) return GuiCraftingRecipe.openRecipeGui("item", stackover.copy());
2014-04-29 10:54:20 +10:00
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
public void onKeyTyped(GuiContainer gui, char keyChar, int keyID) {}
2014-04-29 10:54:20 +10:00
@Override
public void onMouseClicked(GuiContainer gui, int mousex, int mousey, int button) {}
2014-04-29 10:54:20 +10:00
@Override
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) {
2014-04-29 10:54:20 +10:00
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) {
2014-04-29 10:54:20 +10:00
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) {}
2014-04-29 10:54:20 +10:00
}