2016-11-10 21:07:15 +01:00
|
|
|
package de.ellpeck.actuallyadditions.mod.booklet.page;
|
|
|
|
|
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.LensConversionRecipe;
|
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;
|
2017-02-14 21:50:03 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
2016-12-18 12:08:32 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.util.Util;
|
2016-11-12 00:29:01 +01:00
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
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 PageReconstructor extends BookletPage {
|
2016-11-10 21:07:15 +01:00
|
|
|
|
2016-11-12 00:29:01 +01:00
|
|
|
private final LensConversionRecipe recipe;
|
2016-12-18 12:08:32 +01:00
|
|
|
private boolean isWildcard;
|
2018-06-24 02:44:47 +02:00
|
|
|
private int counter = 0;
|
|
|
|
private int rotate = 0;
|
|
|
|
private ItemStack[] stacks;
|
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
public PageReconstructor(int localizationKey, LensConversionRecipe 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) 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 + 30, startY + 10, 80, 146, 68, 48, 0);
|
2016-11-12 00:29:01 +01:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
gui.renderScaledAsciiString("(" + StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".reconstructorRecipe") + ")", startX + 6, startY + 63, 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 + 88);
|
|
|
|
if (this.recipe != null) {
|
|
|
|
if (this.counter++ % 50 == 0) gui.addOrModifyItemRenderer(this.stacks[this.rotate++ % this.stacks.length], startX + 30 + 1, startY + 10 + 13, 1F, true);
|
2018-06-24 02:44:47 +02:00
|
|
|
}
|
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[0], startX + 30 + 1, startY + 10 + 13, 1F, true);
|
|
|
|
gui.addOrModifyItemRenderer(this.recipe.getOutput(), startX + 30 + 47, startY + 10 + 13, 1F, false);
|
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);
|
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
if (this.recipe != null) {
|
2018-06-24 02:44:47 +02:00
|
|
|
ItemStack copy = this.recipe.getOutput().copy();
|
2019-05-02 09:10:29 +02:00
|
|
|
if (this.isWildcard) {
|
2016-12-18 12:08:32 +01:00
|
|
|
copy.setItemDamage(Util.WILDCARD);
|
|
|
|
}
|
|
|
|
list.add(copy);
|
2016-11-16 19:08:56 +01:00
|
|
|
}
|
2016-11-10 21:07:15 +01:00
|
|
|
}
|
2016-11-22 22:54:35 +01:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
public BookletPage setWildcard() {
|
2016-12-18 12:08:32 +01:00
|
|
|
this.isWildcard = true;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|