ActuallyAdditions/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageEmpowerer.java

104 lines
4.1 KiB
Java
Raw Normal View History

2016-11-10 21:07:15 +01:00
/*
* This file ("PageEmpowerer.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
2017-01-01 16:23:26 +01:00
* © 2015-2017 Ellpeck
2016-11-10 21:07:15 +01:00
*/
package de.ellpeck.actuallyadditions.mod.booklet.page;
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;
2018-05-10 11:38:58 +02:00
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
2016-11-12 00:29:01 +01:00
import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
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
import java.util.List;
2016-11-10 21:07:15 +01:00
public class PageEmpowerer extends BookletPage{
2016-11-12 00:29:01 +01:00
private final EmpowererRecipe recipe;
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
2016-11-10 21:07:15 +01:00
public PageEmpowerer(int localizationKey, EmpowererRecipe recipe){
super(localizationKey);
2016-11-12 00:29:01 +01:00
this.recipe = recipe;
if(recipe != null) {
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)
2016-11-12 00:29:01 +01:00
public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks){
super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks);
gui.mc.getTextureManager().bindTexture(GuiBooklet.RES_LOC_GADGETS);
GuiUtils.drawTexturedModalRect(startX+5, startY+10, 117, 74, 116, 72, 0);
2018-05-10 11:38:58 +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
PageTextOnly.renderTextToPage(gui, this, startX+6, startY+100);
if(recipe != null) updateInputs(gui, startX, startY);
2016-11-12 00:29:01 +01:00
}
@Override
2017-02-18 00:54:58 +01:00
@SideOnly(Side.CLIENT)
2016-11-12 00:29:01 +01:00
public void initGui(GuiBookletBase gui, int startX, int startY){
super.initGui(gui, startX, startY);
if(this.recipe != null){
gui.addOrModifyItemRenderer(stand1[0], startX+5+26, startY+10+1, 1F, true);
gui.addOrModifyItemRenderer(stand2[0], startX+5+1, startY+10+26, 1F, true);
gui.addOrModifyItemRenderer(stand3[0], startX+5+51, startY+10+26, 1F, true);
gui.addOrModifyItemRenderer(stand4[0], startX+5+26, startY+10+51, 1F, true);
gui.addOrModifyItemRenderer(inputs[0], startX+5+26, startY+10+26, 1F, true);
gui.addOrModifyItemRenderer(this.recipe.getOutput(), startX+5+96, startY+10+26, 1F, false);
}
}
private void updateInputs(GuiBookletBase gui, int startX, int startY) {
if(counter++ % 50 == 0) {
rotate++;
gui.addOrModifyItemRenderer(stand1[rotate % stand1.length], startX+5+26, startY+10+1, 1F, true);
gui.addOrModifyItemRenderer(stand2[rotate % stand2.length], startX+5+1, startY+10+26, 1F, true);
gui.addOrModifyItemRenderer(stand3[rotate % stand3.length], startX+5+51, startY+10+26, 1F, true);
gui.addOrModifyItemRenderer(stand4[rotate % stand4.length], startX+5+26, startY+10+51, 1F, true);
gui.addOrModifyItemRenderer(inputs[rotate % inputs.length], startX+5+26, startY+10+26, 1F, true);
}
}
@Override
public void getItemStacksForPage(List<ItemStack> list){
super.getItemStacksForPage(list);
2016-11-12 00:29:01 +01:00
if(this.recipe != null){
list.add(this.recipe.getOutput());
}
2016-11-10 21:07:15 +01:00
}
2016-11-22 22:54:35 +01:00
@Override
public int getSortingPriority(){
return 20;
}
2016-11-10 21:07:15 +01:00
}