2015-08-29 23:01:13 +02:00
|
|
|
|
/*
|
2015-09-22 23:39:25 +02:00
|
|
|
|
* This file ("PageCrusherRecipe.java") is part of the Actually Additions Mod for Minecraft.
|
2015-08-29 23:01:13 +02:00
|
|
|
|
* 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.recipe.CrusherRecipeManualRegistry;
|
|
|
|
|
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;
|
2015-09-16 11:58:11 +02:00
|
|
|
|
import net.minecraft.util.EnumChatFormatting;
|
2015-08-29 23:01:13 +02:00
|
|
|
|
|
|
|
|
|
public class PageCrusherRecipe extends BookletPage{
|
|
|
|
|
|
2015-08-30 05:11:05 +02:00
|
|
|
|
public CrusherRecipeManualRegistry.CrusherRecipe recipe;
|
2015-08-29 23:01:13 +02:00
|
|
|
|
|
2015-08-30 05:11:05 +02:00
|
|
|
|
public PageCrusherRecipe(int id, CrusherRecipeManualRegistry.CrusherRecipe recipe){
|
2015-08-29 23:01:13 +02:00
|
|
|
|
super(id);
|
2015-08-30 05:11:05 +02:00
|
|
|
|
this.recipe = recipe;
|
2015-08-29 23:01:13 +02:00
|
|
|
|
InitBooklet.pagesWithItemStackData.add(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2015-09-28 23:39:34 +02:00
|
|
|
|
public void renderPre(GuiBooklet gui, int mouseX, int mouseY, boolean mouseClick, int ticksElapsed){
|
2015-08-30 19:10:10 +02:00
|
|
|
|
if(recipe != null){
|
2015-08-29 23:01:13 +02:00
|
|
|
|
gui.mc.getTextureManager().bindTexture(GuiBooklet.resLoc);
|
|
|
|
|
gui.drawTexturedModalRect(gui.guiLeft+37, gui.guiTop+20, 60, 180, 60, 60);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2015-09-28 23:39:34 +02:00
|
|
|
|
public ItemStack[] getItemStacksForPage(){
|
2015-09-29 17:42:04 +02:00
|
|
|
|
return this.recipe == null ? new ItemStack[0] : new ItemStack[]{this.recipe.firstOutput};
|
2015-08-29 23:01:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
@Override
|
2015-09-28 23:39:34 +02:00
|
|
|
|
public void render(GuiBooklet gui, int mouseX, int mouseY, boolean mouseClick, int ticksElapsed){
|
2015-08-30 19:10:10 +02:00
|
|
|
|
if(recipe == 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 = "Crusher 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
|
|
|
|
|
2015-08-30 05:11:05 +02:00
|
|
|
|
if(recipe.secondChance > 0){
|
2015-08-30 21:47:44 +02:00
|
|
|
|
gui.unicodeRenderer.drawString(recipe.secondChance+"%", gui.guiLeft+37+62, gui.guiTop+20+33, 0);
|
2015-08-29 23:01:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-30 05:11:05 +02:00
|
|
|
|
if(recipe.firstOutput != null){
|
2015-08-29 23:01:13 +02:00
|
|
|
|
for(int i = 0; i < 2; i++){
|
|
|
|
|
for(int j = 0; j < 3; j++){
|
2015-08-30 05:11:05 +02:00
|
|
|
|
ItemStack stack = (j == 0 ? this.recipe.input : (j == 1 ? recipe.firstOutput : (j == 2 ? recipe.secondOutput : null)));
|
2015-08-29 23:01:13 +02:00
|
|
|
|
|
|
|
|
|
if(stack != null){
|
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+(j == 0 ? 1 : (j == 1 ? 43 : (j == 2 ? 43 : 0)));
|
|
|
|
|
int yShow = gui.guiTop+20+(j == 0 ? 21 : (j == 1 ? 11 : (j == 2 ? 29 : 0)));
|
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, j == 0, mouseClick);
|
2015-08-29 23:01:13 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|