2016-01-17 01:09:36 +01:00
|
|
|
/*
|
2016-05-16 22:52:27 +02:00
|
|
|
* This file ("RecipeWrapperWithButton.java") is part of the Actually Additions mod for Minecraft.
|
2016-01-17 01:09:36 +01: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
|
2016-01-17 01:09:36 +01:00
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
*
|
2016-05-16 22:54:42 +02:00
|
|
|
* © 2015-2016 Ellpeck
|
2016-01-17 01:09:36 +01:00
|
|
|
*/
|
|
|
|
|
2016-01-17 01:14:30 +01:00
|
|
|
package de.ellpeck.actuallyadditions.mod.jei;
|
2016-01-17 01:09:36 +01:00
|
|
|
|
|
|
|
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
|
|
|
import de.ellpeck.actuallyadditions.api.booklet.BookletPage;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.booklet.BookletUtils;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.booklet.GuiBooklet;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.booklet.button.TexturedButton;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
2016-10-31 20:19:55 +01:00
|
|
|
import mezz.jei.api.recipe.IRecipeWrapper;
|
2016-01-17 01:09:36 +01:00
|
|
|
import net.minecraft.client.Minecraft;
|
|
|
|
|
2016-10-31 20:19:55 +01:00
|
|
|
import javax.annotation.Nullable;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
public abstract class RecipeWrapperWithButton implements IRecipeWrapper{
|
2016-01-17 01:09:36 +01:00
|
|
|
|
2016-05-19 20:05:12 +02:00
|
|
|
protected final TexturedButton theButton;
|
2016-01-17 01:09:36 +01:00
|
|
|
|
|
|
|
public RecipeWrapperWithButton(){
|
2016-10-31 20:19:55 +01:00
|
|
|
this.theButton = new TexturedButton(23782, this.getButtonX(), this.getButtonY(), 146, 154, 20, 20);
|
2016-01-17 01:09:36 +01:00
|
|
|
}
|
|
|
|
|
2016-02-01 17:49:55 +01:00
|
|
|
public abstract int getButtonX();
|
|
|
|
|
|
|
|
public abstract int getButtonY();
|
|
|
|
|
2016-10-31 20:19:55 +01:00
|
|
|
@Override
|
|
|
|
public boolean handleClick(Minecraft minecraft, int mouseX, int mouseY, int mouseButton){
|
|
|
|
if(this.theButton.mousePressed(minecraft, mouseX, mouseY)){
|
|
|
|
this.theButton.playPressSound(minecraft.getSoundHandler());
|
2016-01-17 01:09:36 +01:00
|
|
|
|
|
|
|
BookletPage page = this.getPage();
|
|
|
|
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);
|
2016-01-17 01:09:36 +01:00
|
|
|
BookletUtils.openChapter(book, page.getChapter(), page);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-02-01 17:49:55 +01:00
|
|
|
public abstract BookletPage getPage();
|
|
|
|
|
2016-10-31 20:19:55 +01:00
|
|
|
@Override
|
|
|
|
public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY){
|
|
|
|
this.theButton.drawButton(minecraft, mouseX, mouseY);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
@Override
|
|
|
|
public List<String> getTooltipStrings(int mouseX, int mouseY){
|
|
|
|
if(this.theButton.isMouseOver()){
|
|
|
|
return Collections.singletonList(StringUtil.localize("booklet."+ModUtil.MOD_ID+".clickToSeeRecipe"));
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
return Collections.emptyList();
|
|
|
|
}
|
2016-01-17 01:09:36 +01:00
|
|
|
}
|
|
|
|
}
|