2015-08-29 23:01:13 +02:00
|
|
|
|
/*
|
|
|
|
|
* This file ("PageFurnace.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
|
|
|
|
|
*
|
|
|
|
|
* <EFBFBD> 2015 Ellpeck
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
package ellpeck.actuallyadditions.booklet.page;
|
|
|
|
|
|
|
|
|
|
import ellpeck.actuallyadditions.booklet.GuiBooklet;
|
|
|
|
|
import ellpeck.actuallyadditions.booklet.InitBooklet;
|
|
|
|
|
import ellpeck.actuallyadditions.util.ModUtil;
|
|
|
|
|
import ellpeck.actuallyadditions.util.StringUtil;
|
2015-08-30 19:10:10 +02:00
|
|
|
|
import ellpeck.actuallyadditions.util.Util;
|
2015-08-29 23:01:13 +02:00
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
|
import net.minecraft.item.crafting.FurnaceRecipes;
|
2015-09-16 11:58:11 +02:00
|
|
|
|
import net.minecraft.util.EnumChatFormatting;
|
2015-08-29 23:01:13 +02:00
|
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
public class PageFurnace extends BookletPage{
|
|
|
|
|
|
|
|
|
|
private final ItemStack result;
|
2015-08-30 19:10:10 +02:00
|
|
|
|
private final ItemStack input;
|
2015-08-29 23:01:13 +02:00
|
|
|
|
|
2015-08-30 19:10:10 +02:00
|
|
|
|
public PageFurnace(int id, ItemStack input, ItemStack result){
|
2015-08-29 23:01:13 +02:00
|
|
|
|
super(id);
|
|
|
|
|
this.result = result;
|
2015-08-30 19:10:10 +02:00
|
|
|
|
this.input = input;
|
2015-08-29 23:01:13 +02:00
|
|
|
|
InitBooklet.pagesWithItemStackData.add(this);
|
|
|
|
|
}
|
2015-08-30 19:10:10 +02:00
|
|
|
|
public PageFurnace(int id, ItemStack result){
|
|
|
|
|
this(id, null, result);
|
|
|
|
|
}
|
2015-08-29 23:01:13 +02:00
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ItemStack getItemStackForPage(){
|
|
|
|
|
return this.result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2015-08-31 02:05:41 +02:00
|
|
|
|
public void renderPre(GuiBooklet gui, int mouseX, int mouseY, boolean mouseClick){
|
2015-08-30 19:10:10 +02:00
|
|
|
|
if(this.input != null || this.getInputForOutput(this.result) != null){
|
2015-08-29 23:01:13 +02:00
|
|
|
|
gui.mc.getTextureManager().bindTexture(GuiBooklet.resLoc);
|
|
|
|
|
gui.drawTexturedModalRect(gui.guiLeft+37, gui.guiTop+20, 0, 180, 60, 60);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
@Override
|
2015-08-31 02:05:41 +02:00
|
|
|
|
public void render(GuiBooklet gui, int mouseX, int mouseY, boolean mouseClick){
|
2015-08-30 19:10:10 +02:00
|
|
|
|
ItemStack input = this.input != null ? this.input : this.getInputForOutput(this.result);
|
2015-08-29 23:01:13 +02:00
|
|
|
|
if(input == null){
|
2015-09-16 11:58:11 +02:00
|
|
|
|
gui.unicodeRenderer.drawSplitString(EnumChatFormatting.DARK_RED+StringUtil.localize("booklet."+ModUtil.MOD_ID_LOWER+".recipeDisabled"), gui.guiLeft+14, gui.guiTop+15, 115, 0);
|
2015-08-29 23:01:13 +02:00
|
|
|
|
}
|
2015-08-31 11:48:15 +02:00
|
|
|
|
else{
|
|
|
|
|
String strg = "Furnace Recipe";
|
|
|
|
|
gui.unicodeRenderer.drawString(strg, gui.guiLeft+gui.xSize/2-gui.unicodeRenderer.getStringWidth(strg)/2, gui.guiTop+10, 0);
|
|
|
|
|
}
|
2015-08-29 23:01:13 +02:00
|
|
|
|
|
2015-08-30 04:02:28 +02:00
|
|
|
|
String text = gui.currentPage.getText();
|
2015-09-14 11:02:16 +02:00
|
|
|
|
if(text != null && !text.isEmpty()){
|
2015-08-31 05:44:09 +02:00
|
|
|
|
gui.unicodeRenderer.drawSplitString(text, gui.guiLeft+14, gui.guiTop+100, 115, 0);
|
2015-08-30 04:02:28 +02:00
|
|
|
|
}
|
2015-08-29 23:01:13 +02:00
|
|
|
|
|
|
|
|
|
if(input != null){
|
|
|
|
|
for(int i = 0; i < 2; i++){
|
|
|
|
|
for(int x = 0; x < 2; x++){
|
|
|
|
|
ItemStack stack = x == 0 ? input : this.result;
|
2015-08-30 19:10:10 +02:00
|
|
|
|
if(stack.getItemDamage() == Util.WILDCARD) stack.setItemDamage(0);
|
2015-08-29 23:01:13 +02:00
|
|
|
|
boolean tooltip = i == 1;
|
|
|
|
|
|
2015-08-30 21:47:44 +02:00
|
|
|
|
int xShow = gui.guiLeft+37+1+x*42;
|
|
|
|
|
int yShow = gui.guiTop+20+21;
|
2015-08-29 23:01:13 +02:00
|
|
|
|
if(!tooltip){
|
2015-09-10 21:25:34 +02:00
|
|
|
|
renderItem(gui, stack, xShow, yShow, 1.0F);
|
2015-08-29 23:01:13 +02:00
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
if(mouseX >= xShow && mouseX <= xShow+16 && mouseY >= yShow && mouseY <= yShow+16){
|
2015-08-31 02:05:41 +02:00
|
|
|
|
this.renderTooltipAndTransfer(gui, stack, mouseX, mouseY, x == 0, mouseClick);
|
2015-08-29 23:01:13 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ItemStack getInputForOutput(ItemStack output){
|
|
|
|
|
for(Object o : FurnaceRecipes.smelting().getSmeltingList().entrySet()){
|
|
|
|
|
ItemStack stack = (ItemStack)((Map.Entry)o).getValue();
|
|
|
|
|
if(stack.isItemEqual(output)) return (ItemStack)((Map.Entry)o).getKey();
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|