Files
NotEnoughItems/src/main/java/codechicken/nei/recipe/GuiRecipeButton.java
T
2026-10-25 02:49:38 +03:00

94 lines
2.7 KiB
Java

package codechicken.nei.recipe;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import net.minecraftforge.client.event.GuiScreenEvent;
import codechicken.lib.vec.Rectangle4i;
import codechicken.nei.GuiNEIButton;
import cpw.mods.fml.common.eventhandler.Cancelable;
public abstract class GuiRecipeButton extends GuiNEIButton {
public static class UpdateRecipeButtonsEvent extends GuiScreenEvent {
public List<GuiRecipeButton> buttonList;
public RecipeHandlerRef handlerRef;
public int width;
public int height;
public UpdateRecipeButtonsEvent(GuiRecipe<?> gui, RecipeHandlerRef handlerRef, int width, int height,
List<GuiRecipeButton> buttonList) {
super(gui);
this.handlerRef = handlerRef;
this.width = width;
this.height = height;
this.buttonList = new ArrayList<>(buttonList);
}
@Cancelable
public static class Pre extends UpdateRecipeButtonsEvent {
public HandlerInfo handlerInfo;
public Pre(GuiRecipe<?> gui, RecipeHandlerRef handlerRef, int width, int height, HandlerInfo handlerInfo) {
super(gui, handlerRef, width, height, new ArrayList<>());
this.handlerInfo = handlerInfo;
}
}
public static class Post extends UpdateRecipeButtonsEvent {
public Post(GuiRecipe<?> gui, RecipeHandlerRef handlerRef, int width, int height,
List<GuiRecipeButton> buttonList) {
super(gui, handlerRef, width, height, buttonList);
}
}
}
public static final int BUTTON_WIDTH = 12;
public static final int BUTTON_HEIGHT = 12;
public final RecipeHandlerRef handlerRef;
protected GuiRecipeButton(RecipeHandlerRef point, int x, int y, int buttonId, String label) {
super(buttonId, x, y, BUTTON_WIDTH, BUTTON_HEIGHT, label);
this.handlerRef = point;
}
public abstract List<String> handleTooltip(List<String> currenttip);
public abstract Map<String, String> handleHotkeys(int mousex, int mousey, Map<String, String> hotkeys);
public abstract void lastKeyTyped(char keyChar, int keyID);
public boolean onHotkeyPressed() {
return false;
}
public abstract void drawItemOverlay();
public void update() {
}
public void onPermutationsChanged() {
}
public boolean mouseScrolled(int scroll) {
return false;
}
public Rectangle4i bounds() {
return new Rectangle4i(this.xPosition, this.yPosition, this.width, this.height);
}
public boolean contains(int mx, int my) {
return bounds().contains(mx, my);
}
}