ActuallyAdditions/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/BookletUtils.java

442 lines
21 KiB
Java
Raw Normal View History

/*
2016-05-16 22:52:27 +02:00
* This file ("BookletUtils.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
2016-05-16 22:52:27 +02:00
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
2016-05-16 22:54:42 +02:00
* © 2015-2016 Ellpeck
*/
2016-01-05 04:47:35 +01:00
package de.ellpeck.actuallyadditions.mod.booklet;
2016-01-05 14:57:50 +01:00
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;
2016-01-05 04:47:35 +01:00
import de.ellpeck.actuallyadditions.mod.achievement.InitAchievements;
import de.ellpeck.actuallyadditions.mod.booklet.button.BookmarkButton;
import de.ellpeck.actuallyadditions.mod.booklet.button.IndexButton;
import de.ellpeck.actuallyadditions.mod.booklet.button.TexturedButton;
import de.ellpeck.actuallyadditions.mod.booklet.entry.BookletEntryAllSearch;
import de.ellpeck.actuallyadditions.mod.proxy.ClientProxy;
2016-03-18 15:42:06 +01:00
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import de.ellpeck.actuallyadditions.mod.util.Util;
2015-12-17 21:58:59 +01:00
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
2016-03-18 15:42:06 +01:00
import net.minecraft.client.gui.GuiScreen;
2015-11-13 21:40:38 +01:00
import net.minecraft.item.ItemStack;
import net.minecraft.stats.Achievement;
2016-03-18 23:47:22 +01:00
import net.minecraft.util.text.TextFormatting;
import java.awt.*;
import java.net.URI;
import java.util.ArrayList;
2016-01-05 14:57:50 +01:00
import java.util.List;
import java.util.Locale;
public class BookletUtils{
/**
* Tries to open a URL in the Browser
2015-12-01 19:48:09 +01:00
*/
public static void openBrowser(String url){
openBrowser(url, url);
}
/**
* Tries to open a URL in the Browser
*
* @param url The URL
* @param shiftUrl The URL to open when Shift is held
*/
public static void openBrowser(String url, String shiftUrl){
try{
if(Desktop.isDesktopSupported()){
2016-03-18 15:42:06 +01:00
if(shiftUrl.equals(url) || GuiScreen.isShiftKeyDown()){
Desktop.getDesktop().browse(new URI(shiftUrl));
}
else{
Desktop.getDesktop().browse(new URI(url));
}
}
}
catch(Exception e){
ModUtil.LOGGER.error("Something bad happened when trying to open a URL!", e);
}
}
/**
* Draws the Title of the current chapter, current index entry or just "Actually Additions" if neither is present
*/
public static void drawTitle(GuiBooklet booklet){
2015-12-06 01:01:18 +01:00
booklet.mc.getTextureManager().bindTexture(GuiBooklet.resLoc);
//Upper title
booklet.drawTexturedModalRect(booklet.guiLeft+booklet.xSize/2-142/2, booklet.guiTop-12, 0, 240, 142, 12);
//Lower title
booklet.drawTexturedModalRect(booklet.guiLeft+booklet.xSize/2-142/2, booklet.guiTop+booklet.ySize, 0, 243, 142, 13);
2015-12-17 21:58:59 +01:00
//Draw No Entry title
2016-05-14 13:51:18 +02:00
if(booklet.currentEntrySet.getCurrentEntry() == null){
2016-04-20 21:39:03 +02:00
String strg = TextFormatting.DARK_GREEN+StringUtil.localize("info."+ModUtil.MOD_ID+".booklet.manualName.1");
2015-12-17 21:58:59 +01:00
booklet.getFontRenderer().drawString(strg, booklet.guiLeft+booklet.xSize/2-booklet.getFontRenderer().getStringWidth(strg)/2-3, booklet.guiTop+12, 0);
2016-04-20 21:39:03 +02:00
strg = TextFormatting.DARK_GREEN+StringUtil.localize("info."+ModUtil.MOD_ID+".booklet.manualName.2");
2015-12-17 21:58:59 +01:00
booklet.getFontRenderer().drawString(strg, booklet.guiLeft+booklet.xSize/2-booklet.getFontRenderer().getStringWidth(strg)/2-3, booklet.guiTop+12+booklet.getFontRenderer().FONT_HEIGHT, 0);
String version;
String playerName = Minecraft.getMinecraft().thePlayer.getName();
2015-12-18 15:46:38 +01:00
if(playerName.equals("dqmhose")){
2015-12-17 21:58:59 +01:00
version = "Pants Edition";
}
2015-12-27 17:24:13 +01:00
else if(playerName.equals("TwoOfEight")){
version = "Illustrator's Edition";
}
2015-12-18 15:46:38 +01:00
else if(playerName.equals("KittyVanCat")){
2015-12-17 21:58:59 +01:00
version = "Cat's Edition";
}
2016-03-08 00:05:34 +01:00
else if(playerName.equals("canitzp")){
version = "P's Edition";
}
2015-12-18 15:46:38 +01:00
else if(playerName.equals("Ellpeck") || Util.isDevVersion()){
2015-12-17 21:58:59 +01:00
version = "Dev's Edition";
}
else{
2016-04-20 21:39:03 +02:00
version = StringUtil.localize("info."+ModUtil.MOD_ID+".booklet.edition")+" "+ModUtil.VERSION.substring(ModUtil.VERSION.indexOf("r")+1);
2015-12-17 21:58:59 +01:00
}
2016-03-18 23:47:22 +01:00
strg = TextFormatting.GOLD+TextFormatting.ITALIC.toString()+"-"+version+"-";
2015-12-17 21:58:59 +01:00
booklet.getFontRenderer().drawString(strg, booklet.guiLeft+booklet.xSize/2-booklet.getFontRenderer().getStringWidth(strg)/2-3, booklet.guiTop+33, 0);
}
2016-05-14 13:51:18 +02:00
String strg = booklet.currentEntrySet.getCurrentChapter() == null ? (booklet.currentEntrySet.getCurrentEntry() == null ? StringUtil.localize("itemGroup."+ModUtil.MOD_ID) : booklet.currentEntrySet.getCurrentEntry().getLocalizedName()) : booklet.currentEntrySet.getCurrentChapter().getLocalizedName();
booklet.drawCenteredString(booklet.getFontRenderer(), strg, booklet.guiLeft+booklet.xSize/2, booklet.guiTop-9, StringUtil.DECIMAL_COLOR_WHITE);
}
2015-11-13 21:40:38 +01:00
/**
* Draws an Achievement Info if the page has items that trigger achievements
2015-12-01 19:48:09 +01:00
*
2015-11-13 21:40:38 +01:00
* @param pre If the hover info texts or the icon should be drawn
*/
public static void drawAchievementInfo(GuiBooklet booklet, boolean pre, int mouseX, int mouseY){
2016-05-14 13:51:18 +02:00
if(booklet.currentEntrySet.getCurrentChapter() == null){
2015-11-13 21:40:38 +01:00
return;
}
ArrayList<String> infoList = null;
2016-05-14 13:51:18 +02:00
for(BookletPage page : booklet.currentEntrySet.getCurrentChapter().getPages()){
2015-11-16 19:57:46 +01:00
if(page != null && page.getItemStacksForPage() != null){
for(ItemStack stack : page.getItemStacksForPage()){
if(stack != null){
for(Achievement achievement : InitAchievements.achievementList){
if(achievement.theItemStack != null && ItemUtil.areItemsEqual(stack, achievement.theItemStack, true)){
if(pre){
booklet.mc.getTextureManager().bindTexture(GuiBooklet.resLoc);
booklet.drawTexturedModalRect(booklet.guiLeft+booklet.xSize+1, booklet.guiTop-18, 166, 154, 22, 21);
return;
}
else{
if(mouseX >= booklet.guiLeft+booklet.xSize+1 && mouseX < booklet.guiLeft+booklet.xSize+1+22 && mouseY >= booklet.guiTop-18 && mouseY < booklet.guiTop-18+21){
if(infoList == null){
infoList = new ArrayList<String>();
2016-03-18 23:47:22 +01:00
infoList.add(TextFormatting.GOLD+"Achievements related to this chapter:");
}
infoList.add("-"+StringUtil.localize(achievement.statId));
2016-03-18 23:47:22 +01:00
infoList.add(TextFormatting.GRAY+"("+achievement.getDescription()+")");
2015-11-16 19:57:46 +01:00
}
}
2015-11-13 21:40:38 +01:00
}
}
}
}
}
}
if(infoList != null){
booklet.drawHoveringText(infoList, mouseX, mouseY);
2015-11-13 21:40:38 +01:00
}
}
/**
* Pre-renders the booklet page, including
* -the number of a page and its content (text, crafting recipe etc.)
* -the number of a page in a chapter
* -the amount of words and chars in the index (Just for teh lulz)
*/
public static void renderPre(GuiBooklet booklet, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){
2016-05-14 13:51:18 +02:00
if(booklet.currentEntrySet.getCurrentEntry() != null){
//Renders Booklet Page Number and Content
2016-05-14 13:51:18 +02:00
if(booklet.currentEntrySet.getCurrentChapter() != null && booklet.currentEntrySet.getCurrentPage() != null){
booklet.drawCenteredString(booklet.getFontRenderer(), booklet.currentEntrySet.getCurrentPage().getID()+"/"+booklet.currentEntrySet.getCurrentChapter().getPages().length, booklet.guiLeft+booklet.xSize/2, booklet.guiTop+171, StringUtil.DECIMAL_COLOR_WHITE);
booklet.currentEntrySet.getCurrentPage().renderPre(booklet, mouseX, mouseY, ticksElapsed, mousePressed);
}
//Renders Chapter Page Number
else{
2016-05-14 13:51:18 +02:00
booklet.drawCenteredString(booklet.getFontRenderer(), booklet.currentEntrySet.getPageInIndex()+"/"+booklet.indexPageAmount, booklet.guiLeft+booklet.xSize/2, booklet.guiTop+171, StringUtil.DECIMAL_COLOR_WHITE);
}
}
//Renders the amount of words and chars the book has
else{
2016-04-20 21:39:03 +02:00
String wordCountString = StringUtil.localizeFormatted("booklet."+ModUtil.MOD_ID+".amountOfWords", ClientProxy.bookletWordCount);
2016-03-18 23:47:22 +01:00
booklet.getFontRenderer().drawString(TextFormatting.ITALIC+wordCountString, booklet.guiLeft+booklet.xSize-booklet.getFontRenderer().getStringWidth(wordCountString)-15, booklet.guiTop+booklet.ySize-18-booklet.getFontRenderer().FONT_HEIGHT, 0);
2016-04-20 21:39:03 +02:00
String charCountString = StringUtil.localizeFormatted("booklet."+ModUtil.MOD_ID+".amountOfChars", ClientProxy.bookletCharCount);
2016-03-18 23:47:22 +01:00
booklet.getFontRenderer().drawString(TextFormatting.ITALIC+charCountString, booklet.guiLeft+booklet.xSize-booklet.getFontRenderer().getStringWidth(charCountString)-15, booklet.guiTop+booklet.ySize-18, 0);
}
}
/**
* Draws all of the hovering texts for the buttons that need explanation in the booklet
*/
@SuppressWarnings("unchecked")
public static void doHoverTexts(GuiBooklet booklet, int mouseX, int mouseY){
2015-12-04 18:14:03 +01:00
//Update all of the buttons' hovering texts
for(Object button : booklet.getButtonList()){
if(button instanceof GuiButton && ((GuiButton)button).visible && ((GuiButton)button).isMouseOver()){
2015-12-04 18:14:03 +01:00
if(button instanceof BookmarkButton){
2015-11-16 19:57:46 +01:00
((BookmarkButton)button).drawHover(mouseX, mouseY);
}
2015-12-04 18:14:03 +01:00
else if(button instanceof TexturedButton){
booklet.drawHoveringText(((TexturedButton)button).textList, mouseX, mouseY);
}
else if(button instanceof IndexButton){
((IndexButton)button).drawHover(mouseX, mouseY);
}
2015-11-16 19:57:46 +01:00
}
}
}
/**
* Updates the search bar, should be called when it is getting typed into
*/
@SuppressWarnings("unchecked")
public static void updateSearchBar(GuiBooklet booklet){
2016-05-14 13:51:18 +02:00
if(booklet.currentEntrySet.getCurrentEntry() instanceof BookletEntryAllSearch){
BookletEntryAllSearch currentEntry = (BookletEntryAllSearch)booklet.currentEntrySet.getCurrentEntry();
if(booklet.searchField.getText() != null && !booklet.searchField.getText().isEmpty()){
currentEntry.chapters.clear();
2016-01-05 14:57:50 +01:00
for(IBookletChapter chapter : currentEntry.allChapters){
String searchFieldText = booklet.searchField.getText().toLowerCase(Locale.ROOT);
if(chapter.getLocalizedName().toLowerCase(Locale.ROOT).contains(searchFieldText) || getChapterStacksContainString(searchFieldText, chapter)){
currentEntry.chapters.add(chapter);
}
}
}
else{
2016-01-05 14:57:50 +01:00
currentEntry.setChapters((ArrayList<IBookletChapter>)currentEntry.allChapters.clone());
}
2016-05-14 13:51:18 +02:00
openIndexEntry(booklet, booklet.currentEntrySet.getCurrentEntry(), booklet.currentEntrySet.getPageInIndex(), false);
}
}
private static boolean getChapterStacksContainString(String text, IBookletChapter chapter){
for(BookletPage page : chapter.getPages()){
ItemStack[] pageStacks = page.getItemStacksForPage();
if(pageStacks != null){
for(ItemStack stack : pageStacks){
if(stack.getDisplayName().toLowerCase(Locale.ROOT).contains(text)){
return true;
}
}
}
}
return false;
}
2015-12-01 19:48:09 +01:00
@SuppressWarnings("unchecked")
2016-01-05 14:57:50 +01:00
public static void openIndexEntry(GuiBooklet booklet, IBookletEntry entry, int page, boolean resetTextField){
2015-12-01 19:48:09 +01:00
booklet.searchField.setVisible(entry instanceof BookletEntryAllSearch);
booklet.searchField.setFocused(entry instanceof BookletEntryAllSearch);
if(resetTextField){
booklet.searchField.setText("");
if(entry instanceof BookletEntryAllSearch){
2016-01-05 14:57:50 +01:00
entry.setChapters((List<IBookletChapter>)((BookletEntryAllSearch)entry).allChapters.clone());
2015-12-01 19:48:09 +01:00
}
}
2016-05-14 13:51:18 +02:00
booklet.currentEntrySet.setPage(null);
booklet.currentEntrySet.setChapter(null);
2015-12-01 19:48:09 +01:00
2016-05-14 13:51:18 +02:00
booklet.currentEntrySet.setEntry(entry);
2016-01-05 14:57:50 +01:00
booklet.indexPageAmount = entry == null ? 1 : entry.getChapters().size()/booklet.chapterButtons.length+1;
2016-05-14 13:51:18 +02:00
booklet.currentEntrySet.setPageInIndex(entry == null ? 1 : (booklet.indexPageAmount <= page || page <= 0 ? booklet.indexPageAmount : page));
2015-12-01 19:48:09 +01:00
booklet.buttonPreviousScreen.visible = entry != null;
2016-05-14 13:51:18 +02:00
booklet.buttonForward.visible = booklet.currentEntrySet.getPageInIndex() < booklet.indexPageAmount;
booklet.buttonBackward.visible = booklet.currentEntrySet.getPageInIndex() > 1;
2015-12-01 19:48:09 +01:00
for(int i = 0; i < booklet.chapterButtons.length; i++){
IndexButton button = (IndexButton)booklet.chapterButtons[i];
if(entry == null){
2015-12-17 21:58:59 +01:00
if(i >= GuiBooklet.INDEX_BUTTONS_OFFSET){
2016-01-05 14:57:50 +01:00
boolean entryExists = ActuallyAdditionsAPI.bookletEntries.size() > i-GuiBooklet.INDEX_BUTTONS_OFFSET;
2015-12-17 21:58:59 +01:00
button.visible = entryExists;
if(entryExists){
button.displayString = ""+ActuallyAdditionsAPI.bookletEntries.get(i-GuiBooklet.INDEX_BUTTONS_OFFSET).getLocalizedNameWithFormatting();
2015-12-17 21:58:59 +01:00
button.chap = null;
}
}
else{
button.visible = false;
2015-12-01 19:48:09 +01:00
}
}
else{
2016-05-14 13:51:18 +02:00
boolean entryExists = entry.getChapters().size() > i+(booklet.chapterButtons.length*booklet.currentEntrySet.getPageInIndex()-booklet.chapterButtons.length);
2015-12-01 19:48:09 +01:00
button.visible = entryExists;
if(entryExists){
2016-05-14 13:51:18 +02:00
IBookletChapter chap = entry.getChapters().get(i+(booklet.chapterButtons.length*booklet.currentEntrySet.getPageInIndex()-booklet.chapterButtons.length));
2016-01-05 14:57:50 +01:00
button.displayString = chap.getLocalizedNameWithFormatting();
2015-12-01 19:48:09 +01:00
button.chap = chap;
}
}
}
}
/**
* Called when one of the buttons to open an index or a chapter is pressed
*/
public static void handleChapterButtonClick(GuiBooklet booklet, GuiButton button){
int place = Util.arrayContains(booklet.chapterButtons, button);
if(place >= 0){
2016-05-14 13:51:18 +02:00
if(booklet.currentEntrySet.getCurrentEntry() != null){
if(booklet.currentEntrySet.getCurrentChapter() == null){
if(place < booklet.currentEntrySet.getCurrentEntry().getChapters().size()){
IBookletChapter chap = booklet.currentEntrySet.getCurrentEntry().getChapters().get(place+(booklet.chapterButtons.length*booklet.currentEntrySet.getPageInIndex()-booklet.chapterButtons.length));
2016-01-05 14:57:50 +01:00
openChapter(booklet, chap, chap.getPages()[0]);
}
}
}
else{
2016-01-05 14:57:50 +01:00
if(place-GuiBooklet.INDEX_BUTTONS_OFFSET < ActuallyAdditionsAPI.bookletEntries.size()){
openIndexEntry(booklet, ActuallyAdditionsAPI.bookletEntries.get(place-GuiBooklet.INDEX_BUTTONS_OFFSET), 1, true);
}
}
}
}
/**
2015-12-01 19:48:09 +01:00
* Opens a chapter in the booklet.
* Can only be done when the chapter is not null and an index entry is opened in the booklet
*/
2016-01-05 14:57:50 +01:00
public static void openChapter(GuiBooklet booklet, IBookletChapter chapter, BookletPage page){
2016-05-14 13:51:18 +02:00
if(chapter == null || booklet.currentEntrySet.getCurrentEntry() == null){
2015-12-01 19:48:09 +01:00
return;
}
2015-12-01 19:48:09 +01:00
booklet.searchField.setVisible(false);
booklet.searchField.setFocused(false);
booklet.searchField.setText("");
2016-05-14 13:51:18 +02:00
booklet.currentEntrySet.setChapter(chapter);
booklet.currentEntrySet.setPage(page != null && doesChapterHavePage(chapter, page) ? page : chapter.getPages()[0]);
2015-12-01 19:48:09 +01:00
2016-05-14 13:51:18 +02:00
booklet.buttonForward.visible = getNextPage(chapter, booklet.currentEntrySet.getCurrentPage()) != null;
booklet.buttonBackward.visible = getPrevPage(chapter, booklet.currentEntrySet.getCurrentPage()) != null;
2015-12-01 19:48:09 +01:00
booklet.buttonPreviousScreen.visible = true;
for(GuiButton chapterButton : booklet.chapterButtons){
chapterButton.visible = false;
}
}
/**
2015-12-01 19:48:09 +01:00
* Checks if a chapter has a certain page
*/
2016-01-05 14:57:50 +01:00
private static boolean doesChapterHavePage(IBookletChapter chapter, BookletPage page){
for(BookletPage aPage : chapter.getPages()){
2015-12-01 19:48:09 +01:00
if(aPage == page){
return true;
}
}
2015-12-01 19:48:09 +01:00
return false;
}
/**
* Gets the next available page in the booklet (or null if there is none)
*/
2016-01-05 14:57:50 +01:00
private static BookletPage getNextPage(IBookletChapter chapter, BookletPage page){
for(int i = 0; i < chapter.getPages().length; i++){
if(chapter.getPages()[i] == page){
if(i+1 < chapter.getPages().length){
return chapter.getPages()[i+1];
}
}
}
return null;
}
/**
* Gets the previous available page in the booklet (or null if there is none)
*/
2016-01-05 14:57:50 +01:00
private static BookletPage getPrevPage(IBookletChapter chapter, BookletPage page){
for(int i = 0; i < chapter.getPages().length; i++){
if(chapter.getPages()[i] == page){
if(i-1 >= 0){
2016-01-05 14:57:50 +01:00
return chapter.getPages()[i-1];
}
}
}
return null;
}
/**
2015-12-01 19:48:09 +01:00
* Called when the "next page"-button is pressed
*/
2015-12-01 19:48:09 +01:00
public static void handleNextPage(GuiBooklet booklet){
2016-05-14 13:51:18 +02:00
if(booklet.currentEntrySet.getCurrentEntry() != null){
if(booklet.currentEntrySet.getCurrentPage() != null){
BookletPage page = getNextPage(booklet.currentEntrySet.getCurrentChapter(), booklet.currentEntrySet.getCurrentPage());
2015-12-01 19:48:09 +01:00
if(page != null){
2016-05-14 13:51:18 +02:00
booklet.currentEntrySet.setPage(page);
2015-12-01 19:48:09 +01:00
}
2016-05-14 13:51:18 +02:00
booklet.buttonForward.visible = getNextPage(booklet.currentEntrySet.getCurrentChapter(), booklet.currentEntrySet.getCurrentPage()) != null;
booklet.buttonBackward.visible = getPrevPage(booklet.currentEntrySet.getCurrentChapter(), booklet.currentEntrySet.getCurrentPage()) != null;
2015-12-01 19:48:09 +01:00
}
else{
2016-05-14 13:51:18 +02:00
if(booklet.currentEntrySet.getPageInIndex()+1 <= booklet.indexPageAmount){
openIndexEntry(booklet, booklet.currentEntrySet.getCurrentEntry(), booklet.currentEntrySet.getPageInIndex()+1, !(booklet.currentEntrySet.getCurrentEntry() instanceof BookletEntryAllSearch));
}
}
}
}
/**
2015-12-01 19:48:09 +01:00
* Called when the "previous page"-button is pressed
*/
2015-12-01 19:48:09 +01:00
public static void handlePreviousPage(GuiBooklet booklet){
2016-05-14 13:51:18 +02:00
if(booklet.currentEntrySet.getCurrentEntry() != null){
if(booklet.currentEntrySet.getCurrentPage() != null){
BookletPage page = getPrevPage(booklet.currentEntrySet.getCurrentChapter(), booklet.currentEntrySet.getCurrentPage());
2015-12-01 19:48:09 +01:00
if(page != null){
2016-05-14 13:51:18 +02:00
booklet.currentEntrySet.setPage(page);
2015-12-01 19:48:09 +01:00
}
2016-05-14 13:51:18 +02:00
booklet.buttonForward.visible = getNextPage(booklet.currentEntrySet.getCurrentChapter(), booklet.currentEntrySet.getCurrentPage()) != null;
booklet.buttonBackward.visible = getPrevPage(booklet.currentEntrySet.getCurrentChapter(), booklet.currentEntrySet.getCurrentPage()) != null;
2015-12-01 19:48:09 +01:00
}
else{
2016-05-14 13:51:18 +02:00
if(booklet.currentEntrySet.getPageInIndex()-1 > 0){
openIndexEntry(booklet, booklet.currentEntrySet.getCurrentEntry(), booklet.currentEntrySet.getPageInIndex()-1, !(booklet.currentEntrySet.getCurrentEntry() instanceof BookletEntryAllSearch));
}
}
}
2015-12-01 19:48:09 +01:00
}
2015-12-01 19:48:09 +01:00
public static BookletPage getFirstPageForStack(ItemStack stack){
ArrayList<BookletPage> pages = getPagesForStack(stack);
return pages.isEmpty() ? null : pages.get(0);
}
2015-12-01 19:48:09 +01:00
public static ArrayList<BookletPage> getPagesForStack(ItemStack stack){
ArrayList<BookletPage> possiblePages = new ArrayList<BookletPage>();
2016-01-05 14:57:50 +01:00
for(BookletPage page : ActuallyAdditionsAPI.bookletPagesWithItemStackData){
if(ItemUtil.contains(page.getItemStacksForPage(), stack, page.arePageStacksWildcard)){
2015-12-01 19:48:09 +01:00
possiblePages.add(page);
}
}
2015-12-01 19:48:09 +01:00
return possiblePages;
}
}