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
|
|
|
|
*
|
2015-11-02 20:55:19 +01:00
|
|
|
* © 2015 Ellpeck
|
2015-08-29 23:01:13 +02:00
|
|
|
*/
|
|
|
|
|
2015-12-30 22:02:15 +01:00
|
|
|
package de.ellpeck.actuallyadditions.booklet.page;
|
2015-08-29 23:01:13 +02:00
|
|
|
|
2015-11-29 14:30:44 +01:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2015-12-30 22:02:15 +01:00
|
|
|
import de.ellpeck.actuallyadditions.booklet.GuiBooklet;
|
|
|
|
import de.ellpeck.actuallyadditions.proxy.ClientProxy;
|
|
|
|
import de.ellpeck.actuallyadditions.recipe.CrusherRecipeRegistry;
|
|
|
|
import de.ellpeck.actuallyadditions.util.AssetUtil;
|
|
|
|
import de.ellpeck.actuallyadditions.util.ModUtil;
|
|
|
|
import de.ellpeck.actuallyadditions.util.StringUtil;
|
|
|
|
import de.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
|
|
|
|
2015-11-15 18:14:39 +01:00
|
|
|
import java.util.List;
|
2015-10-03 23:28:32 +02:00
|
|
|
|
2015-10-03 22:09:53 +02:00
|
|
|
|
2015-08-29 23:01:13 +02:00
|
|
|
public class PageCrusherRecipe extends BookletPage{
|
|
|
|
|
2015-10-03 21:56:22 +02:00
|
|
|
public CrusherRecipeRegistry.CrusherRecipe recipe;
|
2015-08-29 23:01:13 +02:00
|
|
|
|
2015-11-10 21:26:28 +01:00
|
|
|
private int recipePos;
|
2015-10-03 21:56:22 +02:00
|
|
|
|
|
|
|
public PageCrusherRecipe(int id, CrusherRecipeRegistry.CrusherRecipe recipe){
|
2015-08-29 23:01:13 +02:00
|
|
|
super(id);
|
2015-08-30 05:11:05 +02:00
|
|
|
this.recipe = recipe;
|
2015-10-30 21:42:14 +01:00
|
|
|
this.addToPagesWithItemStackData();
|
2015-08-29 23:01:13 +02:00
|
|
|
}
|
|
|
|
|
2015-12-01 19:48:09 +01:00
|
|
|
@Override
|
|
|
|
public ItemStack[] getItemStacksForPage(){
|
|
|
|
return this.recipe == null ? new ItemStack[0] : this.recipe.getRecipeOutputOnes().toArray(new ItemStack[this.recipe.getRecipeOutputOnes().size()]);
|
|
|
|
}
|
|
|
|
|
2015-08-29 23:01:13 +02:00
|
|
|
@Override
|
2015-11-29 14:30:44 +01:00
|
|
|
@SideOnly(Side.CLIENT)
|
2015-10-04 13:21:07 +02:00
|
|
|
public void renderPre(GuiBooklet gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){
|
2015-08-30 19:10:10 +02:00
|
|
|
if(recipe != null){
|
2015-10-23 23:08:53 +02:00
|
|
|
gui.mc.getTextureManager().bindTexture(ClientProxy.bulletForMyValentine ? GuiBooklet.resLocValentine : GuiBooklet.resLoc);
|
2015-08-29 23:01:13 +02:00
|
|
|
gui.drawTexturedModalRect(gui.guiLeft+37, gui.guiTop+20, 60, 180, 60, 60);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
@Override
|
2015-11-29 14:30:44 +01:00
|
|
|
@SideOnly(Side.CLIENT)
|
2015-10-04 13:21:07 +02:00
|
|
|
public void render(GuiBooklet gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){
|
2015-08-30 19:10:10 +02: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-08-29 23:01:13 +02:00
|
|
|
}
|
2015-08-31 11:48:15 +02:00
|
|
|
else{
|
|
|
|
String strg = "Crusher Recipe";
|
2015-10-03 19:19:26 +02:00
|
|
|
gui.mc.fontRenderer.drawString(strg, gui.guiLeft+gui.xSize/2-gui.mc.fontRenderer.getStringWidth(strg)/2, gui.guiTop+10, 0);
|
2015-08-31 11:48:15 +02:00
|
|
|
}
|
2015-08-29 23:01:13 +02:00
|
|
|
|
2015-12-04 18:55:50 +01:00
|
|
|
String text = gui.currentEntrySet.page.getText();
|
2015-09-14 11:02:16 +02: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-08-30 04:02:28 +02:00
|
|
|
}
|
2015-08-29 23:01:13 +02:00
|
|
|
|
2015-10-03 23:28:32 +02:00
|
|
|
if(recipe != null){
|
|
|
|
if(recipe.outputTwoChance > 0){
|
|
|
|
gui.mc.fontRenderer.drawString(recipe.outputTwoChance+"%", gui.guiLeft+37+62, gui.guiTop+20+33, 0);
|
|
|
|
}
|
2015-08-29 23:01:13 +02:00
|
|
|
|
2015-10-03 23:28:32 +02:00
|
|
|
if(recipe.getRecipeOutputOnes() != null){
|
|
|
|
for(int i = 0; i < 2; i++){
|
|
|
|
for(int j = 0; j < 3; j++){
|
|
|
|
ItemStack stack;
|
|
|
|
switch(j){
|
|
|
|
case 0:
|
2015-11-10 21:26:28 +01:00
|
|
|
stack = this.recipe.getRecipeInputs().get(Math.min(this.recipe.getRecipeInputs().size()-1, this.recipePos));
|
2015-10-03 23:28:32 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
2015-11-10 21:26:28 +01:00
|
|
|
stack = this.recipe.getRecipeOutputOnes().get(Math.min(this.recipe.getRecipeOutputOnes().size()-1, this.recipePos));
|
2015-10-03 23:28:32 +02:00
|
|
|
break;
|
|
|
|
default:
|
2015-11-15 18:14:39 +01:00
|
|
|
List<ItemStack> outputTwos = this.recipe.getRecipeOutputTwos();
|
2015-11-10 21:26:28 +01:00
|
|
|
stack = outputTwos == null ? null : outputTwos.get(Math.min(outputTwos.size()-1, this.recipePos));
|
2015-10-03 23:28:32 +02:00
|
|
|
break;
|
2015-10-03 10:16:18 +02:00
|
|
|
}
|
2015-08-30 19:10:10 +02:00
|
|
|
|
2015-10-03 23:28:32 +02:00
|
|
|
if(stack != null){
|
|
|
|
if(stack.getItemDamage() == Util.WILDCARD){
|
|
|
|
stack.setItemDamage(0);
|
|
|
|
}
|
2015-08-29 23:01:13 +02:00
|
|
|
|
2015-10-03 23:28:32 +02:00
|
|
|
boolean tooltip = i == 1;
|
|
|
|
|
|
|
|
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)));
|
|
|
|
if(!tooltip){
|
2015-12-22 14:58:25 +01:00
|
|
|
AssetUtil.renderStackToGui(stack, xShow, yShow, 1.0F);
|
2015-10-03 23:28:32 +02:00
|
|
|
}
|
|
|
|
else{
|
|
|
|
if(mouseX >= xShow && mouseX <= xShow+16 && mouseY >= yShow && mouseY <= yShow+16){
|
2015-10-04 13:21:07 +02:00
|
|
|
this.renderTooltipAndTransfer(gui, stack, mouseX, mouseY, j == 0, mousePressed);
|
2015-10-03 23:28:32 +02:00
|
|
|
}
|
2015-08-29 23:01:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-10-03 10:19:40 +02:00
|
|
|
|
2015-10-03 22:13:57 +02:00
|
|
|
@Override
|
2015-11-29 14:30:44 +01:00
|
|
|
@SideOnly(Side.CLIENT)
|
2015-10-03 22:13:57 +02:00
|
|
|
public void updateScreen(int ticksElapsed){
|
2015-10-05 11:27:53 +02:00
|
|
|
if(ticksElapsed%10 == 0){
|
2015-11-15 18:14:39 +01:00
|
|
|
List<ItemStack> outputTwos = this.recipe.getRecipeOutputTwos();
|
2015-11-10 21:26:28 +01:00
|
|
|
if(this.recipePos+1 >= Math.max(this.recipe.getRecipeInputs().size(), Math.max(this.recipe.getRecipeOutputOnes().size(), outputTwos == null ? 0 : outputTwos.size()))){
|
|
|
|
this.recipePos = 0;
|
2015-10-03 22:13:57 +02:00
|
|
|
}
|
|
|
|
else{
|
2015-11-10 21:26:28 +01:00
|
|
|
this.recipePos++;
|
2015-10-03 22:13:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-08-29 23:01:13 +02:00
|
|
|
}
|