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
|
|
|
|
*
|
2017-01-01 16:23:26 +01:00
|
|
|
* © 2015-2017 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
|
|
|
|
2016-11-10 19:50:01 +01:00
|
|
|
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
|
2018-05-10 11:38:58 +02:00
|
|
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
2016-11-10 19:50:01 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet;
|
2016-11-10 21:07:15 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils;
|
2016-11-10 19:50:01 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.inventory.gui.TexturedButton;
|
2016-01-17 01:09:36 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
|
|
|
import net.minecraft.client.Minecraft;
|
|
|
|
|
2021-02-26 22:15:48 +01:00
|
|
|
import javax.annotation.Nullable;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
|
|
|
|
2021-02-27 17:22:03 +01:00
|
|
|
public abstract class RecipeWrapperWithButton implements IRecipeWr {
|
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
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
public RecipeWrapperWithButton() {
|
2021-03-01 20:58:15 +01:00
|
|
|
this.theButton = new TexturedButton(GuiBooklet.RES_LOC_GADGETS, this.getButtonX(), this.getButtonY(), 0, 0, 20, 20, btn -> {
|
|
|
|
});
|
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
|
2019-05-02 09:10:29 +02:00
|
|
|
public boolean handleClick(Minecraft minecraft, int mouseX, int mouseY, int mouseButton) {
|
|
|
|
if (this.theButton.mousePressed(minecraft, mouseX, mouseY)) {
|
2016-10-31 20:19:55 +01:00
|
|
|
this.theButton.playPressSound(minecraft.getSoundHandler());
|
2016-01-17 01:09:36 +01:00
|
|
|
|
2016-11-10 19:50:01 +01:00
|
|
|
IBookletPage page = this.getPage();
|
2019-05-02 09:10:29 +02:00
|
|
|
if (page != null) {
|
2021-02-26 22:15:48 +01:00
|
|
|
Minecraft.getInstance().displayGuiScreen(BookletUtils.createBookletGuiFromPage(Minecraft.getInstance().currentScreen, page));
|
2016-01-17 01:09:36 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-11-10 19:50:01 +01:00
|
|
|
public abstract IBookletPage getPage();
|
2016-02-01 17:49:55 +01:00
|
|
|
|
2016-10-31 20:19:55 +01:00
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) {
|
2017-06-29 18:30:02 +02:00
|
|
|
this.theButton.drawButton(minecraft, mouseX, mouseY, 0F);
|
2016-10-31 20:19:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public List<String> getTooltipStrings(int mouseX, int mouseY) {
|
|
|
|
if (this.theButton.isMouseOver()) {
|
|
|
|
return Collections.singletonList(StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".clickToSeeRecipe"));
|
|
|
|
} else {
|
2016-10-31 20:19:55 +01:00
|
|
|
return Collections.emptyList();
|
|
|
|
}
|
2016-01-17 01:09:36 +01:00
|
|
|
}
|
|
|
|
}
|