2015-10-02 19:58:03 +02:00
|
|
|
/*
|
2016-05-16 22:52:27 +02:00
|
|
|
* This file ("NEIScreenEvents.java") is part of the Actually Additions mod for Minecraft.
|
2015-10-02 19:58:03 +02:00
|
|
|
* It is created and owned by Ellpeck and distributed
|
|
|
|
* under the Actually Additions License to be found at
|
2016-05-16 22:52:27 +02:00
|
|
|
* http://ellpeck.de/actaddlicense
|
2015-10-02 19:58:03 +02:00
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
*
|
2016-05-16 22:54:42 +02:00
|
|
|
* © 2015-2016 Ellpeck
|
2015-10-02 19:58:03 +02:00
|
|
|
*/
|
|
|
|
|
2016-01-05 04:47:35 +01:00
|
|
|
package de.ellpeck.actuallyadditions.mod.nei;
|
2015-10-02 19:58:03 +02:00
|
|
|
|
2016-01-05 04:47:35 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.booklet.button.TexturedButton;
|
2015-10-02 19:58:03 +02:00
|
|
|
|
2015-11-27 15:22:44 +01:00
|
|
|
public class NEIScreenEvents{
|
2015-10-02 19:58:03 +02:00
|
|
|
|
|
|
|
private static final int NEI_BUTTON_ID = 123782;
|
2015-12-04 18:14:03 +01:00
|
|
|
private TexturedButton neiButton;
|
2015-10-02 19:58:03 +02:00
|
|
|
|
2016-01-23 12:09:29 +01:00
|
|
|
/*@SuppressWarnings("unchecked")
|
2015-10-02 19:58:03 +02:00
|
|
|
@SubscribeEvent
|
|
|
|
public void onInitGuiForNEI(GuiScreenEvent.InitGuiEvent event){
|
|
|
|
if(event.gui instanceof GuiRecipe){
|
|
|
|
int xSize = 176;
|
|
|
|
int ySize = 166;
|
|
|
|
int guiLeft = (event.gui.width-xSize)/2;
|
|
|
|
int guiTop = (event.gui.height-ySize)/2;
|
|
|
|
|
2015-12-04 18:14:03 +01:00
|
|
|
this.neiButton = new TexturedButton(NEI_BUTTON_ID, guiLeft+xSize-24, guiTop+127, 146, 154, 20, 20){
|
2015-10-02 19:58:03 +02:00
|
|
|
@Override
|
|
|
|
public void drawButton(Minecraft minecraft, int x, int y){
|
|
|
|
super.drawButton(minecraft, x, y);
|
2016-01-08 08:10:55 +01:00
|
|
|
if(this.visible && this.hovered){
|
2016-04-20 21:39:03 +02:00
|
|
|
String text = StringUtil.localize("booklet."+ModUtil.MOD_ID+".clickToSeeRecipe");
|
2016-01-08 08:10:55 +01:00
|
|
|
Minecraft.getMinecraft().fontRendererObj.drawString(text, this.xPosition-Minecraft.getMinecraft().fontRendererObj.getStringWidth(text)-1, this.yPosition+this.height/2-Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT/2, StringUtil.DECIMAL_COLOR_WHITE, true);
|
2015-10-02 19:58:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
event.buttonList.add(this.neiButton);
|
2016-01-16 20:06:25 +01:00
|
|
|
|
|
|
|
GuiRecipe theGui = (GuiRecipe)event.gui;
|
|
|
|
|
2015-10-02 20:06:03 +02:00
|
|
|
IRecipeHandler handler = theGui.getCurrentRecipeHandlers().get(theGui.recipetype);
|
2015-11-27 16:48:01 +01:00
|
|
|
this.neiButton.visible = handler instanceof INEIRecipeHandler && ((INEIRecipeHandler)handler).getPageForInfo(theGui.page) != null;
|
2015-10-02 19:58:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@SubscribeEvent
|
|
|
|
public void guiPostAction(GuiScreenEvent.ActionPerformedEvent.Post event){
|
|
|
|
if(this.neiButton != null && event.gui instanceof GuiRecipe){
|
|
|
|
GuiRecipe theGui = (GuiRecipe)event.gui;
|
|
|
|
|
|
|
|
IRecipeHandler handler = theGui.getCurrentRecipeHandlers().get(theGui.recipetype);
|
2015-11-27 16:48:01 +01:00
|
|
|
boolean isPage = handler instanceof INEIRecipeHandler && ((INEIRecipeHandler)handler).getPageForInfo(theGui.page) != null;
|
2015-10-02 19:58:03 +02:00
|
|
|
this.neiButton.visible = isPage;
|
|
|
|
|
|
|
|
if(isPage && event.button.id == NEI_BUTTON_ID){
|
2015-11-27 16:48:01 +01:00
|
|
|
BookletPage page = ((INEIRecipeHandler)handler).getPageForInfo(theGui.page);
|
|
|
|
if(page != null){
|
|
|
|
GuiBooklet book = new GuiBooklet(Minecraft.getMinecraft().currentScreen, false, true);
|
|
|
|
Minecraft.getMinecraft().displayGuiScreen(book);
|
2016-05-19 20:05:12 +02:00
|
|
|
BookletUtils.openIndexEntry(book, page.getChapter().getEntry(), ActuallyAdditionsAPI.BOOKLET_ENTRIES.indexOf(page.getChapter().getEntry())/GuiBooklet.CHAPTER_BUTTONS_AMOUNT+1, true);
|
2015-11-27 16:48:01 +01:00
|
|
|
BookletUtils.openChapter(book, page.getChapter(), page);
|
2015-10-02 19:58:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-01-23 12:09:29 +01:00
|
|
|
}*/
|
2015-10-02 19:58:03 +02:00
|
|
|
}
|