mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 00:38:35 +01:00
Added the ability to add fluids to booklet pages
This commit is contained in:
parent
020adc97b2
commit
7e46a77bcf
13 changed files with 107 additions and 44 deletions
|
@ -30,7 +30,7 @@ public final class ActuallyAdditionsAPI{
|
|||
|
||||
public static final String MOD_ID = "actuallyadditions";
|
||||
public static final String API_ID = MOD_ID+"api";
|
||||
public static final String API_VERSION = "24";
|
||||
public static final String API_VERSION = "25";
|
||||
|
||||
public static final List<CrusherRecipe> CRUSHER_RECIPES = new ArrayList<CrusherRecipe>();
|
||||
public static final List<BallOfFurReturn> BALL_OF_FUR_RETURN_ITEMS = new ArrayList<BallOfFurReturn>();
|
||||
|
@ -42,7 +42,7 @@ public final class ActuallyAdditionsAPI{
|
|||
public static final List<CompostRecipe> COMPOST_RECIPES = new ArrayList<CompostRecipe>();
|
||||
public static final Map<String, Integer> OIL_GENERATOR_RECIPES = new HashMap<String, Integer>();
|
||||
public static final List<IBookletEntry> BOOKLET_ENTRIES = new ArrayList<IBookletEntry>();
|
||||
public static final List<BookletPage> BOOKLET_PAGES_WITH_ITEM_DATA = new ArrayList<BookletPage>();
|
||||
public static final List<BookletPage> BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA = new ArrayList<BookletPage>();
|
||||
|
||||
/**
|
||||
* Use this to handle things that aren't based in the API itself
|
||||
|
@ -289,7 +289,8 @@ public final class ActuallyAdditionsAPI{
|
|||
*
|
||||
* @param page The page to add
|
||||
*/
|
||||
@Deprecated //Search will now be done on all pages that are in the book
|
||||
public static void addPageWithItemStackData(BookletPage page){
|
||||
BOOKLET_PAGES_WITH_ITEM_DATA.add(page);
|
||||
BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA.add(page);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ package de.ellpeck.actuallyadditions.api.booklet;
|
|||
import de.ellpeck.actuallyadditions.api.internal.IBookletGui;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
|
@ -67,9 +68,18 @@ public abstract class BookletPage{
|
|||
public abstract void updateScreen(int ticksElapsed);
|
||||
|
||||
/**
|
||||
* Gets the ItemStacks that are part of or displayed on this page (for NEI Handler, right-click function etc.)
|
||||
* Gets the ItemStacks that are part of or displayed on this page (for JEI Handler and search)
|
||||
*/
|
||||
public abstract ItemStack[] getItemStacksForPage();
|
||||
public ItemStack[] getItemStacksForPage(){
|
||||
return new ItemStack[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the FluidStacks that are part of or displayed on this page (for JEI Handler and search)
|
||||
*/
|
||||
public FluidStack[] getFluidStacksForPage(){
|
||||
return new FluidStack[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the text that is displayed when an Item is hovered over that can be clicked on to go to its page
|
||||
|
|
|
@ -32,6 +32,7 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
@ -39,6 +40,7 @@ import org.apache.commons.lang3.ArrayUtils;
|
|||
import java.awt.*;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
|
@ -134,8 +136,9 @@ public final class BookletUtils{
|
|||
|
||||
List<TheAchievements> achievements = null;
|
||||
for(BookletPage page : booklet.currentEntrySet.getCurrentChapter().getPages()){
|
||||
if(page != null && page.getItemStacksForPage() != null){
|
||||
for(ItemStack stack : page.getItemStacksForPage()){
|
||||
ItemStack[] stacks = page.getItemStacksForPage();
|
||||
if(page != null && stacks != null){
|
||||
for(ItemStack stack : stacks){
|
||||
if(stack != null){
|
||||
for(TheAchievements achievement : TheAchievements.values()){
|
||||
if(ItemUtil.contains(achievement.itemsToBeGotten, stack, true)){
|
||||
|
@ -257,15 +260,32 @@ public final class BookletUtils{
|
|||
if(pageStacks != null){
|
||||
for(ItemStack stack : pageStacks){
|
||||
if(stack != null && stack.getItem() != null){
|
||||
List<String> list = stack.getTooltip(mc.thePlayer, mc.gameSettings.advancedItemTooltips);
|
||||
for(String s : list){
|
||||
if(s != null && !s.isEmpty()){
|
||||
if(s.toLowerCase(Locale.ROOT).contains(text)){
|
||||
if(doesTooltipContainString(stack.getTooltip(mc.thePlayer, mc.gameSettings.advancedItemTooltips), text)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
FluidStack[] pageFluids = page.getFluidStacksForPage();
|
||||
if(pageFluids != null){
|
||||
for(FluidStack stack : pageFluids){
|
||||
if(stack != null && stack.getFluid() != null){
|
||||
if(doesTooltipContainString(Collections.singletonList(stack.getLocalizedName()), text)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static boolean doesTooltipContainString(List<String> tooltip, String text){
|
||||
for(String s : tooltip){
|
||||
if(s != null && !s.isEmpty()){
|
||||
if(s.toLowerCase(Locale.ROOT).contains(text)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -489,9 +509,14 @@ public final class BookletUtils{
|
|||
return pages.isEmpty() ? null : pages.get(0);
|
||||
}
|
||||
|
||||
public static BookletPage getFirstPageForStack(FluidStack stack){
|
||||
ArrayList<BookletPage> pages = getPagesForStack(stack);
|
||||
return pages.isEmpty() ? null : pages.get(0);
|
||||
}
|
||||
|
||||
public static ArrayList<BookletPage> getPagesForStack(ItemStack stack){
|
||||
ArrayList<BookletPage> possiblePages = new ArrayList<BookletPage>();
|
||||
for(BookletPage page : ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_DATA){
|
||||
for(BookletPage page : ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA){
|
||||
if(ItemUtil.contains(page.getItemStacksForPage(), stack, page.arePageStacksWildcard)){
|
||||
possiblePages.add(page);
|
||||
}
|
||||
|
@ -499,6 +524,19 @@ public final class BookletUtils{
|
|||
return possiblePages;
|
||||
}
|
||||
|
||||
public static ArrayList<BookletPage> getPagesForStack(FluidStack stack){
|
||||
ArrayList<BookletPage> possiblePages = new ArrayList<BookletPage>();
|
||||
for(BookletPage page : ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA){
|
||||
for(FluidStack pageStack : page.getFluidStacksForPage()){
|
||||
if(pageStack != null && pageStack.isFluidEqual(stack)){
|
||||
possiblePages.add(page);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return possiblePages;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void saveBookPage(GuiBooklet gui, NBTTagCompound compound){
|
||||
//Save Entry etc.
|
||||
|
|
|
@ -12,6 +12,9 @@ package de.ellpeck.actuallyadditions.mod.booklet;
|
|||
|
||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.BookletPage;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheColoredLampColors;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheMiscBlocks;
|
||||
|
@ -22,6 +25,7 @@ import de.ellpeck.actuallyadditions.mod.booklet.entry.BookletEntry;
|
|||
import de.ellpeck.actuallyadditions.mod.booklet.entry.BookletEntryAllSearch;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.page.*;
|
||||
import de.ellpeck.actuallyadditions.mod.crafting.*;
|
||||
import de.ellpeck.actuallyadditions.mod.fluids.InitFluids;
|
||||
import de.ellpeck.actuallyadditions.mod.gen.OreGen;
|
||||
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
||||
import de.ellpeck.actuallyadditions.mod.items.lens.LensDisenchanting;
|
||||
|
@ -30,11 +34,13 @@ import de.ellpeck.actuallyadditions.mod.items.metalists.TheFoods;
|
|||
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
|
||||
import de.ellpeck.actuallyadditions.mod.recipe.EmpowererHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.*;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
@ -57,6 +63,25 @@ public final class InitBooklet{
|
|||
|
||||
public static void postInit(){
|
||||
initChapters();
|
||||
|
||||
int count = 0;
|
||||
for(IBookletEntry entry : ActuallyAdditionsAPI.BOOKLET_ENTRIES){
|
||||
for(IBookletChapter chapter : entry.getChapters()){
|
||||
for(BookletPage page : chapter.getPages()){
|
||||
ItemStack[] items = page.getItemStacksForPage();
|
||||
FluidStack[] fluids = page.getFluidStacksForPage();
|
||||
|
||||
if((items != null && items.length > 0) || (fluids != null && fluids.length > 0)){
|
||||
if(!ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA.contains(page)){
|
||||
ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA.add(page);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ModUtil.LOGGER.info("Registered "+count+" booklet pages as containing information about items or fluids!");
|
||||
}
|
||||
|
||||
private static void initChapters(){
|
||||
|
@ -153,9 +178,10 @@ public final class InitBooklet{
|
|||
//RF Generating Blocks
|
||||
new BookletChapter("solarPanel", ActuallyAdditionsAPI.entryGeneratingRF, new ItemStack(InitBlocks.blockFurnaceSolar), new PageTextOnly(1).addTextReplacement("<rf>", TileEntityFurnaceSolar.PRODUCE), new PageCrafting(2, BlockCrafting.recipeSolar).setNoText());
|
||||
new BookletChapter("heatCollector", ActuallyAdditionsAPI.entryGeneratingRF, new ItemStack(InitBlocks.blockHeatCollector), new PageTextOnly(1).addTextReplacement("<rf>", TileEntityHeatCollector.ENERGY_PRODUCE).addTextReplacement("<min>", TileEntityHeatCollector.BLOCKS_NEEDED), new PageCrafting(2, BlockCrafting.recipeHeatCollector).setNoText());
|
||||
new BookletChapter("canola", ActuallyAdditionsAPI.entryGeneratingRF, new ItemStack(InitBlocks.blockFermentingBarrel), new PageTextOnly(1).setStacks(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CANOLA.ordinal()), new ItemStack(InitItems.itemCanolaSeed)), new PageTextOnly(2), new PageCrafting(3, BlockCrafting.recipeCanolaPress).setNoText(), new PageCrafting(4, BlockCrafting.recipeFermentingBarrel).setNoText(), new PageCrafting(5, BlockCrafting.recipeOilGen), new PageReconstructor(6, LensRecipeHandler.recipeCrystallizedCanolaSeed).setNoText(), new PageEmpowerer(7, EmpowererHandler.recipeEmpoweredCanolaSeed).setNoText());
|
||||
new BookletChapter("canola", ActuallyAdditionsAPI.entryGeneratingRF, new ItemStack(InitBlocks.blockFermentingBarrel), new PageTextOnly(1).setStacks(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CANOLA.ordinal()), new ItemStack(InitItems.itemCanolaSeed)).addFluidToPage(InitFluids.fluidCanolaOil), new PageTextOnly(2).addFluidToPage(InitFluids.fluidOil).addFluidToPage(InitFluids.fluidCrystalOil).addFluidToPage(InitFluids.fluidEmpoweredOil), new PageCrafting(3, BlockCrafting.recipeCanolaPress).setNoText(), new PageCrafting(4, BlockCrafting.recipeFermentingBarrel).setNoText(), new PageCrafting(5, BlockCrafting.recipeOilGen), new PageReconstructor(6, LensRecipeHandler.recipeCrystallizedCanolaSeed).setNoText(), new PageEmpowerer(7, EmpowererHandler.recipeEmpoweredCanolaSeed).setNoText());
|
||||
new BookletChapter("leafGen", ActuallyAdditionsAPI.entryGeneratingRF, new ItemStack(InitBlocks.blockLeafGenerator), new PageTextOnly(1).addTextReplacement("<rf>", TileEntityLeafGenerator.ENERGY_PRODUCED).addTextReplacement("<range>", TileEntityLeafGenerator.RANGE), new PageCrafting(2, BlockCrafting.recipeLeafGen)).setImportant();
|
||||
new BookletChapter("bioReactor", ActuallyAdditionsAPI.entryGeneratingRF, new ItemStack(InitBlocks.blockBioReactor), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeBioReactor).setNoText()).setSpecial();;
|
||||
new BookletChapter("bioReactor", ActuallyAdditionsAPI.entryGeneratingRF, new ItemStack(InitBlocks.blockBioReactor), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeBioReactor).setNoText()).setSpecial();
|
||||
;
|
||||
|
||||
//No RF Using Items
|
||||
new BookletChapter("bags", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(InitItems.itemBag), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeBag), new PageCrafting(3, ItemCrafting.recipeVoidBag).setNoText()).setImportant();
|
||||
|
|
|
@ -10,18 +10,22 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.booklet.page;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
import de.ellpeck.actuallyadditions.api.booklet.BookletPage;
|
||||
import de.ellpeck.actuallyadditions.api.internal.IBookletGui;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class BookletPageAA extends BookletPage{
|
||||
|
||||
protected List<FluidStack> fluidsForPage = new ArrayList<FluidStack>();
|
||||
protected final int localizationKey;
|
||||
|
||||
public BookletPageAA(int localizationKey){
|
||||
|
@ -69,27 +73,17 @@ public class BookletPageAA extends BookletPage{
|
|||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getItemStacksForPage(){
|
||||
return null;
|
||||
public FluidStack[] getFluidStacksForPage(){
|
||||
return this.fluidsForPage.toArray(new FluidStack[this.fluidsForPage.size()]);
|
||||
}
|
||||
|
||||
public BookletPageAA addFluidToPage(Fluid fluid){
|
||||
this.fluidsForPage.add(new FluidStack(fluid, 1));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClickToSeeRecipeString(){
|
||||
return TextFormatting.GOLD+StringUtil.localize("booklet."+ModUtil.MOD_ID+".clickToSeeRecipe");
|
||||
}
|
||||
|
||||
public void addToPagesWithItemStackData(){
|
||||
if(!ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_DATA.contains(this)){
|
||||
ItemStack[] stacks = this.getItemStacksForPage();
|
||||
if(stacks != null && stacks.length > 0){
|
||||
//Ensure that there is at least one ItemStack
|
||||
for(ItemStack stack : stacks){
|
||||
if(stack != null){
|
||||
ActuallyAdditionsAPI.addPageWithItemStackData(this);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,6 @@ public class PageCrafting extends BookletPageAA{
|
|||
public PageCrafting(int id, IRecipe... recipes){
|
||||
super(id);
|
||||
this.recipes = recipes;
|
||||
this.addToPagesWithItemStackData();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -30,7 +30,6 @@ public class PageCrusherRecipe extends BookletPageAA{
|
|||
public PageCrusherRecipe(int id, CrusherRecipe recipe){
|
||||
super(id);
|
||||
this.recipe = recipe;
|
||||
this.addToPagesWithItemStackData();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -37,7 +37,6 @@ public class PageEmpowerer extends BookletPageAA{
|
|||
public PageEmpowerer(int id, EmpowererRecipe... recipes){
|
||||
super(id);
|
||||
this.recipes = recipes;
|
||||
this.addToPagesWithItemStackData();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -38,7 +38,6 @@ public class PageFurnace extends BookletPageAA{
|
|||
super(id);
|
||||
this.result = result;
|
||||
this.input = input;
|
||||
this.addToPagesWithItemStackData();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -35,7 +35,6 @@ public class PageReconstructor extends BookletPageAA{
|
|||
public PageReconstructor(int id, LensConversionRecipe... recipes){
|
||||
super(id);
|
||||
this.recipes = recipes;
|
||||
this.addToPagesWithItemStackData();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -27,7 +27,6 @@ public class PageTextOnly extends BookletPageAA{
|
|||
|
||||
public PageTextOnly setStacks(ItemStack... stacks){
|
||||
this.stacks = stacks;
|
||||
this.addToPagesWithItemStackData();
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ public class JEIActuallyAdditionsPlugin implements IModPlugin{
|
|||
new BookletRecipeHandler()
|
||||
);
|
||||
|
||||
registry.addRecipes(ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_DATA);
|
||||
registry.addRecipes(ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA);
|
||||
registry.addRecipes(ActuallyAdditionsAPI.COFFEE_MACHINE_INGREDIENTS);
|
||||
registry.addRecipes(ActuallyAdditionsAPI.CRUSHER_RECIPES);
|
||||
registry.addRecipes(ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_CONVERSION_RECIPES);
|
||||
|
|
|
@ -51,12 +51,12 @@ public class BookletRecipeWrapper extends RecipeWrapperWithButton implements IRe
|
|||
|
||||
@Override
|
||||
public List<FluidStack> getFluidInputs(){
|
||||
return new ArrayList<FluidStack>();
|
||||
return Arrays.asList(this.thePage.getFluidStacksForPage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FluidStack> getFluidOutputs(){
|
||||
return new ArrayList<FluidStack>();
|
||||
return Arrays.asList(this.thePage.getFluidStacksForPage());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue