2020-09-09 16:48:43 +02:00
|
|
|
package de.ellpeck.actuallyadditions.booklet.page;
|
2016-11-10 21:07:15 +01:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
import java.util.List;
|
|
|
|
|
2016-11-12 00:29:01 +01:00
|
|
|
import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
|
2016-11-10 21:07:15 +01:00
|
|
|
import de.ellpeck.actuallyadditions.api.recipe.EmpowererRecipe;
|
2020-09-09 16:48:43 +02:00
|
|
|
import de.ellpeck.actuallyadditions.common.ActuallyAdditions;
|
|
|
|
import de.ellpeck.actuallyadditions.booklet.gui.GuiBooklet;
|
|
|
|
import de.ellpeck.actuallyadditions.common.util.StringUtil;
|
2016-11-16 19:08:56 +01:00
|
|
|
import net.minecraft.item.ItemStack;
|
2016-11-12 00:29:01 +01:00
|
|
|
import net.minecraftforge.fml.client.config.GuiUtils;
|
2017-02-18 00:54:58 +01:00
|
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
2016-11-10 21:07:15 +01:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
public class PageEmpowerer extends BookletPage {
|
2016-11-10 21:07:15 +01:00
|
|
|
|
2016-11-12 00:29:01 +01:00
|
|
|
private final EmpowererRecipe recipe;
|
2018-06-24 02:44:47 +02:00
|
|
|
private int counter = 0;
|
|
|
|
private int rotate = 0;
|
|
|
|
ItemStack[] inputs;
|
|
|
|
ItemStack[] stand1;
|
|
|
|
ItemStack[] stand2;
|
|
|
|
ItemStack[] stand3;
|
|
|
|
ItemStack[] stand4;
|
2016-11-12 00:29:01 +01:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
public PageEmpowerer(int localizationKey, EmpowererRecipe recipe) {
|
2016-11-10 21:07:15 +01:00
|
|
|
super(localizationKey);
|
2016-11-12 00:29:01 +01:00
|
|
|
this.recipe = recipe;
|
2019-05-02 09:10:29 +02:00
|
|
|
if (recipe != null) {
|
2018-06-24 02:44:47 +02:00
|
|
|
this.inputs = recipe.getInput().getMatchingStacks();
|
|
|
|
this.stand1 = recipe.getStandOne().getMatchingStacks();
|
|
|
|
this.stand2 = recipe.getStandTwo().getMatchingStacks();
|
|
|
|
this.stand3 = recipe.getStandThree().getMatchingStacks();
|
|
|
|
this.stand4 = recipe.getStandFour().getMatchingStacks();
|
|
|
|
}
|
2016-11-12 00:29:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-02-18 00:54:58 +01:00
|
|
|
@SideOnly(Side.CLIENT)
|
2019-05-02 09:10:29 +02:00
|
|
|
public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) {
|
2016-11-12 00:29:01 +01:00
|
|
|
super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks);
|
|
|
|
|
|
|
|
gui.mc.getTextureManager().bindTexture(GuiBooklet.RES_LOC_GADGETS);
|
2019-05-02 09:10:29 +02:00
|
|
|
GuiUtils.drawTexturedModalRect(startX + 5, startY + 10, 117, 74, 116, 72, 0);
|
2016-11-12 00:29:01 +01:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
gui.renderScaledAsciiString("(" + StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".empowererRecipe") + ")", startX + 6, startY + 85, 0, false, gui.getMediumFontSize());
|
2016-11-12 00:29:01 +01:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
PageTextOnly.renderTextToPage(gui, this, startX + 6, startY + 100);
|
|
|
|
if (this.recipe != null) this.updateInputs(gui, startX, startY);
|
2016-11-12 00:29:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-02-18 00:54:58 +01:00
|
|
|
@SideOnly(Side.CLIENT)
|
2019-05-02 09:10:29 +02:00
|
|
|
public void initGui(GuiBookletBase gui, int startX, int startY) {
|
2016-11-12 00:29:01 +01:00
|
|
|
super.initGui(gui, startX, startY);
|
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
if (this.recipe != null) {
|
|
|
|
gui.addOrModifyItemRenderer(this.stand1[0], startX + 5 + 26, startY + 10 + 1, 1F, true);
|
|
|
|
gui.addOrModifyItemRenderer(this.stand2[0], startX + 5 + 1, startY + 10 + 26, 1F, true);
|
|
|
|
gui.addOrModifyItemRenderer(this.stand3[0], startX + 5 + 51, startY + 10 + 26, 1F, true);
|
|
|
|
gui.addOrModifyItemRenderer(this.stand4[0], startX + 5 + 26, startY + 10 + 51, 1F, true);
|
2016-11-16 19:08:56 +01:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
gui.addOrModifyItemRenderer(this.inputs[0], startX + 5 + 26, startY + 10 + 26, 1F, true);
|
|
|
|
gui.addOrModifyItemRenderer(this.recipe.getOutput(), startX + 5 + 96, startY + 10 + 26, 1F, false);
|
2018-06-24 02:44:47 +02:00
|
|
|
}
|
|
|
|
}
|
2019-02-27 19:53:05 +01:00
|
|
|
|
2018-06-24 02:44:47 +02:00
|
|
|
private void updateInputs(GuiBookletBase gui, int startX, int startY) {
|
2019-05-02 09:10:29 +02:00
|
|
|
if (this.counter++ % 50 == 0) {
|
2019-02-27 19:53:05 +01:00
|
|
|
this.rotate++;
|
2019-05-02 09:10:29 +02:00
|
|
|
gui.addOrModifyItemRenderer(this.stand1[this.rotate % this.stand1.length], startX + 5 + 26, startY + 10 + 1, 1F, true);
|
|
|
|
gui.addOrModifyItemRenderer(this.stand2[this.rotate % this.stand2.length], startX + 5 + 1, startY + 10 + 26, 1F, true);
|
|
|
|
gui.addOrModifyItemRenderer(this.stand3[this.rotate % this.stand3.length], startX + 5 + 51, startY + 10 + 26, 1F, true);
|
|
|
|
gui.addOrModifyItemRenderer(this.stand4[this.rotate % this.stand4.length], startX + 5 + 26, startY + 10 + 51, 1F, true);
|
2019-02-27 19:53:05 +01:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
gui.addOrModifyItemRenderer(this.inputs[this.rotate % this.inputs.length], startX + 5 + 26, startY + 10 + 26, 1F, true);
|
2016-11-16 19:08:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public void getItemStacksForPage(List<ItemStack> list) {
|
2016-11-16 19:08:56 +01:00
|
|
|
super.getItemStacksForPage(list);
|
2016-11-12 00:29:01 +01:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
if (this.recipe != null) {
|
2018-06-24 02:44:47 +02:00
|
|
|
list.add(this.recipe.getOutput());
|
2016-11-16 19:08:56 +01:00
|
|
|
}
|
2016-11-10 21:07:15 +01:00
|
|
|
}
|
2016-11-22 22:54:35 +01:00
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public int getSortingPriority() {
|
2016-11-22 22:54:35 +01:00
|
|
|
return 20;
|
|
|
|
}
|
2016-11-10 21:07:15 +01:00
|
|
|
}
|