From e0cf1803580642340b5ed1f31b39795d1933c195 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sat, 14 May 2016 13:51:18 +0200 Subject: [PATCH] Lotsa API restructuring --- .../api/ActuallyAdditionsAPI.java | 27 ++++-- .../api/internal/IBookletGui.java | 2 +- .../api/internal/IEntrySet.java | 31 +++++++ .../api/internal/IMethodHandler.java | 24 +++++ .../recipe/{coffee => }/CoffeeIngredient.java | 5 +- ...eRecipe.java => LensConversionRecipe.java} | 6 +- .../mod/ActuallyAdditions.java | 5 +- .../mod/booklet/BookletUtils.java | 90 +++++++++---------- .../mod/booklet/GuiBooklet.java | 27 +++--- .../mod/booklet/button/BookmarkButton.java | 6 +- .../booklet/chapter/BookletChapterCoffee.java | 2 +- .../booklet/entry}/EntrySet.java | 48 +++++++++- .../mod/booklet/page/PageCoffeeRecipe.java | 8 +- .../mod/booklet/page/PageCrafting.java | 2 +- .../mod/booklet/page/PageCrusherRecipe.java | 2 +- .../mod/booklet/page/PageFurnace.java | 2 +- .../mod/booklet/page/PagePicture.java | 2 +- .../mod/booklet/page/PageReconstructor.java | 16 ++-- .../mod/booklet/page/PageTextOnly.java | 2 +- .../mod/items/ItemBooklet.java | 2 +- .../mod/items/ItemCoffee.java | 11 ++- .../{LensNone.java => LensConversion.java} | 12 +-- .../mod/items/lens/LensRecipeHandler.java | 70 +++++++-------- .../mod/items/lens/Lenses.java | 2 +- .../mod/jei/JEIActuallyAdditionsPlugin.java | 2 +- .../coffee/CoffeeMachineRecipeHandler.java | 2 +- .../coffee/CoffeeMachineRecipeWrapper.java | 6 +- .../ReconstructorRecipeHandler.java | 10 +-- .../ReconstructorRecipeWrapper.java | 6 +- .../misc/MethodHandler.java} | 54 ++++++----- .../mod/nei/NEIReconstructorRecipe.java | 6 +- .../mod/tile/TileEntityCoffeeMachine.java | 2 +- .../mod/util/RecipeUtil.java | 6 +- .../util/playerdata/PersistentClientData.java | 2 +- 34 files changed, 305 insertions(+), 195 deletions(-) create mode 100644 src/main/java/de/ellpeck/actuallyadditions/api/internal/IEntrySet.java create mode 100644 src/main/java/de/ellpeck/actuallyadditions/api/internal/IMethodHandler.java rename src/main/java/de/ellpeck/actuallyadditions/api/recipe/{coffee => }/CoffeeIngredient.java (83%) rename src/main/java/de/ellpeck/actuallyadditions/api/recipe/{LensNoneRecipe.java => LensConversionRecipe.java} (93%) rename src/main/java/de/ellpeck/actuallyadditions/{api/internal => mod/booklet/entry}/EntrySet.java (74%) rename src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/{LensNone.java => LensConversion.java} (89%) rename src/main/java/de/ellpeck/actuallyadditions/{api/recipe/coffee/CoffeeBrewing.java => mod/misc/MethodHandler.java} (65%) diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java b/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java index 7df7fbf6f..7846b0a38 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java @@ -12,8 +12,9 @@ package de.ellpeck.actuallyadditions.api; import de.ellpeck.actuallyadditions.api.booklet.BookletPage; import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry; +import de.ellpeck.actuallyadditions.api.internal.IMethodHandler; import de.ellpeck.actuallyadditions.api.recipe.*; -import de.ellpeck.actuallyadditions.api.recipe.coffee.CoffeeIngredient; +import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; @@ -29,17 +30,25 @@ public class ActuallyAdditionsAPI{ public static final String API_ID = MOD_ID+"api"; public static final String API_VERSION = "11"; + /** + * Use this to handle things that aren't based in the API itself + * DO NOT CHANGE/OVERRIDE THIS!! + * This is getting initialized in Actually Additions' PreInit phase + */ + public static IMethodHandler methodHandler; + public static List crusherRecipes = new ArrayList(); public static List ballOfFurReturnItems = new ArrayList(); public static List treasureChestLoot = new ArrayList(); - public static List reconstructorLensNoneRecipes = new ArrayList(); + public static List reconstructorLensConversionRecipes = new ArrayList(); public static Map reconstructorLensColorChangers = new HashMap(); public static List coffeeMachineIngredients = new ArrayList(); public static List bookletEntries = new ArrayList(); public static List bookletPagesWithItemStackData = new ArrayList(); - //These are getting initlized in Actually Additions' PreInit phase + //These are getting initialized in Actually Additions' PreInit phase + //DO NOT CHANGE/OVERRIDE THESE!! public static IBookletEntry entryGettingStarted; public static IBookletEntry entryFunctionalNonRF; public static IBookletEntry entryFunctionalRF; @@ -139,26 +148,26 @@ public class ActuallyAdditionsAPI{ } /** - * Adds a recipe to the Atomic Reconstructor conversion without lens + * Adds a recipe to the Atomic Reconstructor conversion lenses * StackSizes can only be 1 and greater ones will be ignored * * @param input The input as an ItemStack * @param output The output as an ItemStack * @param energyUse The amount of RF used per conversion */ - public static void addReconstructorLensNoneRecipe(ItemStack input, ItemStack output, int energyUse){ - reconstructorLensNoneRecipes.add(new LensNoneRecipe(input, output, energyUse)); + public static void addReconstructorLensConversionRecipe(ItemStack input, ItemStack output, int energyUse){ + reconstructorLensConversionRecipes.add(new LensConversionRecipe(input, output, energyUse)); } /** - * Adds a recipe to the Atomic Reconstructor conversion without lens + * Adds a recipe to the Atomic Reconstructor conversion lenses * * @param input The input's OreDictionary name * @param output The output's OreDictionary name * @param energyUse The amount of RF used per conversion */ - public static void addReconstructorLensNoneRecipe(String input, String output, int energyUse){ - reconstructorLensNoneRecipes.add(new LensNoneRecipe(input, output, energyUse)); + public static void addReconstructorLensConversionRecipe(String input, String output, int energyUse){ + reconstructorLensConversionRecipes.add(new LensConversionRecipe(input, output, energyUse)); } /** diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/internal/IBookletGui.java b/src/main/java/de/ellpeck/actuallyadditions/api/internal/IBookletGui.java index 96d279db3..65f381e6d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/internal/IBookletGui.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/internal/IBookletGui.java @@ -43,5 +43,5 @@ public interface IBookletGui{ void drawRect(int startX, int startY, int u, int v, int xSize, int ySize); - EntrySet getCurrentEntrySet(); + IEntrySet getCurrentEntrySet(); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/internal/IEntrySet.java b/src/main/java/de/ellpeck/actuallyadditions/api/internal/IEntrySet.java new file mode 100644 index 000000000..90e493e9f --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/api/internal/IEntrySet.java @@ -0,0 +1,31 @@ +package de.ellpeck.actuallyadditions.api.internal; + +import de.ellpeck.actuallyadditions.api.booklet.BookletPage; +import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter; +import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry; +import net.minecraft.nbt.NBTTagCompound; + +public interface IEntrySet{ + + void setEntry(BookletPage page, IBookletChapter chapter, IBookletEntry entry, int pageInIndex); + + void removeEntry(); + + NBTTagCompound writeToNBT(); + + BookletPage getCurrentPage(); + + IBookletEntry getCurrentEntry(); + + IBookletChapter getCurrentChapter(); + + int getPageInIndex(); + + void setPage(BookletPage page); + + void setEntry(IBookletEntry entry); + + void setChapter(IBookletChapter chapter); + + void setPageInIndex(int page); +} diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/internal/IMethodHandler.java b/src/main/java/de/ellpeck/actuallyadditions/api/internal/IMethodHandler.java new file mode 100644 index 000000000..cd8f8116c --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/api/internal/IMethodHandler.java @@ -0,0 +1,24 @@ +package de.ellpeck.actuallyadditions.api.internal; + +import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.PotionEffect; + +/** + * This is the internal method handler. + * Use ActuallyAdditionsAPI.methodHandler for calling + * This is not supposed to be implemented. + */ +public interface IMethodHandler{ + + boolean addEffectToStack(ItemStack stack, CoffeeIngredient ingredient); + + PotionEffect getSameEffectFromStack(ItemStack stack, PotionEffect effect); + + void addEffectProperties(ItemStack stack, PotionEffect effect, boolean addDur, boolean addAmp); + + void addEffectToStack(ItemStack stack, PotionEffect effect); + + PotionEffect[] getEffectsFromStack(ItemStack stack); +} diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/coffee/CoffeeIngredient.java b/src/main/java/de/ellpeck/actuallyadditions/api/recipe/CoffeeIngredient.java similarity index 83% rename from src/main/java/de/ellpeck/actuallyadditions/api/recipe/coffee/CoffeeIngredient.java rename to src/main/java/de/ellpeck/actuallyadditions/api/recipe/CoffeeIngredient.java index 53f67a3b4..d45d66120 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/coffee/CoffeeIngredient.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/recipe/CoffeeIngredient.java @@ -8,8 +8,9 @@ * © 2016 Ellpeck */ -package de.ellpeck.actuallyadditions.api.recipe.coffee; +package de.ellpeck.actuallyadditions.api.recipe; +import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import net.minecraft.item.ItemStack; import net.minecraft.potion.PotionEffect; @@ -30,7 +31,7 @@ public class CoffeeIngredient{ } public boolean effect(ItemStack stack){ - return CoffeeBrewing.addEffectToStack(stack, this); + return ActuallyAdditionsAPI.methodHandler.addEffectToStack(stack, this); } public String getExtraText(){ diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/LensNoneRecipe.java b/src/main/java/de/ellpeck/actuallyadditions/api/recipe/LensConversionRecipe.java similarity index 93% rename from src/main/java/de/ellpeck/actuallyadditions/api/recipe/LensNoneRecipe.java rename to src/main/java/de/ellpeck/actuallyadditions/api/recipe/LensConversionRecipe.java index 45bb5e923..739c27e03 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/LensNoneRecipe.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/recipe/LensConversionRecipe.java @@ -17,7 +17,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -public class LensNoneRecipe{ +public class LensConversionRecipe{ public int energyUse; private String input; @@ -25,13 +25,13 @@ public class LensNoneRecipe{ private ItemStack inputStack; private ItemStack outputStack; - public LensNoneRecipe(ItemStack input, ItemStack output, int energyUse){ + public LensConversionRecipe(ItemStack input, ItemStack output, int energyUse){ this.inputStack = input; this.outputStack = output; this.energyUse = energyUse; } - public LensNoneRecipe(String input, String output, int energyUse){ + public LensConversionRecipe(String input, String output, int energyUse){ this.input = input; this.output = output; this.energyUse = energyUse; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyAdditions.java b/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyAdditions.java index 1cfe56b2e..0dbc8f2a6 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyAdditions.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyAdditions.java @@ -10,6 +10,7 @@ package de.ellpeck.actuallyadditions.mod; +import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.mod.achievement.InitAchievements; import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; import de.ellpeck.actuallyadditions.mod.booklet.InitBooklet; @@ -68,6 +69,9 @@ public class ActuallyAdditions{ public void preInit(FMLPreInitializationEvent event){ ModUtil.LOGGER.info("Starting PreInitialization Phase..."); + InitBooklet.preInit(); + ActuallyAdditionsAPI.methodHandler = new MethodHandler(); + new ConfigurationHandler(event.getSuggestedConfigurationFile()); PacketHandler.init(); InitToolMaterials.init(); @@ -79,7 +83,6 @@ public class ActuallyAdditions{ BannerHelper.init(); SoundHandler.init(); UpdateChecker.init(); - InitBooklet.preInit(); proxy.preInit(event); ModUtil.LOGGER.info("PreInitialization Finished."); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/BookletUtils.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/BookletUtils.java index 64a7d420f..8b0a83554 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/BookletUtils.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/BookletUtils.java @@ -79,7 +79,7 @@ public class BookletUtils{ booklet.drawTexturedModalRect(booklet.guiLeft+booklet.xSize/2-142/2, booklet.guiTop+booklet.ySize, 0, 243, 142, 13); //Draw No Entry title - if(booklet.currentEntrySet.entry == null){ + if(booklet.currentEntrySet.getCurrentEntry() == null){ String strg = TextFormatting.DARK_GREEN+StringUtil.localize("info."+ModUtil.MOD_ID+".booklet.manualName.1"); booklet.getFontRenderer().drawString(strg, booklet.guiLeft+booklet.xSize/2-booklet.getFontRenderer().getStringWidth(strg)/2-3, booklet.guiTop+12, 0); strg = TextFormatting.DARK_GREEN+StringUtil.localize("info."+ModUtil.MOD_ID+".booklet.manualName.2"); @@ -109,7 +109,7 @@ public class BookletUtils{ booklet.getFontRenderer().drawString(strg, booklet.guiLeft+booklet.xSize/2-booklet.getFontRenderer().getStringWidth(strg)/2-3, booklet.guiTop+33, 0); } - String strg = booklet.currentEntrySet.chapter == null ? (booklet.currentEntrySet.entry == null ? StringUtil.localize("itemGroup."+ModUtil.MOD_ID) : booklet.currentEntrySet.entry.getLocalizedName()) : booklet.currentEntrySet.chapter.getLocalizedName(); + 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); } @@ -119,12 +119,12 @@ public class BookletUtils{ * @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){ - if(booklet.currentEntrySet.chapter == null){ + if(booklet.currentEntrySet.getCurrentChapter() == null){ return; } ArrayList infoList = null; - for(BookletPage page : booklet.currentEntrySet.chapter.getPages()){ + for(BookletPage page : booklet.currentEntrySet.getCurrentChapter().getPages()){ if(page != null && page.getItemStacksForPage() != null){ for(ItemStack stack : page.getItemStacksForPage()){ if(stack != null){ @@ -164,15 +164,15 @@ public class BookletUtils{ * -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){ - if(booklet.currentEntrySet.entry != null){ + if(booklet.currentEntrySet.getCurrentEntry() != null){ //Renders Booklet Page Number and Content - if(booklet.currentEntrySet.chapter != null && booklet.currentEntrySet.page != null){ - booklet.drawCenteredString(booklet.getFontRenderer(), booklet.currentEntrySet.page.getID()+"/"+booklet.currentEntrySet.chapter.getPages().length, booklet.guiLeft+booklet.xSize/2, booklet.guiTop+171, StringUtil.DECIMAL_COLOR_WHITE); - booklet.currentEntrySet.page.renderPre(booklet, mouseX, mouseY, ticksElapsed, mousePressed); + 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{ - booklet.drawCenteredString(booklet.getFontRenderer(), booklet.currentEntrySet.pageInIndex+"/"+booklet.indexPageAmount, booklet.guiLeft+booklet.xSize/2, booklet.guiTop+171, StringUtil.DECIMAL_COLOR_WHITE); + 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 @@ -211,8 +211,8 @@ public class BookletUtils{ */ @SuppressWarnings("unchecked") public static void updateSearchBar(GuiBooklet booklet){ - if(booklet.currentEntrySet.entry instanceof BookletEntryAllSearch){ - BookletEntryAllSearch currentEntry = (BookletEntryAllSearch)booklet.currentEntrySet.entry; + if(booklet.currentEntrySet.getCurrentEntry() instanceof BookletEntryAllSearch){ + BookletEntryAllSearch currentEntry = (BookletEntryAllSearch)booklet.currentEntrySet.getCurrentEntry(); if(booklet.searchField.getText() != null && !booklet.searchField.getText().isEmpty()){ currentEntry.chapters.clear(); @@ -226,7 +226,7 @@ public class BookletUtils{ else{ currentEntry.setChapters((ArrayList)currentEntry.allChapters.clone()); } - openIndexEntry(booklet, booklet.currentEntrySet.entry, booklet.currentEntrySet.pageInIndex, false); + openIndexEntry(booklet, booklet.currentEntrySet.getCurrentEntry(), booklet.currentEntrySet.getPageInIndex(), false); } } @@ -255,16 +255,16 @@ public class BookletUtils{ } } - booklet.currentEntrySet.page = null; - booklet.currentEntrySet.chapter = null; + booklet.currentEntrySet.setPage(null); + booklet.currentEntrySet.setChapter(null); - booklet.currentEntrySet.entry = entry; + booklet.currentEntrySet.setEntry(entry); booklet.indexPageAmount = entry == null ? 1 : entry.getChapters().size()/booklet.chapterButtons.length+1; - booklet.currentEntrySet.pageInIndex = entry == null ? 1 : (booklet.indexPageAmount <= page || page <= 0 ? booklet.indexPageAmount : page); + booklet.currentEntrySet.setPageInIndex(entry == null ? 1 : (booklet.indexPageAmount <= page || page <= 0 ? booklet.indexPageAmount : page)); booklet.buttonPreviousScreen.visible = entry != null; - booklet.buttonForward.visible = booklet.currentEntrySet.pageInIndex < booklet.indexPageAmount; - booklet.buttonBackward.visible = booklet.currentEntrySet.pageInIndex > 1; + booklet.buttonForward.visible = booklet.currentEntrySet.getPageInIndex() < booklet.indexPageAmount; + booklet.buttonBackward.visible = booklet.currentEntrySet.getPageInIndex() > 1; for(int i = 0; i < booklet.chapterButtons.length; i++){ IndexButton button = (IndexButton)booklet.chapterButtons[i]; @@ -282,10 +282,10 @@ public class BookletUtils{ } } else{ - boolean entryExists = entry.getChapters().size() > i+(booklet.chapterButtons.length*booklet.currentEntrySet.pageInIndex-booklet.chapterButtons.length); + boolean entryExists = entry.getChapters().size() > i+(booklet.chapterButtons.length*booklet.currentEntrySet.getPageInIndex()-booklet.chapterButtons.length); button.visible = entryExists; if(entryExists){ - IBookletChapter chap = entry.getChapters().get(i+(booklet.chapterButtons.length*booklet.currentEntrySet.pageInIndex-booklet.chapterButtons.length)); + IBookletChapter chap = entry.getChapters().get(i+(booklet.chapterButtons.length*booklet.currentEntrySet.getPageInIndex()-booklet.chapterButtons.length)); button.displayString = chap.getLocalizedNameWithFormatting(); button.chap = chap; } @@ -299,10 +299,10 @@ public class BookletUtils{ public static void handleChapterButtonClick(GuiBooklet booklet, GuiButton button){ int place = Util.arrayContains(booklet.chapterButtons, button); if(place >= 0){ - if(booklet.currentEntrySet.entry != null){ - if(booklet.currentEntrySet.chapter == null){ - if(place < booklet.currentEntrySet.entry.getChapters().size()){ - IBookletChapter chap = booklet.currentEntrySet.entry.getChapters().get(place+(booklet.chapterButtons.length*booklet.currentEntrySet.pageInIndex-booklet.chapterButtons.length)); + 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)); openChapter(booklet, chap, chap.getPages()[0]); } } @@ -320,7 +320,7 @@ public class BookletUtils{ * Can only be done when the chapter is not null and an index entry is opened in the booklet */ public static void openChapter(GuiBooklet booklet, IBookletChapter chapter, BookletPage page){ - if(chapter == null || booklet.currentEntrySet.entry == null){ + if(chapter == null || booklet.currentEntrySet.getCurrentEntry() == null){ return; } @@ -328,11 +328,11 @@ public class BookletUtils{ booklet.searchField.setFocused(false); booklet.searchField.setText(""); - booklet.currentEntrySet.chapter = chapter; - booklet.currentEntrySet.page = page != null && doesChapterHavePage(chapter, page) ? page : chapter.getPages()[0]; + booklet.currentEntrySet.setChapter(chapter); + booklet.currentEntrySet.setPage(page != null && doesChapterHavePage(chapter, page) ? page : chapter.getPages()[0]); - booklet.buttonForward.visible = getNextPage(chapter, booklet.currentEntrySet.page) != null; - booklet.buttonBackward.visible = getPrevPage(chapter, booklet.currentEntrySet.page) != null; + booklet.buttonForward.visible = getNextPage(chapter, booklet.currentEntrySet.getCurrentPage()) != null; + booklet.buttonBackward.visible = getPrevPage(chapter, booklet.currentEntrySet.getCurrentPage()) != null; booklet.buttonPreviousScreen.visible = true; for(GuiButton chapterButton : booklet.chapterButtons){ @@ -384,19 +384,19 @@ public class BookletUtils{ * Called when the "next page"-button is pressed */ public static void handleNextPage(GuiBooklet booklet){ - if(booklet.currentEntrySet.entry != null){ - if(booklet.currentEntrySet.page != null){ - BookletPage page = getNextPage(booklet.currentEntrySet.chapter, booklet.currentEntrySet.page); + if(booklet.currentEntrySet.getCurrentEntry() != null){ + if(booklet.currentEntrySet.getCurrentPage() != null){ + BookletPage page = getNextPage(booklet.currentEntrySet.getCurrentChapter(), booklet.currentEntrySet.getCurrentPage()); if(page != null){ - booklet.currentEntrySet.page = page; + booklet.currentEntrySet.setPage(page); } - booklet.buttonForward.visible = getNextPage(booklet.currentEntrySet.chapter, booklet.currentEntrySet.page) != null; - booklet.buttonBackward.visible = getPrevPage(booklet.currentEntrySet.chapter, booklet.currentEntrySet.page) != null; + booklet.buttonForward.visible = getNextPage(booklet.currentEntrySet.getCurrentChapter(), booklet.currentEntrySet.getCurrentPage()) != null; + booklet.buttonBackward.visible = getPrevPage(booklet.currentEntrySet.getCurrentChapter(), booklet.currentEntrySet.getCurrentPage()) != null; } else{ - if(booklet.currentEntrySet.pageInIndex+1 <= booklet.indexPageAmount){ - openIndexEntry(booklet, booklet.currentEntrySet.entry, booklet.currentEntrySet.pageInIndex+1, !(booklet.currentEntrySet.entry instanceof BookletEntryAllSearch)); + if(booklet.currentEntrySet.getPageInIndex()+1 <= booklet.indexPageAmount){ + openIndexEntry(booklet, booklet.currentEntrySet.getCurrentEntry(), booklet.currentEntrySet.getPageInIndex()+1, !(booklet.currentEntrySet.getCurrentEntry() instanceof BookletEntryAllSearch)); } } } @@ -406,19 +406,19 @@ public class BookletUtils{ * Called when the "previous page"-button is pressed */ public static void handlePreviousPage(GuiBooklet booklet){ - if(booklet.currentEntrySet.entry != null){ - if(booklet.currentEntrySet.page != null){ - BookletPage page = getPrevPage(booklet.currentEntrySet.chapter, booklet.currentEntrySet.page); + if(booklet.currentEntrySet.getCurrentEntry() != null){ + if(booklet.currentEntrySet.getCurrentPage() != null){ + BookletPage page = getPrevPage(booklet.currentEntrySet.getCurrentChapter(), booklet.currentEntrySet.getCurrentPage()); if(page != null){ - booklet.currentEntrySet.page = page; + booklet.currentEntrySet.setPage(page); } - booklet.buttonForward.visible = getNextPage(booklet.currentEntrySet.chapter, booklet.currentEntrySet.page) != null; - booklet.buttonBackward.visible = getPrevPage(booklet.currentEntrySet.chapter, booklet.currentEntrySet.page) != null; + booklet.buttonForward.visible = getNextPage(booklet.currentEntrySet.getCurrentChapter(), booklet.currentEntrySet.getCurrentPage()) != null; + booklet.buttonBackward.visible = getPrevPage(booklet.currentEntrySet.getCurrentChapter(), booklet.currentEntrySet.getCurrentPage()) != null; } else{ - if(booklet.currentEntrySet.pageInIndex-1 > 0){ - openIndexEntry(booklet, booklet.currentEntrySet.entry, booklet.currentEntrySet.pageInIndex-1, !(booklet.currentEntrySet.entry instanceof BookletEntryAllSearch)); + if(booklet.currentEntrySet.getPageInIndex()-1 > 0){ + openIndexEntry(booklet, booklet.currentEntrySet.getCurrentEntry(), booklet.currentEntrySet.getPageInIndex()-1, !(booklet.currentEntrySet.getCurrentEntry() instanceof BookletEntryAllSearch)); } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/GuiBooklet.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/GuiBooklet.java index 284c0d0b7..d5c538424 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/GuiBooklet.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/GuiBooklet.java @@ -12,12 +12,13 @@ package de.ellpeck.actuallyadditions.mod.booklet; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.booklet.BookletPage; -import de.ellpeck.actuallyadditions.api.internal.EntrySet; +import de.ellpeck.actuallyadditions.api.internal.IEntrySet; import de.ellpeck.actuallyadditions.api.internal.IBookletGui; 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.booklet.entry.EntrySet; import de.ellpeck.actuallyadditions.mod.config.GuiConfiguration; import de.ellpeck.actuallyadditions.mod.items.ItemBooklet; import de.ellpeck.actuallyadditions.mod.misc.SoundHandler; @@ -64,7 +65,7 @@ public class GuiBooklet extends GuiScreen implements IBookletGui{ public int ySize; public int guiLeft; public int guiTop; - public EntrySet currentEntrySet = new EntrySet(null); + public IEntrySet currentEntrySet = new EntrySet(null); public int indexPageAmount; public GuiButton buttonForward; public GuiButton buttonBackward; @@ -124,7 +125,7 @@ public class GuiBooklet extends GuiScreen implements IBookletGui{ this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize); //Draws the search bar - if(this.currentEntrySet.entry instanceof BookletEntryAllSearch && this.currentEntrySet.chapter == null){ + if(this.currentEntrySet.getCurrentEntry() instanceof BookletEntryAllSearch && this.currentEntrySet.getCurrentChapter() == null){ this.mc.getTextureManager().bindTexture(resLoc); this.drawTexturedModalRect(this.guiLeft+146, this.guiTop+160, 146, 80, 70, 14); } @@ -145,8 +146,8 @@ public class GuiBooklet extends GuiScreen implements IBookletGui{ this.searchField.drawTextBox(); //Renders the current page's content - if(this.currentEntrySet.entry != null && this.currentEntrySet.chapter != null && this.currentEntrySet.page != null){ - this.currentEntrySet.page.render(this, x, y, this.ticksElapsed, this.mousePressed); + if(this.currentEntrySet.getCurrentEntry() != null && this.currentEntrySet.getCurrentChapter() != null && this.currentEntrySet.getCurrentPage() != null){ + this.currentEntrySet.getCurrentPage().render(this, x, y, this.ticksElapsed, this.mousePressed); } //Draws hovering texts for buttons @@ -204,13 +205,13 @@ public class GuiBooklet extends GuiScreen implements IBookletGui{ protected void mouseClicked(int par1, int par2, int par3) throws IOException{ this.searchField.mouseClicked(par1, par2, par3); //Left mouse button - if(par3 == 0 && this.currentEntrySet.chapter != null){ + if(par3 == 0 && this.currentEntrySet.getCurrentChapter() != null){ this.mousePressed = true; } //Right mouse button else if(par3 == 1){ - if(this.currentEntrySet.chapter != null){ - BookletUtils.openIndexEntry(this, this.currentEntrySet.entry, this.currentEntrySet.pageInIndex, true); + if(this.currentEntrySet.getCurrentChapter() != null){ + BookletUtils.openIndexEntry(this, this.currentEntrySet.getCurrentEntry(), this.currentEntrySet.getPageInIndex(), true); } else{ BookletUtils.openIndexEntry(this, null, 1, true); @@ -259,8 +260,8 @@ public class GuiBooklet extends GuiScreen implements IBookletGui{ } //Handles gonig from page to chapter or from chapter to index else if(button == this.buttonPreviousScreen){ - if(this.currentEntrySet.chapter != null){ - BookletUtils.openIndexEntry(this, this.currentEntrySet.entry, this.currentEntrySet.pageInIndex, true); + if(this.currentEntrySet.getCurrentChapter() != null){ + BookletUtils.openIndexEntry(this, this.currentEntrySet.getCurrentEntry(), this.currentEntrySet.getPageInIndex(), true); } else{ BookletUtils.openIndexEntry(this, null, 1, true); @@ -389,8 +390,8 @@ public class GuiBooklet extends GuiScreen implements IBookletGui{ super.updateScreen(); this.searchField.updateCursorCounter(); - if(this.currentEntrySet.entry != null && this.currentEntrySet.chapter != null && this.currentEntrySet.page != null){ - this.currentEntrySet.page.updateScreen(this.ticksElapsed); + if(this.currentEntrySet.getCurrentEntry() != null && this.currentEntrySet.getCurrentChapter() != null && this.currentEntrySet.getCurrentPage() != null){ + this.currentEntrySet.getCurrentPage().updateScreen(this.ticksElapsed); } boolean buttonThere = UpdateChecker.needsUpdateNotify; @@ -477,7 +478,7 @@ public class GuiBooklet extends GuiScreen implements IBookletGui{ } @Override - public EntrySet getCurrentEntrySet(){ + public IEntrySet getCurrentEntrySet(){ return this.currentEntrySet; } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/button/BookmarkButton.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/button/BookmarkButton.java index 2816f8d50..cf4e0f776 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/button/BookmarkButton.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/button/BookmarkButton.java @@ -10,7 +10,7 @@ package de.ellpeck.actuallyadditions.mod.booklet.button; -import de.ellpeck.actuallyadditions.api.internal.EntrySet; +import de.ellpeck.actuallyadditions.mod.booklet.entry.EntrySet; import de.ellpeck.actuallyadditions.mod.booklet.BookletUtils; import de.ellpeck.actuallyadditions.mod.booklet.GuiBooklet; import de.ellpeck.actuallyadditions.mod.items.InitItems; @@ -46,8 +46,8 @@ public class BookmarkButton extends GuiButton{ } } else{ - if(this.booklet.currentEntrySet.entry != null){ - this.assignedEntry.setEntry(this.booklet.currentEntrySet.page, this.booklet.currentEntrySet.chapter, this.booklet.currentEntrySet.entry, this.booklet.currentEntrySet.pageInIndex); + if(this.booklet.currentEntrySet.getCurrentEntry() != null){ + this.assignedEntry.setEntry(this.booklet.currentEntrySet.getCurrentPage(), this.booklet.currentEntrySet.getCurrentChapter(), this.booklet.currentEntrySet.getCurrentEntry(), this.booklet.currentEntrySet.getPageInIndex()); } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/chapter/BookletChapterCoffee.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/chapter/BookletChapterCoffee.java index 9a04df28a..c73d63726 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/chapter/BookletChapterCoffee.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/chapter/BookletChapterCoffee.java @@ -13,7 +13,7 @@ package de.ellpeck.actuallyadditions.mod.booklet.chapter; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.booklet.BookletPage; import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry; -import de.ellpeck.actuallyadditions.api.recipe.coffee.CoffeeIngredient; +import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient; import de.ellpeck.actuallyadditions.mod.booklet.page.BookletPageAA; import de.ellpeck.actuallyadditions.mod.booklet.page.PageCoffeeRecipe; import de.ellpeck.actuallyadditions.mod.items.ItemCoffee; diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/internal/EntrySet.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/entry/EntrySet.java similarity index 74% rename from src/main/java/de/ellpeck/actuallyadditions/api/internal/EntrySet.java rename to src/main/java/de/ellpeck/actuallyadditions/mod/booklet/entry/EntrySet.java index 993483334..37923e087 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/internal/EntrySet.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/entry/EntrySet.java @@ -8,15 +8,16 @@ * © 2016 Ellpeck */ -package de.ellpeck.actuallyadditions.api.internal; +package de.ellpeck.actuallyadditions.mod.booklet.entry; 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.api.internal.IEntrySet; import net.minecraft.nbt.NBTTagCompound; -public class EntrySet{ +public class EntrySet implements IEntrySet{ public BookletPage page; public IBookletChapter chapter; @@ -49,6 +50,7 @@ public class EntrySet{ return new EntrySet(null); } + @Override public void setEntry(BookletPage page, IBookletChapter chapter, IBookletEntry entry, int pageInIndex){ this.page = page; this.chapter = chapter; @@ -56,10 +58,12 @@ public class EntrySet{ this.pageInIndex = pageInIndex; } + @Override public void removeEntry(){ this.setEntry(null, null, null, 1); } + @Override public NBTTagCompound writeToNBT(){ NBTTagCompound compound = new NBTTagCompound(); compound.setInteger("Entry", this.entry == null ? -1 : ActuallyAdditionsAPI.bookletEntries.indexOf(this.entry)); @@ -68,4 +72,44 @@ public class EntrySet{ compound.setInteger("PageInIndex", this.pageInIndex); return compound; } + + @Override + public BookletPage getCurrentPage(){ + return this.page; + } + + @Override + public IBookletEntry getCurrentEntry(){ + return this.entry; + } + + @Override + public IBookletChapter getCurrentChapter(){ + return this.chapter; + } + + @Override + public int getPageInIndex(){ + return this.pageInIndex; + } + + @Override + public void setPage(BookletPage page){ + this.page = page; + } + + @Override + public void setEntry(IBookletEntry entry){ + this.entry = entry; + } + + @Override + public void setChapter(IBookletChapter chapter){ + this.chapter = chapter; + } + + @Override + public void setPageInIndex(int page){ + this.pageInIndex = page; + } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCoffeeRecipe.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCoffeeRecipe.java index a1c4fed7f..9f5be5112 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCoffeeRecipe.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCoffeeRecipe.java @@ -10,9 +10,9 @@ package de.ellpeck.actuallyadditions.mod.booklet.page; +import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.internal.IBookletGui; -import de.ellpeck.actuallyadditions.api.recipe.coffee.CoffeeBrewing; -import de.ellpeck.actuallyadditions.api.recipe.coffee.CoffeeIngredient; +import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient; import de.ellpeck.actuallyadditions.mod.booklet.GuiBooklet; import de.ellpeck.actuallyadditions.mod.items.InitItems; import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; @@ -48,7 +48,7 @@ public class PageCoffeeRecipe extends BookletPageAA{ String strg = "Coffee Machine Recipe"; Minecraft.getMinecraft().fontRendererObj.drawString(strg, gui.getGuiLeft()+gui.getXSize()/2-Minecraft.getMinecraft().fontRendererObj.getStringWidth(strg)/2, gui.getGuiTop()+10, 0); - String text = gui.getCurrentEntrySet().page.getText(); + String text = gui.getCurrentEntrySet().getCurrentPage().getText(); if(text != null && !text.isEmpty()){ StringUtil.drawSplitString(Minecraft.getMinecraft().fontRendererObj, text, gui.getGuiLeft()+14, gui.getGuiTop()+100, 115, 0, false); } @@ -76,7 +76,7 @@ public class PageCoffeeRecipe extends BookletPageAA{ break; case 2: stack = new ItemStack(InitItems.itemCoffee); - CoffeeBrewing.addEffectToStack(stack, this.ingredient); + ActuallyAdditionsAPI.methodHandler.addEffectToStack(stack, this.ingredient); coordsOffsetX = 39; coordsOffsetY = 39; break; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCrafting.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCrafting.java index 0ccfddebc..7301019e1 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCrafting.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCrafting.java @@ -71,7 +71,7 @@ public class PageCrafting extends BookletPageAA{ Minecraft.getMinecraft().fontRendererObj.drawString(strg, gui.getGuiLeft()+gui.getXSize()/2-Minecraft.getMinecraft().fontRendererObj.getStringWidth(strg)/2, gui.getGuiTop()+10, 0); } - String text = gui.getCurrentEntrySet().page.getText(); + String text = gui.getCurrentEntrySet().getCurrentPage().getText(); if(text != null && !text.isEmpty()){ StringUtil.drawSplitString(Minecraft.getMinecraft().fontRendererObj, text, gui.getGuiLeft()+14, gui.getGuiTop()+90, 115, 0, false); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCrusherRecipe.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCrusherRecipe.java index 488447406..d5073a86a 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCrusherRecipe.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCrusherRecipe.java @@ -60,7 +60,7 @@ public class PageCrusherRecipe extends BookletPageAA{ Minecraft.getMinecraft().fontRendererObj.drawString(strg, gui.getGuiLeft()+gui.getXSize()/2-Minecraft.getMinecraft().fontRendererObj.getStringWidth(strg)/2, gui.getGuiTop()+10, 0); } - String text = gui.getCurrentEntrySet().page.getText(); + String text = gui.getCurrentEntrySet().getCurrentPage().getText(); if(text != null && !text.isEmpty()){ StringUtil.drawSplitString(Minecraft.getMinecraft().fontRendererObj, text, gui.getGuiLeft()+14, gui.getGuiTop()+100, 115, 0, false); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageFurnace.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageFurnace.java index bb52864c0..c35e00c80 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageFurnace.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageFurnace.java @@ -64,7 +64,7 @@ public class PageFurnace extends BookletPageAA{ Minecraft.getMinecraft().fontRendererObj.drawString(strg, gui.getGuiLeft()+gui.getXSize()/2-Minecraft.getMinecraft().fontRendererObj.getStringWidth(strg)/2, gui.getGuiTop()+10, 0); } - String text = gui.getCurrentEntrySet().page.getText(); + String text = gui.getCurrentEntrySet().getCurrentPage().getText(); if(text != null && !text.isEmpty()){ StringUtil.drawSplitString(Minecraft.getMinecraft().fontRendererObj, text, gui.getGuiLeft()+14, gui.getGuiTop()+100, 115, 0, false); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PagePicture.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PagePicture.java index 5263523b2..a70555d77 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PagePicture.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PagePicture.java @@ -35,7 +35,7 @@ public class PagePicture extends PageTextOnly{ Minecraft.getMinecraft().getTextureManager().bindTexture(this.resLoc); gui.drawRect(gui.getGuiLeft(), gui.getGuiTop(), 0, 0, gui.getXSize(), gui.getYSize()); - String text = gui.getCurrentEntrySet().page.getText(); + String text = gui.getCurrentEntrySet().getCurrentPage().getText(); if(text != null && !text.isEmpty()){ StringUtil.drawSplitString(Minecraft.getMinecraft().fontRendererObj, text, gui.getGuiLeft()+14, gui.getGuiTop()+this.textStartY, 115, 0, false); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageReconstructor.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageReconstructor.java index 66ec0bb2a..4fca61c9f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageReconstructor.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageReconstructor.java @@ -11,7 +11,7 @@ package de.ellpeck.actuallyadditions.mod.booklet.page; import de.ellpeck.actuallyadditions.api.internal.IBookletGui; -import de.ellpeck.actuallyadditions.api.recipe.LensNoneRecipe; +import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe; import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; import de.ellpeck.actuallyadditions.mod.booklet.GuiBooklet; import de.ellpeck.actuallyadditions.mod.proxy.ClientProxy; @@ -30,14 +30,14 @@ import java.util.List; public class PageReconstructor extends BookletPageAA{ - private LensNoneRecipe[] recipes; + private LensConversionRecipe[] recipes; private int recipePos; - public PageReconstructor(int id, ArrayList recipes){ - this(id, recipes.toArray(new LensNoneRecipe[recipes.size()])); + public PageReconstructor(int id, ArrayList recipes){ + this(id, recipes.toArray(new LensConversionRecipe[recipes.size()])); } - public PageReconstructor(int id, LensNoneRecipe... recipes){ + public PageReconstructor(int id, LensConversionRecipe... recipes){ super(id); this.recipes = recipes; this.addToPagesWithItemStackData(); @@ -56,7 +56,7 @@ public class PageReconstructor extends BookletPageAA{ @Override @SideOnly(Side.CLIENT) public void render(IBookletGui gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){ - LensNoneRecipe recipe = this.recipes[this.recipePos]; + LensConversionRecipe recipe = this.recipes[this.recipePos]; if(recipe == null){ StringUtil.drawSplitString(Minecraft.getMinecraft().fontRendererObj, TextFormatting.DARK_RED+StringUtil.localize("booklet."+ModUtil.MOD_ID+".recipeDisabled"), gui.getGuiLeft()+14, gui.getGuiTop()+15, 115, 0, false); } @@ -65,7 +65,7 @@ public class PageReconstructor extends BookletPageAA{ Minecraft.getMinecraft().fontRendererObj.drawString(strg, gui.getGuiLeft()+gui.getXSize()/2-Minecraft.getMinecraft().fontRendererObj.getStringWidth(strg)/2, gui.getGuiTop()+10, 0); } - String text = gui.getCurrentEntrySet().page.getText(); + String text = gui.getCurrentEntrySet().getCurrentPage().getText(); if(text != null && !text.isEmpty()){ StringUtil.drawSplitString(Minecraft.getMinecraft().fontRendererObj, text, gui.getGuiLeft()+14, gui.getGuiTop()+100, 115, 0, false); } @@ -116,7 +116,7 @@ public class PageReconstructor extends BookletPageAA{ public ItemStack[] getItemStacksForPage(){ if(this.recipes != null){ ArrayList stacks = new ArrayList(); - for(LensNoneRecipe recipe : this.recipes){ + for(LensConversionRecipe recipe : this.recipes){ if(recipe != null){ stacks.addAll(recipe.getOutputs()); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageTextOnly.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageTextOnly.java index 8ebdfa28c..999eb571d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageTextOnly.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageTextOnly.java @@ -34,7 +34,7 @@ public class PageTextOnly extends BookletPageAA{ @Override @SideOnly(Side.CLIENT) public void renderPre(IBookletGui gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){ - String text = gui.getCurrentEntrySet().page.getText(); + String text = gui.getCurrentEntrySet().getCurrentPage().getText(); if(text != null && !text.isEmpty()){ StringUtil.drawSplitString(Minecraft.getMinecraft().fontRendererObj, text, gui.getGuiLeft()+14, gui.getGuiTop()+9, 115, 0, false); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBooklet.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBooklet.java index 5ec32cac2..85380abdd 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBooklet.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBooklet.java @@ -12,7 +12,7 @@ package de.ellpeck.actuallyadditions.mod.items; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.booklet.BookletPage; -import de.ellpeck.actuallyadditions.api.internal.EntrySet; +import de.ellpeck.actuallyadditions.mod.booklet.entry.EntrySet; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.achievement.TheAchievements; import de.ellpeck.actuallyadditions.mod.blocks.IHudDisplay; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCoffee.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCoffee.java index a4593dbb0..7fb0cabc8 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCoffee.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCoffee.java @@ -11,8 +11,7 @@ package de.ellpeck.actuallyadditions.mod.items; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; -import de.ellpeck.actuallyadditions.api.recipe.coffee.CoffeeBrewing; -import de.ellpeck.actuallyadditions.api.recipe.coffee.CoffeeIngredient; +import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient; import de.ellpeck.actuallyadditions.mod.items.base.ItemFoodBase; import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; import de.ellpeck.actuallyadditions.mod.util.ItemUtil; @@ -74,7 +73,7 @@ public class ItemCoffee extends ItemFoodBase{ } public static void applyPotionEffectsFromStack(ItemStack stack, EntityLivingBase player){ - PotionEffect[] effects = CoffeeBrewing.getEffectsFromStack(stack); + PotionEffect[] effects = ActuallyAdditionsAPI.methodHandler.getEffectsFromStack(stack); if(effects != null && effects.length > 0){ for(PotionEffect effect : effects){ player.addPotionEffect(new PotionEffect(effect.getPotion(), effect.getDuration()*20, effect.getAmplifier())); @@ -114,7 +113,7 @@ public class ItemCoffee extends ItemFoodBase{ @SuppressWarnings("unchecked") @Override public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool){ - PotionEffect[] effects = CoffeeBrewing.getEffectsFromStack(stack); + PotionEffect[] effects = ActuallyAdditionsAPI.methodHandler.getEffectsFromStack(stack); if(effects != null){ for(PotionEffect effect : effects){ list.add(StringUtil.localize(effect.getEffectName())+" "+(effect.getAmplifier()+1)+", "+StringUtils.ticksToElapsedTime(effect.getDuration()*20)); @@ -138,7 +137,7 @@ public class ItemCoffee extends ItemFoodBase{ @Override public boolean effect(ItemStack stack){ - PotionEffect[] effects = CoffeeBrewing.getEffectsFromStack(stack); + PotionEffect[] effects = ActuallyAdditionsAPI.methodHandler.getEffectsFromStack(stack); ArrayList effectsNew = new ArrayList(); if(effects != null && effects.length > 0){ for(PotionEffect effect : effects){ @@ -149,7 +148,7 @@ public class ItemCoffee extends ItemFoodBase{ stack.setTagCompound(new NBTTagCompound()); if(effectsNew.size() > 0){ this.effects = effectsNew.toArray(new PotionEffect[effectsNew.size()]); - CoffeeBrewing.addEffectToStack(stack, this); + ActuallyAdditionsAPI.methodHandler.addEffectToStack(stack, this); } } this.effects = null; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensNone.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensConversion.java similarity index 89% rename from src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensNone.java rename to src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensConversion.java index f3a9e5bd9..1902ab974 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensNone.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensConversion.java @@ -13,7 +13,7 @@ package de.ellpeck.actuallyadditions.mod.items.lens; import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor; import de.ellpeck.actuallyadditions.api.lens.Lens; -import de.ellpeck.actuallyadditions.api.recipe.LensNoneRecipe; +import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe; import de.ellpeck.actuallyadditions.mod.config.ConfigValues; import de.ellpeck.actuallyadditions.mod.util.PosUtil; import net.minecraft.block.Block; @@ -27,7 +27,7 @@ import net.minecraft.util.math.BlockPos; import java.util.ArrayList; import java.util.List; -public class LensNone extends Lens{ +public class LensConversion extends Lens{ @SuppressWarnings("unchecked") @Override @@ -40,8 +40,8 @@ public class LensNone extends Lens{ for(int reachZ = -range; reachZ < range+1; reachZ++){ for(int reachY = -range; reachY < range+1; reachY++){ BlockPos pos = new BlockPos(hitBlock.getX()+reachX, hitBlock.getY()+reachY, hitBlock.getZ()+reachZ); - List recipes = LensRecipeHandler.getRecipesFor(new ItemStack(PosUtil.getBlock(pos, tile.getWorldObject()), 1, PosUtil.getMetadata(pos, tile.getWorldObject()))); - for(LensNoneRecipe recipe : recipes){ + List recipes = LensRecipeHandler.getRecipesFor(new ItemStack(PosUtil.getBlock(pos, tile.getWorldObject()), 1, PosUtil.getMetadata(pos, tile.getWorldObject()))); + for(LensConversionRecipe recipe : recipes){ if(recipe != null && tile.getEnergy() >= recipe.energyUse){ List outputs = recipe.getOutputs(); if(outputs != null && !outputs.isEmpty()){ @@ -70,8 +70,8 @@ public class LensNone extends Lens{ for(EntityItem item : items){ ItemStack stack = item.getEntityItem(); if(!item.isDead && stack != null){ - List recipes = LensRecipeHandler.getRecipesFor(stack); - for(LensNoneRecipe recipe : recipes){ + List recipes = LensRecipeHandler.getRecipesFor(stack); + for(LensConversionRecipe recipe : recipes){ if(recipe != null && tile.getEnergy() >= recipe.energyUse){ List outputs = recipe.getOutputs(); if(outputs != null && !outputs.isEmpty()){ diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensRecipeHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensRecipeHandler.java index 160a5a385..98c1c027a 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensRecipeHandler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensRecipeHandler.java @@ -13,7 +13,7 @@ package de.ellpeck.actuallyadditions.mod.items.lens; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.recipe.ColorLensChangerByDyeMeta; import de.ellpeck.actuallyadditions.api.recipe.IColorLensChanger; -import de.ellpeck.actuallyadditions.api.recipe.LensNoneRecipe; +import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe; import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; import de.ellpeck.actuallyadditions.mod.config.values.ConfigCrafting; import de.ellpeck.actuallyadditions.mod.items.InitItems; @@ -30,74 +30,74 @@ import java.util.ArrayList; public class LensRecipeHandler{ - public static ArrayList mainPageRecipes = new ArrayList(); - public static LensNoneRecipe recipeColorLens; - public static LensNoneRecipe recipeSoulSand; - public static LensNoneRecipe recipeGreenWall; - public static LensNoneRecipe recipeWhiteWall; - public static LensNoneRecipe recipeExplosionLens; - public static LensNoneRecipe recipeDamageLens; - public static LensNoneRecipe recipeLeather; - public static LensNoneRecipe recipeNetherWart; + public static ArrayList mainPageRecipes = new ArrayList(); + public static LensConversionRecipe recipeColorLens; + public static LensConversionRecipe recipeSoulSand; + public static LensConversionRecipe recipeGreenWall; + public static LensConversionRecipe recipeWhiteWall; + public static LensConversionRecipe recipeExplosionLens; + public static LensConversionRecipe recipeDamageLens; + public static LensConversionRecipe recipeLeather; + public static LensConversionRecipe recipeNetherWart; public static void init(){ //Crystal Blocks - ActuallyAdditionsAPI.addReconstructorLensNoneRecipe(new ItemStack(Blocks.REDSTONE_BLOCK), new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.REDSTONE.ordinal()), 400); + ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(Blocks.REDSTONE_BLOCK), new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.REDSTONE.ordinal()), 400); mainPageRecipes.add(RecipeUtil.lastReconstructorRecipe()); - ActuallyAdditionsAPI.addReconstructorLensNoneRecipe(new ItemStack(Blocks.LAPIS_BLOCK), new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.LAPIS.ordinal()), 400); + ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(Blocks.LAPIS_BLOCK), new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.LAPIS.ordinal()), 400); mainPageRecipes.add(RecipeUtil.lastReconstructorRecipe()); - ActuallyAdditionsAPI.addReconstructorLensNoneRecipe(new ItemStack(Blocks.DIAMOND_BLOCK), new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.DIAMOND.ordinal()), 600); + ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(Blocks.DIAMOND_BLOCK), new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.DIAMOND.ordinal()), 600); mainPageRecipes.add(RecipeUtil.lastReconstructorRecipe()); - ActuallyAdditionsAPI.addReconstructorLensNoneRecipe(new ItemStack(Blocks.EMERALD_BLOCK), new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.EMERALD.ordinal()), 1000); + ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(Blocks.EMERALD_BLOCK), new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.EMERALD.ordinal()), 1000); mainPageRecipes.add(RecipeUtil.lastReconstructorRecipe()); - ActuallyAdditionsAPI.addReconstructorLensNoneRecipe(new ItemStack(Blocks.COAL_BLOCK), new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.COAL.ordinal()), 600); + ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(Blocks.COAL_BLOCK), new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.COAL.ordinal()), 600); mainPageRecipes.add(RecipeUtil.lastReconstructorRecipe()); - ActuallyAdditionsAPI.addReconstructorLensNoneRecipe(new ItemStack(Blocks.IRON_BLOCK), new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.IRON.ordinal()), 800); + ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(Blocks.IRON_BLOCK), new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.IRON.ordinal()), 800); mainPageRecipes.add(RecipeUtil.lastReconstructorRecipe()); //Crystal Items - ActuallyAdditionsAPI.addReconstructorLensNoneRecipe(new ItemStack(Items.REDSTONE), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), 40); + ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(Items.REDSTONE), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), 40); mainPageRecipes.add(RecipeUtil.lastReconstructorRecipe()); - ActuallyAdditionsAPI.addReconstructorLensNoneRecipe(new ItemStack(Items.DYE, 1, 4), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.LAPIS.ordinal()), 40); + ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(Items.DYE, 1, 4), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.LAPIS.ordinal()), 40); mainPageRecipes.add(RecipeUtil.lastReconstructorRecipe()); - ActuallyAdditionsAPI.addReconstructorLensNoneRecipe(new ItemStack(Items.DIAMOND), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.DIAMOND.ordinal()), 60); + ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(Items.DIAMOND), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.DIAMOND.ordinal()), 60); mainPageRecipes.add(RecipeUtil.lastReconstructorRecipe()); - ActuallyAdditionsAPI.addReconstructorLensNoneRecipe(new ItemStack(Items.EMERALD), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.EMERALD.ordinal()), 100); + ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(Items.EMERALD), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.EMERALD.ordinal()), 100); mainPageRecipes.add(RecipeUtil.lastReconstructorRecipe()); - ActuallyAdditionsAPI.addReconstructorLensNoneRecipe(new ItemStack(Items.COAL), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.COAL.ordinal()), 60); + ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(Items.COAL), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.COAL.ordinal()), 60); mainPageRecipes.add(RecipeUtil.lastReconstructorRecipe()); - ActuallyAdditionsAPI.addReconstructorLensNoneRecipe(new ItemStack(Items.IRON_INGOT), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), 80); + ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(Items.IRON_INGOT), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), 80); //Lenses - ActuallyAdditionsAPI.addReconstructorLensNoneRecipe(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.LENS.ordinal()), new ItemStack(InitItems.itemColorLens), 5000); + ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.LENS.ordinal()), new ItemStack(InitItems.itemColorLens), 5000); recipeColorLens = RecipeUtil.lastReconstructorRecipe(); if(ConfigCrafting.RECONSTRUCTOR_EXPLOSION_LENS.isEnabled()){ - ActuallyAdditionsAPI.addReconstructorLensNoneRecipe(new ItemStack(InitItems.itemColorLens), new ItemStack(InitItems.itemExplosionLens), 5000); + ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(InitItems.itemColorLens), new ItemStack(InitItems.itemExplosionLens), 5000); recipeExplosionLens = RecipeUtil.lastReconstructorRecipe(); - ActuallyAdditionsAPI.addReconstructorLensNoneRecipe(new ItemStack(InitItems.itemExplosionLens), new ItemStack(InitItems.itemDamageLens), 5000); + ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(InitItems.itemExplosionLens), new ItemStack(InitItems.itemDamageLens), 5000); } else{ - ActuallyAdditionsAPI.addReconstructorLensNoneRecipe(new ItemStack(InitItems.itemColorLens), new ItemStack(InitItems.itemDamageLens), 5000); + ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(InitItems.itemColorLens), new ItemStack(InitItems.itemDamageLens), 5000); } recipeDamageLens = RecipeUtil.lastReconstructorRecipe(); - ActuallyAdditionsAPI.addReconstructorLensNoneRecipe(new ItemStack(InitItems.itemDamageLens), new ItemStack(InitItems.itemMisc, 1, TheMiscItems.LENS.ordinal()), 5000); + ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(InitItems.itemDamageLens), new ItemStack(InitItems.itemMisc, 1, TheMiscItems.LENS.ordinal()), 5000); //Misc if(ConfigCrafting.RECONSTRUCTOR_MISC.isEnabled()){ - ActuallyAdditionsAPI.addReconstructorLensNoneRecipe(new ItemStack(Blocks.SAND), new ItemStack(Blocks.SOUL_SAND), 20000); + ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(Blocks.SAND), new ItemStack(Blocks.SOUL_SAND), 20000); recipeSoulSand = RecipeUtil.lastReconstructorRecipe(); - ActuallyAdditionsAPI.addReconstructorLensNoneRecipe(new ItemStack(Items.ROTTEN_FLESH), new ItemStack(Items.LEATHER), 8000); + ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(Items.ROTTEN_FLESH), new ItemStack(Items.LEATHER), 8000); recipeLeather = RecipeUtil.lastReconstructorRecipe(); - ActuallyAdditionsAPI.addReconstructorLensNoneRecipe(new ItemStack(Blocks.RED_MUSHROOM), new ItemStack(Items.NETHER_WART), 150000); + ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(Blocks.RED_MUSHROOM), new ItemStack(Items.NETHER_WART), 150000); recipeNetherWart = RecipeUtil.lastReconstructorRecipe(); } - ActuallyAdditionsAPI.addReconstructorLensNoneRecipe(new ItemStack(Blocks.QUARTZ_BLOCK), new ItemStack(InitBlocks.blockTestifiBucksWhiteWall), 10); + ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(Blocks.QUARTZ_BLOCK), new ItemStack(InitBlocks.blockTestifiBucksWhiteWall), 10); recipeWhiteWall = RecipeUtil.lastReconstructorRecipe(); - ActuallyAdditionsAPI.addReconstructorLensNoneRecipe(new ItemStack(Blocks.QUARTZ_BLOCK, 1, 1), new ItemStack(InitBlocks.blockTestifiBucksGreenWall), 10); + ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(Blocks.QUARTZ_BLOCK, 1, 1), new ItemStack(InitBlocks.blockTestifiBucksGreenWall), 10); recipeGreenWall = RecipeUtil.lastReconstructorRecipe(); IColorLensChanger changer = new ColorLensChangerByDyeMeta(); @@ -112,9 +112,9 @@ public class LensRecipeHandler{ } - public static ArrayList getRecipesFor(ItemStack input){ - ArrayList possibleRecipes = new ArrayList(); - for(LensNoneRecipe recipe : ActuallyAdditionsAPI.reconstructorLensNoneRecipes){ + public static ArrayList getRecipesFor(ItemStack input){ + ArrayList possibleRecipes = new ArrayList(); + for(LensConversionRecipe recipe : ActuallyAdditionsAPI.reconstructorLensConversionRecipes){ if(ItemUtil.contains(recipe.getInputs(), input, true)){ possibleRecipes.add(recipe); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/Lenses.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/Lenses.java index fd2a8169f..1dcbb660b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/Lenses.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/Lenses.java @@ -14,7 +14,7 @@ import de.ellpeck.actuallyadditions.api.lens.Lens; public class Lenses{ - public static final Lens LENS_NONE = new LensNone(); + public static final Lens LENS_NONE = new LensConversion(); public static final Lens LENS_DETONATION = new LensDetonation(); public static final Lens LENS_DEATH = new LensDeath(); public static final Lens LENS_COLOR = new LensColor(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/JEIActuallyAdditionsPlugin.java b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/JEIActuallyAdditionsPlugin.java index 1d45ffa0d..8baa62f86 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/JEIActuallyAdditionsPlugin.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/JEIActuallyAdditionsPlugin.java @@ -58,7 +58,7 @@ public class JEIActuallyAdditionsPlugin implements IModPlugin{ registry.addRecipes(ActuallyAdditionsAPI.bookletPagesWithItemStackData); registry.addRecipes(ActuallyAdditionsAPI.coffeeMachineIngredients); registry.addRecipes(ActuallyAdditionsAPI.crusherRecipes); - registry.addRecipes(ActuallyAdditionsAPI.reconstructorLensNoneRecipes); + registry.addRecipes(ActuallyAdditionsAPI.reconstructorLensConversionRecipes); registry.addRecipeClickArea(GuiCoffeeMachine.class, 53, 42, 22, 16, NEICoffeeMachineRecipe.NAME); registry.addRecipeClickArea(GuiGrinder.class, 80, 40, 24, 22, CrusherRecipeCategory.NAME); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/coffee/CoffeeMachineRecipeHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/coffee/CoffeeMachineRecipeHandler.java index 04f208f1b..e2c796052 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/coffee/CoffeeMachineRecipeHandler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/coffee/CoffeeMachineRecipeHandler.java @@ -10,7 +10,7 @@ package de.ellpeck.actuallyadditions.mod.jei.coffee; -import de.ellpeck.actuallyadditions.api.recipe.coffee.CoffeeIngredient; +import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient; import de.ellpeck.actuallyadditions.mod.nei.NEICoffeeMachineRecipe; import mezz.jei.api.recipe.IRecipeHandler; import mezz.jei.api.recipe.IRecipeWrapper; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/coffee/CoffeeMachineRecipeWrapper.java b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/coffee/CoffeeMachineRecipeWrapper.java index 5ac65b318..80f04422e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/coffee/CoffeeMachineRecipeWrapper.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/coffee/CoffeeMachineRecipeWrapper.java @@ -10,9 +10,9 @@ package de.ellpeck.actuallyadditions.mod.jei.coffee; +import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.booklet.BookletPage; -import de.ellpeck.actuallyadditions.api.recipe.coffee.CoffeeBrewing; -import de.ellpeck.actuallyadditions.api.recipe.coffee.CoffeeIngredient; +import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient; import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; import de.ellpeck.actuallyadditions.mod.booklet.BookletUtils; import de.ellpeck.actuallyadditions.mod.items.InitItems; @@ -42,7 +42,7 @@ public class CoffeeMachineRecipeWrapper extends RecipeWrapperWithButton implemen this.theIngredient = ingredient; this.theOutput = new ItemStack(InitItems.itemCoffee); - CoffeeBrewing.addEffectToStack(this.theOutput, this.theIngredient); + ActuallyAdditionsAPI.methodHandler.addEffectToStack(this.theOutput, this.theIngredient); } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/reconstructor/ReconstructorRecipeHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/reconstructor/ReconstructorRecipeHandler.java index 1d22fec60..ed8e90b36 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/reconstructor/ReconstructorRecipeHandler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/reconstructor/ReconstructorRecipeHandler.java @@ -10,19 +10,19 @@ package de.ellpeck.actuallyadditions.mod.jei.reconstructor; -import de.ellpeck.actuallyadditions.api.recipe.LensNoneRecipe; +import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe; import de.ellpeck.actuallyadditions.mod.nei.NEIReconstructorRecipe; import mezz.jei.api.recipe.IRecipeHandler; import mezz.jei.api.recipe.IRecipeWrapper; import javax.annotation.Nonnull; -public class ReconstructorRecipeHandler implements IRecipeHandler{ +public class ReconstructorRecipeHandler implements IRecipeHandler{ @Nonnull @Override public Class getRecipeClass(){ - return LensNoneRecipe.class; + return LensConversionRecipe.class; } @Nonnull @@ -33,12 +33,12 @@ public class ReconstructorRecipeHandler implements IRecipeHandler 0){ for(PotionEffect effect : effects){ - PotionEffect effectHas = getSameEffectFromStack(stack, effect); + PotionEffect effectHas = this.getSameEffectFromStack(stack, effect); if(effectHas != null){ if(effectHas.getAmplifier() < ingredient.maxAmplifier-1){ - addEffectProperties(stack, effect, false, true); + this.addEffectProperties(stack, effect, false, true); worked = true; } } else{ - addEffectToStack(stack, effect); + this.addEffectToStack(stack, effect); worked = true; } } @@ -46,8 +41,9 @@ public class CoffeeBrewing{ return worked; } - public static PotionEffect getSameEffectFromStack(ItemStack stack, PotionEffect effect){ - PotionEffect[] effectsStack = getEffectsFromStack(stack); + @Override + public PotionEffect getSameEffectFromStack(ItemStack stack, PotionEffect effect){ + PotionEffect[] effectsStack = this.getEffectsFromStack(stack); if(effectsStack != null && effectsStack.length > 0){ for(PotionEffect effectStack : effectsStack){ if(effect.getPotion() == effectStack.getPotion()){ @@ -58,18 +54,20 @@ public class CoffeeBrewing{ return null; } - public static void addEffectProperties(ItemStack stack, PotionEffect effect, boolean addDur, boolean addAmp){ - PotionEffect[] effects = getEffectsFromStack(stack); + @Override + public void addEffectProperties(ItemStack stack, PotionEffect effect, boolean addDur, boolean addAmp){ + PotionEffect[] effects = this.getEffectsFromStack(stack); stack.setTagCompound(new NBTTagCompound()); for(int i = 0; i < effects.length; i++){ if(effects[i].getPotion() == effect.getPotion()){ effects[i] = new PotionEffect(effects[i].getPotion(), effects[i].getDuration()+(addDur ? effect.getDuration() : 0), effects[i].getAmplifier()+(addAmp ? (effect.getAmplifier() > 0 ? effect.getAmplifier() : 1) : 0)); } - addEffectToStack(stack, effects[i]); + this.addEffectToStack(stack, effects[i]); } } - public static void addEffectToStack(ItemStack stack, PotionEffect effect){ + @Override + public void addEffectToStack(ItemStack stack, PotionEffect effect){ NBTTagCompound tag = stack.getTagCompound(); if(tag == null){ tag = new NBTTagCompound(); @@ -88,7 +86,8 @@ public class CoffeeBrewing{ stack.setTagCompound(tag); } - public static PotionEffect[] getEffectsFromStack(ItemStack stack){ + @Override + public PotionEffect[] getEffectsFromStack(ItemStack stack){ ArrayList effects = new ArrayList(); NBTTagCompound tag = stack.getTagCompound(); if(tag != null){ @@ -102,5 +101,4 @@ public class CoffeeBrewing{ } return effects.size() > 0 ? effects.toArray(new PotionEffect[effects.size()]) : null; } - } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/nei/NEIReconstructorRecipe.java b/src/main/java/de/ellpeck/actuallyadditions/mod/nei/NEIReconstructorRecipe.java index d56590414..eb2d06c85 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/nei/NEIReconstructorRecipe.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/nei/NEIReconstructorRecipe.java @@ -37,7 +37,7 @@ public class NEIReconstructorRecipe/* extends TemplateRecipeHandler implements I @Override public void loadCraftingRecipes(String outputId, Object... results){ if(outputId.equals(NAME) && getClass() == NEIReconstructorRecipe.class){ - List recipes = ActuallyAdditionsAPI.reconstructorLensNoneRecipes; + List recipes = ActuallyAdditionsAPI.reconstructorLensConversionRecipes; //Default Recipes for(LensNoneRecipe recipe : recipes){ arecipes.add(new CachedReconstructorRecipe(recipe, false)); @@ -66,7 +66,7 @@ public class NEIReconstructorRecipe/* extends TemplateRecipeHandler implements I @Override public void loadCraftingRecipes(ItemStack result){ - List recipes = ActuallyAdditionsAPI.reconstructorLensNoneRecipes; + List recipes = ActuallyAdditionsAPI.reconstructorLensConversionRecipes; //Default Recipes for(LensNoneRecipe recipe : recipes){ if(ItemUtil.contains(recipe.getOutputs(), result, true)){ @@ -84,7 +84,7 @@ public class NEIReconstructorRecipe/* extends TemplateRecipeHandler implements I @Override public void loadUsageRecipes(ItemStack ingredient){ - List recipes = ActuallyAdditionsAPI.reconstructorLensNoneRecipes; + List recipes = ActuallyAdditionsAPI.reconstructorLensConversionRecipes; //Default Recipes for(LensNoneRecipe recipe : recipes){ if(ItemUtil.contains(recipe.getInputs(), ingredient, true)){ diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCoffeeMachine.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCoffeeMachine.java index 3dffad89f..b004276f2 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCoffeeMachine.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCoffeeMachine.java @@ -12,7 +12,7 @@ package de.ellpeck.actuallyadditions.mod.tile; import cofh.api.energy.EnergyStorage; import cofh.api.energy.IEnergyReceiver; -import de.ellpeck.actuallyadditions.api.recipe.coffee.CoffeeIngredient; +import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient; import de.ellpeck.actuallyadditions.mod.config.ConfigValues; import de.ellpeck.actuallyadditions.mod.items.InitItems; import de.ellpeck.actuallyadditions.mod.items.ItemCoffee; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/RecipeUtil.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/RecipeUtil.java index c0349156a..53db6ddfb 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/RecipeUtil.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/RecipeUtil.java @@ -12,7 +12,7 @@ package de.ellpeck.actuallyadditions.mod.util; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe; -import de.ellpeck.actuallyadditions.api.recipe.LensNoneRecipe; +import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.item.crafting.IRecipe; @@ -20,8 +20,8 @@ import java.util.List; public class RecipeUtil{ - public static LensNoneRecipe lastReconstructorRecipe(){ - List list = ActuallyAdditionsAPI.reconstructorLensNoneRecipes; + public static LensConversionRecipe lastReconstructorRecipe(){ + List list = ActuallyAdditionsAPI.reconstructorLensConversionRecipes; return list.get(list.size()-1); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/playerdata/PersistentClientData.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/playerdata/PersistentClientData.java index 2b4ed115d..d20c3e30c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/playerdata/PersistentClientData.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/playerdata/PersistentClientData.java @@ -10,7 +10,7 @@ package de.ellpeck.actuallyadditions.mod.util.playerdata; -import de.ellpeck.actuallyadditions.api.internal.EntrySet; +import de.ellpeck.actuallyadditions.mod.booklet.entry.EntrySet; import de.ellpeck.actuallyadditions.mod.booklet.BookletUtils; import de.ellpeck.actuallyadditions.mod.booklet.GuiBooklet; import de.ellpeck.actuallyadditions.mod.booklet.button.BookmarkButton;