ActuallyAdditions/src/main/java/de/ellpeck/actuallyadditions/booklet/page/PageCrusherRecipe.java
Michael be421af8e2
Big Refactor of the package layout
Ignore this commit for diffs
2020-09-09 15:48:43 +01:00

72 lines
2.8 KiB
Java

package de.ellpeck.actuallyadditions.booklet.page;
import java.util.List;
import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe;
import de.ellpeck.actuallyadditions.common.ActuallyAdditions;
import de.ellpeck.actuallyadditions.booklet.gui.GuiBooklet;
import de.ellpeck.actuallyadditions.common.util.StackUtil;
import de.ellpeck.actuallyadditions.common.util.StringUtil;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.client.config.GuiUtils;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class PageCrusherRecipe extends BookletPage {
private final CrusherRecipe recipe;
private int counter = 0;
private int rotate = 0;
private final ItemStack[] stacks;
public PageCrusherRecipe(int localizationKey, CrusherRecipe recipe) {
super(localizationKey);
this.recipe = recipe;
this.stacks = recipe.getInput().getMatchingStacks();
}
@Override
@SideOnly(Side.CLIENT)
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 + 38, startY + 6, 136, 0, 52, 74, 0);
gui.renderScaledAsciiString("(" + StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".crusherRecipe") + ")", startX + 36, startY + 85, 0, false, gui.getMediumFontSize());
PageTextOnly.renderTextToPage(gui, this, startX + 6, startY + 100);
if (this.counter++ % 50 == 0) gui.addOrModifyItemRenderer(this.stacks[this.rotate++ % this.stacks.length], startX + 38 + 18, startY + 6 + 1, 1F, true);
}
@Override
@SideOnly(Side.CLIENT)
public void initGui(GuiBookletBase gui, int startX, int startY) {
super.initGui(gui, startX, startY);
if (this.recipe != null) {
gui.addOrModifyItemRenderer(this.stacks[this.rotate++ % this.stacks.length], startX + 38 + 18, startY + 6 + 1, 1F, true);
gui.addOrModifyItemRenderer(this.recipe.getOutputOne(), startX + 38 + 4, startY + 6 + 53, 1F, false);
if (StackUtil.isValid(this.recipe.getOutputTwo())) {
gui.addOrModifyItemRenderer(this.recipe.getOutputTwo(), startX + 38 + 30, startY + 6 + 53, 1F, false);
}
}
}
@Override
public void getItemStacksForPage(List<ItemStack> list) {
super.getItemStacksForPage(list);
if (this.recipe != null) {
list.add(this.recipe.getOutputOne());
if (StackUtil.isValid(this.recipe.getOutputTwo())) {
list.add(this.recipe.getOutputTwo());
}
}
}
}