2016-01-16 20:06:25 +01:00
|
|
|
/*
|
2016-05-16 22:52:27 +02:00
|
|
|
* This file ("BookletRecipeWrapper.java") is part of the Actually Additions mod for Minecraft.
|
2016-01-16 20:06:25 +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
|
2016-01-16 20:06:25 +01:00
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
*
|
2017-01-01 16:23:26 +01:00
|
|
|
* © 2015-2017 Ellpeck
|
2016-01-16 20:06:25 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
package de.ellpeck.actuallyadditions.mod.jei.booklet;
|
|
|
|
|
|
|
|
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
|
2016-11-10 19:50:01 +01:00
|
|
|
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
|
2018-05-10 11:38:58 +02:00
|
|
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
2016-01-17 01:14:30 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.jei.RecipeWrapperWithButton;
|
2016-01-16 20:06:25 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
2016-10-29 10:47:33 +02:00
|
|
|
import mezz.jei.api.ingredients.IIngredients;
|
2016-01-16 20:06:25 +01:00
|
|
|
import net.minecraft.client.Minecraft;
|
2016-11-08 23:35:11 +01:00
|
|
|
import net.minecraft.item.ItemStack;
|
2016-03-18 23:47:22 +01:00
|
|
|
import net.minecraft.util.text.TextFormatting;
|
2016-01-16 20:06:25 +01:00
|
|
|
import net.minecraftforge.fluids.FluidStack;
|
|
|
|
|
2016-11-11 18:55:32 +01:00
|
|
|
import java.util.ArrayList;
|
2016-01-16 20:06:25 +01:00
|
|
|
import java.util.List;
|
|
|
|
|
2016-10-31 20:19:55 +01:00
|
|
|
public class BookletRecipeWrapper extends RecipeWrapperWithButton{
|
2016-01-16 20:06:25 +01:00
|
|
|
|
2016-11-10 19:50:01 +01:00
|
|
|
public final IBookletPage thePage;
|
2016-01-16 20:06:25 +01:00
|
|
|
|
2016-11-10 19:50:01 +01:00
|
|
|
public BookletRecipeWrapper(IBookletPage page){
|
2016-01-16 20:06:25 +01:00
|
|
|
this.thePage = page;
|
|
|
|
}
|
|
|
|
|
2016-10-29 10:47:33 +02:00
|
|
|
@Override
|
|
|
|
public void getIngredients(IIngredients ingredients){
|
2016-11-11 18:55:32 +01:00
|
|
|
List<ItemStack> itemList = new ArrayList<ItemStack>();
|
|
|
|
this.thePage.getItemStacksForPage(itemList);
|
|
|
|
ingredients.setInputs(ItemStack.class, itemList);
|
|
|
|
ingredients.setOutputs(ItemStack.class, itemList);
|
|
|
|
|
|
|
|
List<FluidStack> fluidList = new ArrayList<FluidStack>();
|
|
|
|
this.thePage.getFluidStacksForPage(fluidList);
|
|
|
|
ingredients.setInputs(FluidStack.class, fluidList);
|
|
|
|
ingredients.setOutputs(FluidStack.class, fluidList);
|
2016-01-16 20:06:25 +01:00
|
|
|
}
|
|
|
|
|
2016-01-17 01:09:36 +01:00
|
|
|
@Override
|
2016-05-29 23:49:35 +02:00
|
|
|
public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY){
|
2018-05-10 11:38:58 +02:00
|
|
|
List<String> header = minecraft.fontRenderer.listFormattedStringToWidth(StringUtil.localize("container.nei."+ActuallyAdditions.MODID+".booklet.header").replaceAll("<item>", TextFormatting.BLUE+"").replaceAll("<r>", TextFormatting.BLACK+""), 150);
|
2016-01-16 20:06:25 +01:00
|
|
|
for(int i = 0; i < header.size(); i++){
|
2017-06-29 18:30:02 +02:00
|
|
|
minecraft.fontRenderer.drawString((String)header.get(i), 0, 17+i*(minecraft.fontRenderer.FONT_HEIGHT+1), 0, false);
|
2016-01-16 20:06:25 +01:00
|
|
|
}
|
|
|
|
|
2016-01-17 01:09:36 +01:00
|
|
|
int maxLines = 4;
|
2016-01-16 20:06:25 +01:00
|
|
|
IBookletChapter chapter = this.thePage.getChapter();
|
2016-11-10 19:50:01 +01:00
|
|
|
String aText = chapter.getAllPages()[0].getInfoText();
|
2018-05-10 11:38:58 +02:00
|
|
|
List<String> text = minecraft.fontRenderer.listFormattedStringToWidth(aText != null ? aText : TextFormatting.DARK_RED+StringUtil.localize("container.nei."+ActuallyAdditions.MODID+".booklet.noText"), 150);
|
2016-01-16 20:06:25 +01:00
|
|
|
for(int i = 0; i < Math.min(maxLines, text.size()); i++){
|
2017-06-29 18:30:02 +02:00
|
|
|
minecraft.fontRenderer.drawString(text.get(i)+(i == maxLines-1 && text.size() > maxLines ? TextFormatting.RESET+""+TextFormatting.BLACK+"..." : ""), 0, 16+25+i*(minecraft.fontRenderer.FONT_HEIGHT+1), 0, false);
|
2016-01-16 20:06:25 +01:00
|
|
|
}
|
2017-06-29 18:30:02 +02:00
|
|
|
minecraft.fontRenderer.drawString(TextFormatting.ITALIC+chapter.getLocalizedName(), 25, 85, 0, false);
|
|
|
|
minecraft.fontRenderer.drawString(TextFormatting.ITALIC+"Page "+(chapter.getPageIndex(this.thePage)+1), 25, 95, 0, false);
|
2016-01-17 01:09:36 +01:00
|
|
|
|
2016-10-31 20:19:55 +01:00
|
|
|
super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY);
|
2016-01-16 20:06:25 +01:00
|
|
|
}
|
|
|
|
|
2016-01-17 12:17:24 +01:00
|
|
|
@Override
|
|
|
|
public int getButtonX(){
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getButtonY(){
|
|
|
|
return 84;
|
|
|
|
}
|
2016-02-01 17:49:55 +01:00
|
|
|
|
|
|
|
@Override
|
2016-11-10 19:50:01 +01:00
|
|
|
public IBookletPage getPage(){
|
2016-02-01 17:49:55 +01:00
|
|
|
return this.thePage;
|
|
|
|
}
|
2016-01-16 20:06:25 +01:00
|
|
|
}
|