2016-11-10 21:07:15 +01:00
|
|
|
/*
|
|
|
|
* This file ("PageCrusherRecipe.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;
|
|
|
|
|
2018-06-23 01:39:30 +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.CrusherRecipe;
|
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;
|
2016-11-16 19:08:56 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
2017-02-14 21:50:03 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.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
|
|
|
|
|
|
|
public class PageCrusherRecipe extends BookletPage{
|
|
|
|
|
2016-11-12 00:29:01 +01:00
|
|
|
private final CrusherRecipe recipe;
|
2018-06-23 01:39:30 +02:00
|
|
|
private int counter = 0;
|
|
|
|
private int rotate = 0;
|
|
|
|
private final ItemStack[] stacks;
|
2016-11-12 00:29:01 +01:00
|
|
|
|
2016-11-10 21:07:15 +01:00
|
|
|
public PageCrusherRecipe(int localizationKey, CrusherRecipe recipe){
|
|
|
|
super(localizationKey);
|
2016-11-12 00:29:01 +01:00
|
|
|
this.recipe = recipe;
|
2018-06-23 01:39:30 +02:00
|
|
|
stacks = recipe.getInput().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+38, startY+6, 136, 0, 52, 74, 0);
|
|
|
|
|
2018-05-10 11:38:58 +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
|
|
|
|
|
|
|
PageTextOnly.renderTextToPage(gui, this, startX+6, startY+100);
|
2018-06-23 01:39:30 +02:00
|
|
|
|
2018-06-24 02:44:47 +02:00
|
|
|
if(counter++ % 50 == 0) gui.addOrModifyItemRenderer(stacks[rotate++ % 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)
|
2016-11-12 00:29:01 +01:00
|
|
|
public void initGui(GuiBookletBase gui, int startX, int startY){
|
|
|
|
super.initGui(gui, startX, startY);
|
|
|
|
|
2016-11-16 19:08:56 +01:00
|
|
|
if(this.recipe != null){
|
2018-06-23 01:39:30 +02:00
|
|
|
gui.addOrModifyItemRenderer(stacks[rotate++ % stacks.length], startX+38+18, startY+6+1, 1F, true);
|
|
|
|
gui.addOrModifyItemRenderer(this.recipe.getOutputOne(), startX+38+4, startY+6+53, 1F, false);
|
2016-11-16 19:08:56 +01:00
|
|
|
|
2018-06-23 01:39:30 +02:00
|
|
|
if(StackUtil.isValid(this.recipe.getOutputTwo())){
|
|
|
|
gui.addOrModifyItemRenderer(this.recipe.getOutputTwo(), startX+38+30, startY+6+53, 1F, false);
|
2016-11-16 19:08:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void getItemStacksForPage(List<ItemStack> list){
|
|
|
|
super.getItemStacksForPage(list);
|
|
|
|
|
|
|
|
if(this.recipe != null){
|
2018-06-23 01:39:30 +02:00
|
|
|
list.add(this.recipe.getOutputOne());
|
2016-11-12 00:29:01 +01:00
|
|
|
|
2018-06-23 01:39:30 +02:00
|
|
|
if(StackUtil.isValid(this.recipe.getOutputTwo())){
|
|
|
|
list.add(this.recipe.getOutputTwo());
|
2016-11-16 19:08:56 +01:00
|
|
|
}
|
2016-11-12 00:29:01 +01:00
|
|
|
}
|
2016-11-10 21:07:15 +01:00
|
|
|
}
|
|
|
|
}
|