ActuallyAdditions/src/main/java/de/ellpeck/actuallyadditions/booklet/page/PageCrusherRecipe.java

71 lines
2.8 KiB
Java
Raw Normal View History

package de.ellpeck.actuallyadditions.booklet.page;
2016-11-10 21:07:15 +01:00
import java.util.List;
2016-11-12 00:29:01 +01:00
import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
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;
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 PageCrusherRecipe extends BookletPage {
2016-11-10 21:07:15 +01:00
2016-11-12 00:29:01 +01:00
private final CrusherRecipe recipe;
private int counter = 0;
private int rotate = 0;
private final ItemStack[] stacks;
2016-11-12 00:29:01 +01:00
2019-05-02 09:10:29 +02:00
public PageCrusherRecipe(int localizationKey, CrusherRecipe recipe) {
2016-11-10 21:07:15 +01:00
super(localizationKey);
2016-11-12 00:29:01 +01:00
this.recipe = recipe;
2019-02-27 19:53:05 +01:00
this.stacks = recipe.getInput().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 + 38, startY + 6, 136, 0, 52, 74, 0);
2016-11-12 00:29:01 +01:00
2019-05-02 09:10:29 +02:00
gui.renderScaledAsciiString("(" + StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".crusherRecipe") + ")", startX + 36, 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);
2019-02-27 19:53:05 +01:00
2019-05-02 09:10:29 +02:00
if (this.counter++ % 50 == 0) gui.addOrModifyItemRenderer(this.stacks[this.rotate++ % this.stacks.length], startX + 38 + 18, startY + 6 + 1, 1F, true);
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.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);
2019-05-02 09:10:29 +02:00
if (StackUtil.isValid(this.recipe.getOutputTwo())) {
gui.addOrModifyItemRenderer(this.recipe.getOutputTwo(), startX + 38 + 30, startY + 6 + 53, 1F, false);
}
}
}
@Override
2019-05-02 09:10:29 +02:00
public void getItemStacksForPage(List<ItemStack> list) {
super.getItemStacksForPage(list);
2019-05-02 09:10:29 +02:00
if (this.recipe != null) {
list.add(this.recipe.getOutputOne());
2016-11-12 00:29:01 +01:00
2019-05-02 09:10:29 +02:00
if (StackUtil.isValid(this.recipe.getOutputTwo())) {
list.add(this.recipe.getOutputTwo());
}
2016-11-12 00:29:01 +01:00
}
2016-11-10 21:07:15 +01:00
}
}