2015-11-15 15:15:32 +01:00
|
|
|
/*
|
2016-05-16 22:52:27 +02:00
|
|
|
* This file ("PageReconstructor.java") is part of the Actually Additions mod for Minecraft.
|
2015-11-15 15:15:32 +01:00
|
|
|
* It is created and owned by Ellpeck and distributed
|
|
|
|
* under the Actually Additions License to be found at
|
2016-05-16 22:52:27 +02:00
|
|
|
* http://ellpeck.de/actaddlicense
|
2015-11-15 15:15:32 +01:00
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
*
|
2016-05-16 22:54:42 +02:00
|
|
|
* © 2015-2016 Ellpeck
|
2015-11-15 15:15:32 +01:00
|
|
|
*/
|
|
|
|
|
2016-01-05 04:47:35 +01:00
|
|
|
package de.ellpeck.actuallyadditions.mod.booklet.page;
|
2015-11-15 15:15:32 +01:00
|
|
|
|
2016-01-05 14:57:50 +01:00
|
|
|
import de.ellpeck.actuallyadditions.api.internal.IBookletGui;
|
2016-05-14 13:51:18 +02:00
|
|
|
import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe;
|
2016-01-05 04:47:35 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.booklet.GuiBooklet;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.proxy.ClientProxy;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.util.Util;
|
2016-01-05 14:57:50 +01:00
|
|
|
import net.minecraft.client.Minecraft;
|
2015-11-15 15:15:32 +01:00
|
|
|
import net.minecraft.item.ItemStack;
|
2016-03-18 23:47:22 +01:00
|
|
|
import net.minecraft.util.text.TextFormatting;
|
2016-01-07 18:20:59 +01:00
|
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
2015-11-15 15:15:32 +01:00
|
|
|
|
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
|
|
|
|
2016-01-05 14:57:50 +01:00
|
|
|
public class PageReconstructor extends BookletPageAA{
|
2015-11-15 15:15:32 +01:00
|
|
|
|
2016-05-19 20:05:12 +02:00
|
|
|
private final LensConversionRecipe[] recipes;
|
2015-11-25 22:13:51 +01:00
|
|
|
private int recipePos;
|
2015-11-15 15:15:32 +01:00
|
|
|
|
2016-05-14 13:51:18 +02:00
|
|
|
public PageReconstructor(int id, ArrayList<LensConversionRecipe> recipes){
|
|
|
|
this(id, recipes.toArray(new LensConversionRecipe[recipes.size()]));
|
2015-12-01 19:48:09 +01:00
|
|
|
}
|
|
|
|
|
2016-05-14 13:51:18 +02:00
|
|
|
public PageReconstructor(int id, LensConversionRecipe... 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();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-11-29 14:30:44 +01:00
|
|
|
@SideOnly(Side.CLIENT)
|
2016-01-05 14:57:50 +01:00
|
|
|
public void renderPre(IBookletGui gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){
|
2015-11-25 22:13:51 +01:00
|
|
|
if(this.recipes[this.recipePos] != null){
|
2016-01-05 14:57:50 +01:00
|
|
|
Minecraft.getMinecraft().getTextureManager().bindTexture(ClientProxy.bulletForMyValentine ? GuiBooklet.resLocValentine : GuiBooklet.resLoc);
|
2016-01-06 05:17:54 +01:00
|
|
|
gui.drawRect(gui.getGuiLeft()+37, gui.getGuiTop()+20, 188, 154, 60, 60);
|
2015-11-15 15:15:32 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
@Override
|
2015-11-29 14:30:44 +01:00
|
|
|
@SideOnly(Side.CLIENT)
|
2016-01-05 14:57:50 +01:00
|
|
|
public void render(IBookletGui gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){
|
2016-05-14 13:51:18 +02:00
|
|
|
LensConversionRecipe recipe = this.recipes[this.recipePos];
|
2015-11-25 22:13:51 +01:00
|
|
|
if(recipe == null){
|
2016-04-20 21:39:03 +02:00
|
|
|
StringUtil.drawSplitString(Minecraft.getMinecraft().fontRendererObj, TextFormatting.DARK_RED+StringUtil.localize("booklet."+ModUtil.MOD_ID+".recipeDisabled"), gui.getGuiLeft()+14, gui.getGuiTop()+15, 115, 0, false);
|
2015-11-15 15:15:32 +01:00
|
|
|
}
|
|
|
|
else{
|
|
|
|
String strg = "Atomic Reconstructor";
|
2016-01-07 23:42:42 +01:00
|
|
|
Minecraft.getMinecraft().fontRendererObj.drawString(strg, gui.getGuiLeft()+gui.getXSize()/2-Minecraft.getMinecraft().fontRendererObj.getStringWidth(strg)/2, gui.getGuiTop()+10, 0);
|
2015-11-15 15:15:32 +01:00
|
|
|
}
|
|
|
|
|
2016-05-14 13:51:18 +02:00
|
|
|
String text = gui.getCurrentEntrySet().getCurrentPage().getText();
|
2015-11-15 15:15:32 +01:00
|
|
|
if(text != null && !text.isEmpty()){
|
2016-01-07 23:42:42 +01:00
|
|
|
StringUtil.drawSplitString(Minecraft.getMinecraft().fontRendererObj, text, gui.getGuiLeft()+14, gui.getGuiTop()+100, 115, 0, false);
|
2015-11-15 15:15:32 +01:00
|
|
|
}
|
|
|
|
|
2015-11-25 22:13:51 +01:00
|
|
|
if(recipe != null){
|
2016-01-05 14:57:50 +01:00
|
|
|
AssetUtil.renderStackToGui(new ItemStack(InitBlocks.blockAtomicReconstructor), gui.getGuiLeft()+37+22, gui.getGuiTop()+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;
|
|
|
|
|
2016-01-05 14:57:50 +01:00
|
|
|
int xShow = gui.getGuiLeft()+37+1+x*42;
|
|
|
|
int yShow = gui.getGuiTop()+20+21;
|
2015-12-01 23:23:55 +01:00
|
|
|
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){
|
2016-01-05 14:57:50 +01:00
|
|
|
gui.renderTooltipAndTransferButton(this, stack, mouseX, mouseY, x == 0, mousePressed);
|
2015-12-01 23:23:55 +01:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-02-01 17:49:55 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public ItemStack[] getItemStacksForPage(){
|
|
|
|
if(this.recipes != null){
|
|
|
|
ArrayList<ItemStack> stacks = new ArrayList<ItemStack>();
|
2016-05-14 13:51:18 +02:00
|
|
|
for(LensConversionRecipe recipe : this.recipes){
|
2016-02-01 17:49:55 +01:00
|
|
|
if(recipe != null){
|
|
|
|
stacks.addAll(recipe.getOutputs());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return stacks.toArray(new ItemStack[stacks.size()]);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2015-11-15 15:15:32 +01:00
|
|
|
}
|