2015-11-15 15:15:32 +01:00
|
|
|
/*
|
|
|
|
* This file ("PageReconstructor.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://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
|
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
*
|
|
|
|
* © 2015 Ellpeck
|
|
|
|
*/
|
|
|
|
|
|
|
|
package ellpeck.actuallyadditions.booklet.page;
|
|
|
|
|
2015-11-29 14:30:44 +01:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2015-11-15 15:15:32 +01:00
|
|
|
import ellpeck.actuallyadditions.blocks.InitBlocks;
|
|
|
|
import ellpeck.actuallyadditions.booklet.GuiBooklet;
|
2015-12-03 22:49:31 +01:00
|
|
|
import ellpeck.actuallyadditions.items.lens.LensNoneRecipeHandler;
|
2015-11-15 15:15:32 +01:00
|
|
|
import ellpeck.actuallyadditions.proxy.ClientProxy;
|
2015-12-22 14:55:10 +01:00
|
|
|
import ellpeck.actuallyadditions.util.AssetUtil;
|
2015-11-15 15:15:32 +01:00
|
|
|
import ellpeck.actuallyadditions.util.ModUtil;
|
|
|
|
import ellpeck.actuallyadditions.util.StringUtil;
|
|
|
|
import ellpeck.actuallyadditions.util.Util;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.util.EnumChatFormatting;
|
|
|
|
|
2015-11-25 22:13:51 +01:00
|
|
|
import java.util.ArrayList;
|
2015-11-15 18:14:39 +01:00
|
|
|
import java.util.List;
|
2015-11-15 15:15:32 +01:00
|
|
|
|
|
|
|
public class PageReconstructor extends BookletPage{
|
|
|
|
|
2015-12-03 22:49:31 +01:00
|
|
|
private LensNoneRecipeHandler.Recipe[] recipes;
|
2015-11-25 22:13:51 +01:00
|
|
|
private int recipePos;
|
2015-11-15 15:15:32 +01:00
|
|
|
|
2015-12-03 22:49:31 +01:00
|
|
|
public PageReconstructor(int id, ArrayList<LensNoneRecipeHandler.Recipe> recipes){
|
|
|
|
this(id, recipes.toArray(new LensNoneRecipeHandler.Recipe[recipes.size()]));
|
2015-12-01 19:48:09 +01:00
|
|
|
}
|
|
|
|
|
2015-12-03 22:49:31 +01:00
|
|
|
public PageReconstructor(int id, LensNoneRecipeHandler.Recipe... recipes){
|
2015-11-15 15:15:32 +01:00
|
|
|
super(id);
|
2015-11-25 22:13:51 +01:00
|
|
|
this.recipes = recipes;
|
2015-11-15 15:15:32 +01:00
|
|
|
this.addToPagesWithItemStackData();
|
|
|
|
}
|
|
|
|
|
2015-11-25 22:13:51 +01:00
|
|
|
@Override
|
2015-12-01 19:48:09 +01:00
|
|
|
public ItemStack[] getItemStacksForPage(){
|
|
|
|
if(this.recipes != null){
|
2015-12-01 23:23:55 +01:00
|
|
|
ArrayList<ItemStack> stacks = new ArrayList<ItemStack>();
|
2015-12-03 22:49:31 +01:00
|
|
|
for(LensNoneRecipeHandler.Recipe recipe : this.recipes){
|
2015-12-01 23:23:55 +01:00
|
|
|
if(recipe != null){
|
|
|
|
stacks.addAll(recipe.getOutputs());
|
2015-12-01 19:48:09 +01:00
|
|
|
}
|
2015-11-25 22:13:51 +01:00
|
|
|
}
|
2015-12-01 23:23:55 +01:00
|
|
|
return stacks.toArray(new ItemStack[stacks.size()]);
|
2015-11-25 22:13:51 +01:00
|
|
|
}
|
2015-12-01 19:48:09 +01:00
|
|
|
return null;
|
2015-11-25 22:13:51 +01:00
|
|
|
}
|
|
|
|
|
2015-11-15 15:15:32 +01:00
|
|
|
@Override
|
2015-11-29 14:30:44 +01:00
|
|
|
@SideOnly(Side.CLIENT)
|
2015-11-15 15:15:32 +01:00
|
|
|
public void renderPre(GuiBooklet gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){
|
2015-11-25 22:13:51 +01:00
|
|
|
if(this.recipes[this.recipePos] != null){
|
2015-11-15 15:15:32 +01:00
|
|
|
gui.mc.getTextureManager().bindTexture(ClientProxy.bulletForMyValentine ? GuiBooklet.resLocValentine : GuiBooklet.resLoc);
|
|
|
|
gui.drawTexturedModalRect(gui.guiLeft+37, gui.guiTop+20, 188, 154, 60, 60);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
@Override
|
2015-11-29 14:30:44 +01:00
|
|
|
@SideOnly(Side.CLIENT)
|
2015-11-15 15:15:32 +01:00
|
|
|
public void render(GuiBooklet gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){
|
2015-12-03 22:49:31 +01:00
|
|
|
LensNoneRecipeHandler.Recipe recipe = this.recipes[this.recipePos];
|
2015-11-25 22:13:51 +01:00
|
|
|
if(recipe == null){
|
2015-12-23 20:42:20 +01:00
|
|
|
StringUtil.drawSplitString(gui.mc.fontRenderer, EnumChatFormatting.DARK_RED+StringUtil.localize("booklet."+ModUtil.MOD_ID_LOWER+".recipeDisabled"), gui.guiLeft+14, gui.guiTop+15, 115, 0, false);
|
2015-11-15 15:15:32 +01:00
|
|
|
}
|
|
|
|
else{
|
|
|
|
String strg = "Atomic Reconstructor";
|
|
|
|
gui.mc.fontRenderer.drawString(strg, gui.guiLeft+gui.xSize/2-gui.mc.fontRenderer.getStringWidth(strg)/2, gui.guiTop+10, 0);
|
|
|
|
}
|
|
|
|
|
2015-12-04 18:55:50 +01:00
|
|
|
String text = gui.currentEntrySet.page.getText();
|
2015-11-15 15:15:32 +01:00
|
|
|
if(text != null && !text.isEmpty()){
|
2015-12-23 20:42:20 +01:00
|
|
|
StringUtil.drawSplitString(gui.mc.fontRenderer, text, gui.guiLeft+14, gui.guiTop+100, 115, 0, false);
|
2015-11-15 15:15:32 +01:00
|
|
|
}
|
|
|
|
|
2015-11-25 22:13:51 +01:00
|
|
|
if(recipe != null){
|
2015-12-22 14:55:10 +01:00
|
|
|
AssetUtil.renderStackToGui(new ItemStack(InitBlocks.blockAtomicReconstructor), gui.guiLeft+37+22, gui.guiTop+20+21, 1.0F);
|
2015-11-15 15:15:32 +01:00
|
|
|
for(int i = 0; i < 2; i++){
|
|
|
|
for(int x = 0; x < 2; x++){
|
2015-12-01 23:23:55 +01:00
|
|
|
List<ItemStack> stacks = x == 0 ? recipe.getInputs() : recipe.getOutputs();
|
|
|
|
if(stacks != null && !stacks.isEmpty()){
|
|
|
|
ItemStack stack = stacks.get(0);
|
2015-11-15 15:15:32 +01:00
|
|
|
|
2015-12-01 23:23:55 +01:00
|
|
|
if(stack.getItemDamage() == Util.WILDCARD){
|
|
|
|
stack.setItemDamage(0);
|
|
|
|
}
|
|
|
|
boolean tooltip = i == 1;
|
|
|
|
|
|
|
|
int xShow = gui.guiLeft+37+1+x*42;
|
|
|
|
int yShow = gui.guiTop+20+21;
|
|
|
|
if(!tooltip){
|
2015-12-22 14:55:10 +01:00
|
|
|
AssetUtil.renderStackToGui(stack, xShow, yShow, 1.0F);
|
2015-12-01 23:23:55 +01:00
|
|
|
}
|
|
|
|
else{
|
|
|
|
if(mouseX >= xShow && mouseX <= xShow+16 && mouseY >= yShow && mouseY <= yShow+16){
|
|
|
|
this.renderTooltipAndTransfer(gui, stack, mouseX, mouseY, x == 0, mousePressed);
|
|
|
|
}
|
2015-11-15 15:15:32 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-12-01 19:48:09 +01:00
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public void updateScreen(int ticksElapsed){
|
|
|
|
if(ticksElapsed%15 == 0){
|
|
|
|
if(this.recipePos+1 >= this.recipes.length){
|
|
|
|
this.recipePos = 0;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
this.recipePos++;
|
2015-11-15 15:15:32 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|