diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/GuiBooklet.java b/src/main/java/ellpeck/actuallyadditions/booklet/GuiBooklet.java index 226c14bd1..f671c8a97 100644 --- a/src/main/java/ellpeck/actuallyadditions/booklet/GuiBooklet.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/GuiBooklet.java @@ -546,7 +546,7 @@ public class GuiBooklet extends GuiScreen{ } } - private static class TexturedButton extends GuiButton{ + public static class TexturedButton extends GuiButton{ public int texturePosX; public int texturePosY; diff --git a/src/main/java/ellpeck/actuallyadditions/config/values/ConfigBoolValues.java b/src/main/java/ellpeck/actuallyadditions/config/values/ConfigBoolValues.java index 1ba624edc..fd9c22e6f 100644 --- a/src/main/java/ellpeck/actuallyadditions/config/values/ConfigBoolValues.java +++ b/src/main/java/ellpeck/actuallyadditions/config/values/ConfigBoolValues.java @@ -54,8 +54,7 @@ public enum ConfigBoolValues{ CTRL_EXTRA_INFO("Advanced Info", ConfigCategories.OTHER, true, "Show Advanced Item Info when holding Control on every Item"), CTRL_INFO_FOR_EXTRA_INFO("Advanced Info Tooltips", ConfigCategories.OTHER, true, "Show the 'Press Control for more Info'-Text on Item Tooltips"), - NEED_BOOKLET_FOR_KEYBIND_INFO("Booklet Quick Opening", ConfigCategories.TOOL_VALUES, true, "If the booklet should have to be inside the player's inventory to be able to hover over an item and press a keybind to quickly access the item's page"), - SHOW_NEED_BOOKLET_FOR_KEYBIND_INFO("Booklet Quick Opening Info", ConfigCategories.TOOL_VALUES, true, "If the 'Press key for more information'-button should show when the item has a page in the booklet"), + SHOW_BOOKLET_INFO("Booklet Quick Opening Info", ConfigCategories.TOOL_VALUES, true, "If the 'Press key for more information'-text should show when the item has a page in the booklet"), GIVE_BOOKLET_ON_FIRST_CRAFT("Give Booklet on First Craft", ConfigCategories.OTHER, true, "If the booklet should be given to the player when he first crafts something from the Mod"); public final String name; diff --git a/src/main/java/ellpeck/actuallyadditions/event/InitEvents.java b/src/main/java/ellpeck/actuallyadditions/event/InitEvents.java index 230c5b2cd..b8ba35e2c 100644 --- a/src/main/java/ellpeck/actuallyadditions/event/InitEvents.java +++ b/src/main/java/ellpeck/actuallyadditions/event/InitEvents.java @@ -10,8 +10,11 @@ package ellpeck.actuallyadditions.event; +import cpw.mods.fml.common.Loader; import ellpeck.actuallyadditions.config.values.ConfigBoolValues; +import ellpeck.actuallyadditions.nei.NeiScreenEvents; import ellpeck.actuallyadditions.update.UpdateCheckerClientNotifier; +import ellpeck.actuallyadditions.util.CompatUtil; import ellpeck.actuallyadditions.util.ModUtil; import ellpeck.actuallyadditions.util.Util; import net.minecraftforge.common.MinecraftForge; @@ -36,6 +39,10 @@ public class InitEvents{ Util.registerEvent(new TooltipEvent()); Util.registerEvent(new RenderPlayerEventAA()); + if(Loader.isModLoaded(CompatUtil.NEI_MOD_ID)){ + Util.registerEvent(new NeiScreenEvents()); + } + if(ConfigBoolValues.DO_UPDATE_CHECK.isEnabled()){ Util.registerEvent(new UpdateCheckerClientNotifier()); } diff --git a/src/main/java/ellpeck/actuallyadditions/event/TooltipEvent.java b/src/main/java/ellpeck/actuallyadditions/event/TooltipEvent.java index c0ea47c7b..20310b78d 100644 --- a/src/main/java/ellpeck/actuallyadditions/event/TooltipEvent.java +++ b/src/main/java/ellpeck/actuallyadditions/event/TooltipEvent.java @@ -15,7 +15,6 @@ import ellpeck.actuallyadditions.booklet.GuiBooklet; import ellpeck.actuallyadditions.booklet.InitBooklet; import ellpeck.actuallyadditions.booklet.page.BookletPage; import ellpeck.actuallyadditions.config.values.ConfigBoolValues; -import ellpeck.actuallyadditions.items.InitItems; import ellpeck.actuallyadditions.util.*; import net.minecraft.client.Minecraft; import net.minecraft.client.audio.PositionedSoundRecord; @@ -38,23 +37,16 @@ public class TooltipEvent{ if(event.itemStack != null && !(Minecraft.getMinecraft().currentScreen instanceof GuiBooklet)){ for(BookletPage page : InitBooklet.pagesWithItemStackData){ if(ItemUtil.contains(page.getItemStacksForPage(), event.itemStack, true)){ - int keyCode = KeyBinds.keybindOpenBooklet.getKeyCode(); - if(!ConfigBoolValues.NEED_BOOKLET_FOR_KEYBIND_INFO.isEnabled() || Minecraft.getMinecraft().thePlayer.inventory.hasItem(InitItems.itemLexicon)){ - if(ConfigBoolValues.SHOW_NEED_BOOKLET_FOR_KEYBIND_INFO.isEnabled()){ - event.toolTip.add(EnumChatFormatting.GOLD+StringUtil.localizeFormatted("booklet."+ModUtil.MOD_ID_LOWER+".keyToSeeRecipe", keyCode > 0 && keyCode < Keyboard.KEYBOARD_SIZE ? "'"+Keyboard.getKeyName(keyCode)+"'" : "[NONE]")); - } - if(Keyboard.isKeyDown(KeyBinds.keybindOpenBooklet.getKeyCode())){ - GuiBooklet book = new GuiBooklet(Minecraft.getMinecraft().currentScreen); - Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); - Minecraft.getMinecraft().displayGuiScreen(book); - book.openIndexEntry(page.getChapter().entry, InitBooklet.entries.indexOf(page.getChapter().entry)/GuiBooklet.CHAPTER_BUTTONS_AMOUNT+1, true); - book.openChapter(page.getChapter(), page); - } + if(ConfigBoolValues.SHOW_BOOKLET_INFO.isEnabled()){ + int keyCode = KeyBinds.keybindOpenBooklet.getKeyCode(); + event.toolTip.add(EnumChatFormatting.GOLD+StringUtil.localizeFormatted("booklet."+ModUtil.MOD_ID_LOWER+".keyToSeeRecipe", keyCode > 0 && keyCode < Keyboard.KEYBOARD_SIZE ? "'"+Keyboard.getKeyName(keyCode)+"'" : "[NONE]")); } - else{ - if(ConfigBoolValues.SHOW_NEED_BOOKLET_FOR_KEYBIND_INFO.isEnabled()){ - event.toolTip.addAll(Minecraft.getMinecraft().fontRenderer.listFormattedStringToWidth(EnumChatFormatting.ITALIC+StringUtil.localizeFormatted("booklet."+ModUtil.MOD_ID_LOWER+".noBookletInInventory"), GuiBooklet.TOOLTIP_SPLIT_LENGTH)); - } + if(Keyboard.isKeyDown(KeyBinds.keybindOpenBooklet.getKeyCode())){ + GuiBooklet book = new GuiBooklet(Minecraft.getMinecraft().currentScreen); + Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); + Minecraft.getMinecraft().displayGuiScreen(book); + book.openIndexEntry(page.getChapter().entry, InitBooklet.entries.indexOf(page.getChapter().entry)/GuiBooklet.CHAPTER_BUTTONS_AMOUNT+1, true); + book.openChapter(page.getChapter(), page); } break; } diff --git a/src/main/java/ellpeck/actuallyadditions/items/ItemCoffee.java b/src/main/java/ellpeck/actuallyadditions/items/ItemCoffee.java index e16701cc2..0479c52d6 100644 --- a/src/main/java/ellpeck/actuallyadditions/items/ItemCoffee.java +++ b/src/main/java/ellpeck/actuallyadditions/items/ItemCoffee.java @@ -245,6 +245,10 @@ public class ItemCoffee extends ItemFood implements IActAddItemOrBlock{ public boolean effect(ItemStack stack){ return ItemCoffee.addEffectToStack(stack, this); } + + public String getExtraText(){ + return null; + } } public static class MilkIngredient extends Ingredient{ @@ -273,5 +277,9 @@ public class ItemCoffee extends ItemFood implements IActAddItemOrBlock{ return true; } + @Override + public String getExtraText(){ + return StringUtil.localize("container.nei."+ModUtil.MOD_ID_LOWER+".coffee.extra.milk"); + } } } \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/nei/CoffeeMachineRecipeHandler.java b/src/main/java/ellpeck/actuallyadditions/nei/CoffeeMachineRecipeHandler.java new file mode 100644 index 000000000..73eff7474 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/nei/CoffeeMachineRecipeHandler.java @@ -0,0 +1,174 @@ +/* + * This file ("CoffeeMachineRecipeHandler.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 + * http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md + * View the source code at https://github.com/Ellpeck/ActuallyAdditions + * + * © 2015 Ellpeck + */ + +package ellpeck.actuallyadditions.nei; + +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.NEIServerUtils; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.RecipeInfo; +import codechicken.nei.recipe.TemplateRecipeHandler; +import ellpeck.actuallyadditions.blocks.InitBlocks; +import ellpeck.actuallyadditions.config.values.ConfigIntValues; +import ellpeck.actuallyadditions.inventory.gui.GuiCoffeeMachine; +import ellpeck.actuallyadditions.items.InitItems; +import ellpeck.actuallyadditions.items.ItemCoffee; +import ellpeck.actuallyadditions.items.metalists.TheMiscItems; +import ellpeck.actuallyadditions.util.ModUtil; +import ellpeck.actuallyadditions.util.StringUtil; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.item.ItemStack; +import org.lwjgl.opengl.GL11; + +import java.awt.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class CoffeeMachineRecipeHandler extends TemplateRecipeHandler implements INeiRecipeHandler{ + + public static final String NAME = "actuallyadditions.coffee"; + + public CoffeeMachineRecipeHandler(){ + super(); + RecipeInfo.setGuiOffset(this.getGuiClass(), 35, 3); + } + + @Override + public ItemStack getStackForInfo(){ + return new ItemStack(InitBlocks.blockCoffeeMachine); + } + + public class CachedCoffee extends CachedRecipe{ + + public PositionedStack cup; + public PositionedStack coffeeBeans; + public PositionedStack result; + public PositionedStack ingredientStack; + public String extraText; + public int maxAmp; + + public CachedCoffee(ItemCoffee.Ingredient ingredient){ + this.cup = new PositionedStack(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CUP.ordinal()), 45, 39); + this.coffeeBeans = new PositionedStack(new ItemStack(InitItems.itemCoffeeBean, ConfigIntValues.COFFEE_CACHE_USED_PER_ITEM.getValue()), 2, 39); + this.ingredientStack = new PositionedStack(ingredient.ingredient.copy(), 90, 21); + this.setupResult(ingredient); + this.extraText = ingredient.getExtraText(); + this.maxAmp = ingredient.maxAmplifier; + } + + public void setupResult(ItemCoffee.Ingredient ingredient){ + ItemStack result = new ItemStack(InitItems.itemCoffee); + ItemCoffee.addEffectToStack(result, ingredient); + this.result = new PositionedStack(result.copy(), 45, 70); + } + + @Override + public List getIngredients(){ + ArrayList list = new ArrayList(); + list.add(this.ingredientStack); + list.add(this.cup); + list.add(this.coffeeBeans); + return list; + } + + @Override + public PositionedStack getResult(){ + return result; + } + } + + @Override + public int recipiesPerPage(){ + return 1; + } + + @Override + public void loadTransferRects(){ + transferRects.add(new RecipeTransferRect(new Rectangle(20, 39, 20, 16), NAME)); + transferRects.add(new RecipeTransferRect(new Rectangle(64, 42, 23, 10), NAME)); + } + + @Override + public Class getGuiClass(){ + return GuiCoffeeMachine.class; + } + + @Override + public String getRecipeName(){ + return StringUtil.localize("container.nei."+NAME+".name"); + } + + @Override + public void loadCraftingRecipes(String outputId, Object... results){ + if(outputId.equals(NAME) && getClass() == CoffeeMachineRecipeHandler.class){ + ArrayList ingredients = ItemCoffee.ingredients; + for(ItemCoffee.Ingredient ingredient : ingredients){ + arecipes.add(new CachedCoffee(ingredient)); + } + } + else super.loadCraftingRecipes(outputId, results); + } + + @Override + public void loadCraftingRecipes(ItemStack result){ + ArrayList ingredients = ItemCoffee.ingredients; + for(ItemCoffee.Ingredient ingredient : ingredients){ + if(result.getItem() instanceof ItemCoffee) arecipes.add(new CachedCoffee(ingredient)); + } + } + + @Override + public void loadUsageRecipes(ItemStack ingredient){ + + ArrayList ingredients = ItemCoffee.ingredients; + for(ItemCoffee.Ingredient ingr : ingredients){ + if(NEIServerUtils.areStacksSameTypeCrafting(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CUP.ordinal()), ingredient) || NEIServerUtils.areStacksSameTypeCrafting(new ItemStack(InitItems.itemCoffeeBean), ingredient) || NEIServerUtils.areStacksSameTypeCrafting(ingr.ingredient.copy(), ingredient)){ + CachedCoffee theRecipe = new CachedCoffee(ingr); + theRecipe.setIngredientPermutation(Collections.singletonList(theRecipe.ingredientStack), ingredient); + arecipes.add(theRecipe); + } + } + } + + @Override + public String getGuiTexture(){ + return ModUtil.MOD_ID_LOWER + ":textures/gui/guiNEICoffeeMachine.png"; + } + + @Override + public void drawBackground(int recipeIndex){ + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GuiDraw.changeTexture(getGuiTexture()); + GuiDraw.drawTexturedModalRect(0, 0, 0, 0, 126, 88); + } + + @Override + public void drawExtras(int recipe){ + drawProgressBar(20, 39, 126, 0, 21, 16, 48, 0); + drawProgressBar(63, 42, 125, 16, 24, 12, 48, 2); + + CachedCoffee cache = (CachedCoffee)this.arecipes.get(recipe); + if(cache.extraText != null){ + GuiDraw.drawString(StringUtil.localize("container.nei."+ModUtil.MOD_ID_LOWER+".coffee.special") + ":", 2, 4, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false); + GuiDraw.drawString(cache.extraText, 2, 16, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false); + } + GuiDraw.drawString(StringUtil.localize("container.nei."+ModUtil.MOD_ID_LOWER+".coffee.shift"), 1, 75, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false); + + if(cache.maxAmp > 0){ + GuiDraw.drawString(StringUtil.localize("container.nei."+ModUtil.MOD_ID_LOWER+".coffee.maxAmount") + ": " + cache.maxAmp, 2, 28, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false); + } + } + + @Override + public String getOverlayIdentifier(){ + return NAME; + } +} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/nei/CompostRecipeHandler.java b/src/main/java/ellpeck/actuallyadditions/nei/CompostRecipeHandler.java new file mode 100644 index 000000000..771607a55 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/nei/CompostRecipeHandler.java @@ -0,0 +1,125 @@ +/* + * This file ("CompostRecipeHandler.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 + * http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md + * View the source code at https://github.com/Ellpeck/ActuallyAdditions + * + * © 2015 Ellpeck + */ + +package ellpeck.actuallyadditions.nei; + +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.NEIServerUtils; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.RecipeInfo; +import codechicken.nei.recipe.TemplateRecipeHandler; +import ellpeck.actuallyadditions.blocks.InitBlocks; +import ellpeck.actuallyadditions.config.values.ConfigIntValues; +import ellpeck.actuallyadditions.items.InitItems; +import ellpeck.actuallyadditions.items.metalists.TheMiscItems; +import ellpeck.actuallyadditions.util.ModUtil; +import ellpeck.actuallyadditions.util.StringUtil; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.item.ItemStack; +import org.lwjgl.opengl.GL11; + +import java.awt.*; +import java.util.Collections; + +public class CompostRecipeHandler extends TemplateRecipeHandler implements INeiRecipeHandler{ + + public static final String NAME = "actuallyadditions.compost"; + + public CompostRecipeHandler(){ + super(); + RecipeInfo.setGuiOffset(this.getGuiClass(), 0, 0); + } + + @Override + public ItemStack getStackForInfo(){ + return new ItemStack(InitBlocks.blockCompost); + } + + public class CachedCompostRecipe extends CachedRecipe{ + + public PositionedStack result; + public PositionedStack input; + public int chance; + + public CachedCompostRecipe(ItemStack input, ItemStack result){ + this.result = new PositionedStack(result, 67+32, 19); + this.input = new PositionedStack(input, 5+32, 19); + } + + @Override + public PositionedStack getIngredient(){ + return input; + } + + @Override + public PositionedStack getResult(){ + return result; + } + } + + @Override + public int recipiesPerPage(){ + return 2; + } + + @Override + public Class getGuiClass(){ + return null; + } + + @Override + public String getRecipeName(){ + return StringUtil.localize("container.nei."+NAME+".name"); + } + + @Override + public void loadTransferRects(){ + transferRects.add(new RecipeTransferRect(new Rectangle(31+32, 18, 22, 16), NAME)); + } + + @Override + public void loadCraftingRecipes(String outputId, Object... results){ + if(outputId.equals(NAME) && getClass() == CompostRecipeHandler.class){ + arecipes.add(new CachedCompostRecipe(new ItemStack(InitItems.itemMisc, ConfigIntValues.COMPOST_AMOUNT.getValue(), TheMiscItems.MASHED_FOOD.ordinal()), new ItemStack(InitItems.itemFertilizer, ConfigIntValues.COMPOST_AMOUNT.getValue()))); + } + else super.loadCraftingRecipes(outputId, results); + } + + @Override + public void loadCraftingRecipes(ItemStack result){ + if(NEIServerUtils.areStacksSameType(new ItemStack(InitItems.itemFertilizer), result)) arecipes.add(new CachedCompostRecipe(new ItemStack(InitItems.itemMisc, ConfigIntValues.COMPOST_AMOUNT.getValue(), TheMiscItems.MASHED_FOOD.ordinal()), new ItemStack(InitItems.itemFertilizer, ConfigIntValues.COMPOST_AMOUNT.getValue()))); + } + + @Override + public void loadUsageRecipes(ItemStack ingredient){ + if(NEIServerUtils.areStacksSameTypeCrafting(new ItemStack(InitItems.itemMisc, ConfigIntValues.COMPOST_AMOUNT.getValue(), TheMiscItems.MASHED_FOOD.ordinal()), ingredient)){ + CachedCompostRecipe theRecipe = new CachedCompostRecipe(new ItemStack(InitItems.itemMisc, ConfigIntValues.COMPOST_AMOUNT.getValue(), TheMiscItems.MASHED_FOOD.ordinal()), new ItemStack(InitItems.itemFertilizer, ConfigIntValues.COMPOST_AMOUNT.getValue())); + theRecipe.setIngredientPermutation(Collections.singletonList(theRecipe.input), ingredient); + arecipes.add(theRecipe); + } + } + + @Override + public String getGuiTexture(){ + return ModUtil.MOD_ID_LOWER + ":textures/gui/guiNEISimple.png"; + } + + @Override + public void drawBackground(int recipeIndex){ + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GuiDraw.changeTexture(getGuiTexture()); + GuiDraw.drawTexturedModalRect(32, 0, 0, 0, 96, 60); + } + + @Override + public String getOverlayIdentifier(){ + return NAME; + } +} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/nei/CrusherRecipeHandler.java b/src/main/java/ellpeck/actuallyadditions/nei/CrusherRecipeHandler.java new file mode 100644 index 000000000..074647981 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/nei/CrusherRecipeHandler.java @@ -0,0 +1,201 @@ +/* + * This file ("CrusherRecipeHandler.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 + * http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md + * View the source code at https://github.com/Ellpeck/ActuallyAdditions + * + * © 2015 Ellpeck + */ + +package ellpeck.actuallyadditions.nei; + +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.NEIServerUtils; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.RecipeInfo; +import codechicken.nei.recipe.TemplateRecipeHandler; +import ellpeck.actuallyadditions.blocks.InitBlocks; +import ellpeck.actuallyadditions.inventory.gui.GuiGrinder; +import ellpeck.actuallyadditions.recipe.CrusherRecipeManualRegistry; +import ellpeck.actuallyadditions.util.ModUtil; +import ellpeck.actuallyadditions.util.StringUtil; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.item.ItemStack; +import org.lwjgl.opengl.GL11; + +import java.awt.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class CrusherRecipeHandler extends TemplateRecipeHandler implements INeiRecipeHandler{ + + @Override + public ItemStack getStackForInfo(){ + return new ItemStack(InitBlocks.blockGrinder); + } + + public static class CrusherDoubleRecipeHandler extends CrusherRecipeHandler{ + + @Override + public ItemStack getStackForInfo(){ + return new ItemStack(InitBlocks.blockGrinderDouble); + } + + @Override + public Class getGuiClass(){ + return GuiGrinder.GuiGrinderDouble.class; + } + + @Override + public void loadTransferRects(){ + transferRects.add(new RecipeTransferRect(new Rectangle(51, 40, 24, 22), this.getName())); + transferRects.add(new RecipeTransferRect(new Rectangle(101, 40, 24, 22), this.getName())); + } + + @Override + public String getGuiTexture(){ + return ModUtil.MOD_ID_LOWER+":textures/gui/guiGrinderDouble.png"; + } + + @Override + public void drawBackground(int recipeIndex){ + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GuiDraw.changeTexture(getGuiTexture()); + GuiDraw.drawTexturedModalRect(33, 20, 33, 20, 110, 70); + } + + @Override + public void drawExtras(int recipe){ + drawProgressBar(51, 40, 176, 0, 24, 23, 48, 1); + this.drawChanceString(66, 93, recipe); + } + } + + public CrusherRecipeHandler(){ + RecipeInfo.setGuiOffset(this.getGuiClass(), 0, 0); + } + + public class CachedCrush extends CachedRecipe{ + + public PositionedStack ingredient; + public PositionedStack resultOne; + public PositionedStack resultTwo; + public int secondChance; + + public CachedCrush(ItemStack in, ItemStack resultOne, ItemStack resultTwo, int secondChance, CrusherRecipeHandler handler){ + boolean isDouble = handler instanceof CrusherDoubleRecipeHandler; + in.stackSize = 1; + this.ingredient = new PositionedStack(in, isDouble ? 51 : 80, 21); + this.resultOne = new PositionedStack(resultOne, isDouble ? 38 : 66, 69); + if(resultTwo != null) this.resultTwo = new PositionedStack(resultTwo, isDouble ? 63 : 94, 69); + this.secondChance = secondChance; + } + + @Override + public List getIngredients(){ + return getCycledIngredients(cycleticks/48, Collections.singletonList(ingredient)); + } + + @Override + public PositionedStack getResult(){ + return resultOne; + } + + @Override + public List getOtherStacks(){ + ArrayList list = new ArrayList(); + if(this.resultTwo != null) list.add(this.resultTwo); + return list; + } + } + + @Override + public int recipiesPerPage(){ + return 1; + } + + @Override + public void loadTransferRects(){ + transferRects.add(new RecipeTransferRect(new Rectangle(80, 40, 24, 22), this.getName())); + } + + @Override + public Class getGuiClass(){ + return GuiGrinder.class; + } + + @Override + public String getRecipeName(){ + return StringUtil.localize("container.nei."+this.getName()+".name"); + } + + @Override + public void loadCraftingRecipes(String outputId, Object... results){ + if(outputId.equals(this.getName()) && (getClass() == CrusherRecipeHandler.class || getClass() == CrusherDoubleRecipeHandler.class)){ + ArrayList recipes = CrusherRecipeManualRegistry.recipes; + for(CrusherRecipeManualRegistry.CrusherRecipe recipe : recipes){ + arecipes.add(new CachedCrush(recipe.input, recipe.firstOutput, recipe.secondOutput, recipe.secondChance, this)); + } + } + else super.loadCraftingRecipes(outputId, results); + } + + @Override + public void loadCraftingRecipes(ItemStack result){ + ArrayList recipes = CrusherRecipeManualRegistry.recipes; + for(CrusherRecipeManualRegistry.CrusherRecipe recipe : recipes){ + if(NEIServerUtils.areStacksSameType(recipe.firstOutput, result) || NEIServerUtils.areStacksSameType(recipe.secondOutput, result)) + arecipes.add(new CachedCrush(recipe.input, recipe.firstOutput, recipe.secondOutput, recipe.secondChance, this)); + } + } + + @Override + public void loadUsageRecipes(ItemStack ingredient){ + ArrayList recipes = CrusherRecipeManualRegistry.recipes; + for(CrusherRecipeManualRegistry.CrusherRecipe recipe : recipes){ + if(NEIServerUtils.areStacksSameTypeCrafting(recipe.input, ingredient)){ + CachedCrush theRecipe = new CachedCrush(recipe.input, recipe.firstOutput, recipe.secondOutput, recipe.secondChance, this); + theRecipe.setIngredientPermutation(Collections.singletonList(theRecipe.ingredient), ingredient); + arecipes.add(theRecipe); + } + } + } + + @Override + public String getGuiTexture(){ + return ModUtil.MOD_ID_LOWER+":textures/gui/guiGrinder.png"; + } + + @Override + public void drawBackground(int recipeIndex){ + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GuiDraw.changeTexture(getGuiTexture()); + GuiDraw.drawTexturedModalRect(60, 13, 60, 13, 56, 79); + } + + @Override + public void drawExtras(int recipe){ + drawProgressBar(80, 40, 176, 0, 24, 23, 48, 1); + this.drawChanceString(118, 73, recipe); + } + + @Override + public String getOverlayIdentifier(){ + return this.getName(); + } + + protected String getName(){ + return "actuallyadditions."+(this instanceof CrusherDoubleRecipeHandler ? "crushingDouble" : "crushing"); + } + + protected void drawChanceString(int x, int y, int recipe){ + CachedCrush crush = (CachedCrush)this.arecipes.get(recipe); + if(crush.resultTwo != null){ + int secondChance = crush.secondChance; + String secondString = secondChance+"%"; + GuiDraw.drawString(secondString, x, y, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false); + } + } +} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/nei/FurnaceDoubleRecipeHandler.java b/src/main/java/ellpeck/actuallyadditions/nei/FurnaceDoubleRecipeHandler.java new file mode 100644 index 000000000..3c1c276cd --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/nei/FurnaceDoubleRecipeHandler.java @@ -0,0 +1,144 @@ +/* + * This file ("FurnaceDoubleRecipeHandler.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 + * http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md + * View the source code at https://github.com/Ellpeck/ActuallyAdditions + * + * © 2015 Ellpeck + */ + +package ellpeck.actuallyadditions.nei; + +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.NEIServerUtils; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.RecipeInfo; +import codechicken.nei.recipe.TemplateRecipeHandler; +import ellpeck.actuallyadditions.blocks.InitBlocks; +import ellpeck.actuallyadditions.inventory.gui.GuiFurnaceDouble; +import ellpeck.actuallyadditions.util.ModUtil; +import ellpeck.actuallyadditions.util.StringUtil; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.FurnaceRecipes; +import org.lwjgl.opengl.GL11; + +import java.awt.*; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +public class FurnaceDoubleRecipeHandler extends TemplateRecipeHandler implements INeiRecipeHandler{ + + public static final String NAME = "actuallyadditions.furnaceDouble"; + + public FurnaceDoubleRecipeHandler(){ + RecipeInfo.setGuiOffset(this.getGuiClass(), 0, 0); + } + + @Override + public ItemStack getStackForInfo(){ + return new ItemStack(InitBlocks.blockFurnaceDouble); + } + + public class CachedFurn extends CachedRecipe{ + + public PositionedStack ingredient; + public PositionedStack resultOne; + + public CachedFurn(ItemStack in, ItemStack resultOne){ + in.stackSize = 1; + this.ingredient = new PositionedStack(in, 51, 21); + this.resultOne = new PositionedStack(resultOne, 50, 69); + } + + @Override + public List getIngredients(){ + return getCycledIngredients(cycleticks/48, Collections.singletonList(ingredient)); + } + + @Override + public PositionedStack getResult(){ + return resultOne; + } + } + + @Override + public Class getGuiClass(){ + return GuiFurnaceDouble.class; + } + + @Override + public void loadTransferRects(){ + transferRects.add(new RecipeTransferRect(new Rectangle(51, 40, 24, 22), NAME)); + transferRects.add(new RecipeTransferRect(new Rectangle(101, 40, 24, 22), NAME)); + } + + @Override + public String getGuiTexture(){ + return ModUtil.MOD_ID_LOWER+":textures/gui/guiFurnaceDouble.png"; + } + + @Override + public void drawBackground(int recipeIndex){ + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GuiDraw.changeTexture(getGuiTexture()); + GuiDraw.drawTexturedModalRect(46, 20, 46, 20, 84, 70); + } + + @Override + public void drawExtras(int recipe){ + drawProgressBar(51, 40, 176, 0, 24, 23, 48, 1); + } + + @Override + public int recipiesPerPage(){ + return 1; + } + + @Override + public String getRecipeName(){ + return StringUtil.localize("container.nei."+NAME+".name"); + } + + @SuppressWarnings("unchecked") + @Override + public void loadCraftingRecipes(String outputId, Object... results){ + if(outputId.equals(NAME) && getClass() == FurnaceDoubleRecipeHandler.class){ + Map recipes = (Map)FurnaceRecipes.smelting().getSmeltingList(); + for(Map.Entry recipe : recipes.entrySet()){ + arecipes.add(new CachedFurn(recipe.getKey(), recipe.getValue())); + } + } + else super.loadCraftingRecipes(outputId, results); + } + + @SuppressWarnings("unchecked") + @Override + public void loadCraftingRecipes(ItemStack result){ + Map recipes = (Map)FurnaceRecipes.smelting().getSmeltingList(); + for(Map.Entry recipe : recipes.entrySet()){ + if(NEIServerUtils.areStacksSameType(recipe.getValue(), result)) + arecipes.add(new CachedFurn(recipe.getKey(), recipe.getValue())); + } + } + + @SuppressWarnings("unchecked") + @Override + public void loadUsageRecipes(ItemStack ingredient){ + Map recipes = (Map)FurnaceRecipes.smelting().getSmeltingList(); + for(Map.Entry recipe : recipes.entrySet()){ + if(NEIServerUtils.areStacksSameTypeCrafting(recipe.getKey(), ingredient)){ + CachedFurn theRecipe = new CachedFurn(recipe.getKey(), recipe.getValue()); + theRecipe.setIngredientPermutation(Collections.singletonList(theRecipe.ingredient), ingredient); + arecipes.add(theRecipe); + } + } + } + + @Override + public String getOverlayIdentifier(){ + return NAME; + } +} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/nei/HairyBallRecipeHandler.java b/src/main/java/ellpeck/actuallyadditions/nei/HairyBallRecipeHandler.java new file mode 100644 index 000000000..a41a9f7da --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/nei/HairyBallRecipeHandler.java @@ -0,0 +1,144 @@ +/* + * This file ("HairyBallRecipeHandler.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 + * http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md + * View the source code at https://github.com/Ellpeck/ActuallyAdditions + * + * © 2015 Ellpeck + */ + +package ellpeck.actuallyadditions.nei; + +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.NEIServerUtils; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.RecipeInfo; +import codechicken.nei.recipe.TemplateRecipeHandler; +import ellpeck.actuallyadditions.items.InitItems; +import ellpeck.actuallyadditions.recipe.HairyBallHandler; +import ellpeck.actuallyadditions.util.ModUtil; +import ellpeck.actuallyadditions.util.StringUtil; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.item.ItemStack; +import org.lwjgl.opengl.GL11; + +import java.awt.*; +import java.util.ArrayList; +import java.util.Collections; + +public class HairyBallRecipeHandler extends TemplateRecipeHandler implements INeiRecipeHandler{ + + public static final String NAME = "actuallyadditions.ballOfHair"; + + public HairyBallRecipeHandler(){ + super(); + RecipeInfo.setGuiOffset(this.getGuiClass(), 0, 0); + } + + @Override + public ItemStack getStackForInfo(){ + return new ItemStack(InitItems.itemHairyBall); + } + + public class CachedBallRecipe extends CachedRecipe{ + + public PositionedStack result; + public PositionedStack input; + public int chance; + + public CachedBallRecipe(ItemStack input, ItemStack result, int chance){ + this.result = new PositionedStack(result, 67+32, 19); + this.chance = chance; + this.input = new PositionedStack(input, 5+32, 19); + } + + @Override + public PositionedStack getIngredient(){ + return input; + } + + @Override + public PositionedStack getResult(){ + return result; + } + } + + @Override + public int recipiesPerPage(){ + return 2; + } + + @Override + public Class getGuiClass(){ + return null; + } + + @Override + public String getRecipeName(){ + return StringUtil.localize("container.nei."+NAME+".name"); + } + + @Override + public void loadTransferRects(){ + transferRects.add(new RecipeTransferRect(new Rectangle(31+32, 18, 22, 16), NAME)); + } + + @Override + public void loadCraftingRecipes(String outputId, Object... results){ + if(outputId.equals(NAME) && getClass() == HairyBallRecipeHandler.class){ + ArrayList recipes = HairyBallHandler.returns; + for(HairyBallHandler.Return recipe : recipes){ + arecipes.add(new CachedBallRecipe(recipe.inputItem, recipe.returnItem, recipe.itemWeight)); + } + } + else super.loadCraftingRecipes(outputId, results); + } + + @Override + public void loadCraftingRecipes(ItemStack result){ + ArrayList recipes = HairyBallHandler.returns; + for(HairyBallHandler.Return recipe : recipes){ + if(NEIServerUtils.areStacksSameType(recipe.returnItem, result)) arecipes.add(new CachedBallRecipe(recipe.inputItem, recipe.returnItem, recipe.itemWeight)); + } + } + + @Override + public void loadUsageRecipes(ItemStack ingredient){ + ArrayList recipes = HairyBallHandler.returns; + for(HairyBallHandler.Return recipe : recipes){ + if(NEIServerUtils.areStacksSameTypeCrafting(recipe.inputItem, ingredient)){ + CachedBallRecipe theRecipe = new CachedBallRecipe(recipe.inputItem, recipe.returnItem, recipe.itemWeight); + theRecipe.setIngredientPermutation(Collections.singletonList(theRecipe.input), ingredient); + arecipes.add(theRecipe); + } + } + } + + @Override + public String getGuiTexture(){ + return ModUtil.MOD_ID_LOWER + ":textures/gui/guiNEISimple.png"; + } + + @Override + public void drawBackground(int recipeIndex){ + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GuiDraw.changeTexture(getGuiTexture()); + GuiDraw.drawTexturedModalRect(32, 0, 0, 0, 96, 60); + } + + @Override + public void drawExtras(int rec){ + CachedBallRecipe recipe = (CachedBallRecipe)this.arecipes.get(rec); + if(recipe.result != null){ + int secondChance = recipe.chance; + String secondString = secondChance + "%"; + GuiDraw.drawString(secondString, 65+32, 45, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false); + } + } + + @Override + public String getOverlayIdentifier(){ + return NAME; + } +} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/nei/INeiRecipeHandler.java b/src/main/java/ellpeck/actuallyadditions/nei/INeiRecipeHandler.java new file mode 100644 index 000000000..7ffb6003a --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/nei/INeiRecipeHandler.java @@ -0,0 +1,18 @@ +/* + * This file ("INeiRecipeHandler.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 + * http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md + * View the source code at https://github.com/Ellpeck/ActuallyAdditions + * + * © 2015 Ellpeck + */ + +package ellpeck.actuallyadditions.nei; + +import net.minecraft.item.ItemStack; + +public interface INeiRecipeHandler{ + + ItemStack getStackForInfo(); +} diff --git a/src/main/java/ellpeck/actuallyadditions/nei/NEIActuallyAdditionsConfig.java b/src/main/java/ellpeck/actuallyadditions/nei/NEIActuallyAdditionsConfig.java index 3531b7114..30ac0de67 100644 --- a/src/main/java/ellpeck/actuallyadditions/nei/NEIActuallyAdditionsConfig.java +++ b/src/main/java/ellpeck/actuallyadditions/nei/NEIActuallyAdditionsConfig.java @@ -28,6 +28,34 @@ public class NEIActuallyAdditionsConfig implements IConfigureNEI{ API.registerGuiOverlay(GuiCrafter.class, "crafting"); API.registerGuiOverlayHandler(GuiCrafter.class, new DefaultOverlayHandler(), "crafting"); + CrusherRecipeHandler crusherRecipeHandler = new CrusherRecipeHandler(); + API.registerRecipeHandler(crusherRecipeHandler); + API.registerUsageHandler(crusherRecipeHandler); + + CrusherRecipeHandler.CrusherDoubleRecipeHandler crusherDoubleRecipeHandler = new CrusherRecipeHandler.CrusherDoubleRecipeHandler(); + API.registerRecipeHandler(crusherDoubleRecipeHandler); + API.registerUsageHandler(crusherDoubleRecipeHandler); + + FurnaceDoubleRecipeHandler furnaceDoubleRecipeHandler = new FurnaceDoubleRecipeHandler(); + API.registerRecipeHandler(furnaceDoubleRecipeHandler); + API.registerUsageHandler(furnaceDoubleRecipeHandler); + + HairyBallRecipeHandler ballRecipeHandler = new HairyBallRecipeHandler(); + API.registerRecipeHandler(ballRecipeHandler); + API.registerUsageHandler(ballRecipeHandler); + + TreasureChestRecipeHandler treasureRecipeHandler = new TreasureChestRecipeHandler(); + API.registerRecipeHandler(treasureRecipeHandler); + API.registerUsageHandler(treasureRecipeHandler); + + CompostRecipeHandler compostRecipeHandler = new CompostRecipeHandler(); + API.registerRecipeHandler(compostRecipeHandler); + API.registerUsageHandler(compostRecipeHandler); + + CoffeeMachineRecipeHandler coffeeMachineRecipeHandler = new CoffeeMachineRecipeHandler(); + API.registerRecipeHandler(coffeeMachineRecipeHandler); + API.registerUsageHandler(coffeeMachineRecipeHandler); + API.hideItem(new ItemStack(InitBlocks.blockRice)); API.hideItem(new ItemStack(InitBlocks.blockCanola)); API.hideItem(new ItemStack(InitBlocks.blockFlax)); @@ -38,11 +66,12 @@ public class NEIActuallyAdditionsConfig implements IConfigureNEI{ @Override public String getName(){ - return ModUtil.MOD_ID+" NEI Plugin"; + return ModUtil.MOD_ID + " NEI Plugin"; } @Override public String getVersion(){ return ModUtil.VERSION; } + } \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/nei/NeiScreenEvents.java b/src/main/java/ellpeck/actuallyadditions/nei/NeiScreenEvents.java new file mode 100644 index 000000000..487a26d85 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/nei/NeiScreenEvents.java @@ -0,0 +1,83 @@ +/* + * This file ("InitGuiEvent.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 + * http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md + * View the source code at https://github.com/Ellpeck/ActuallyAdditions + * + * © 2015 Ellpeck + */ + +package ellpeck.actuallyadditions.nei; + +import codechicken.nei.recipe.GuiRecipe; +import codechicken.nei.recipe.IRecipeHandler; +import cpw.mods.fml.common.Optional; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import ellpeck.actuallyadditions.booklet.GuiBooklet; +import ellpeck.actuallyadditions.booklet.InitBooklet; +import ellpeck.actuallyadditions.booklet.page.BookletPage; +import ellpeck.actuallyadditions.util.CompatUtil; +import ellpeck.actuallyadditions.util.ItemUtil; +import ellpeck.actuallyadditions.util.StringUtil; +import net.minecraft.client.Minecraft; +import net.minecraft.client.audio.PositionedSoundRecord; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.event.GuiScreenEvent; + +public class NeiScreenEvents{ + + private static final int NEI_BUTTON_ID = 123782; + private GuiBooklet.TexturedButton neiButton; + + @Optional.Method(modid = CompatUtil.NEI_MOD_ID) + @SuppressWarnings("unchecked") + @SubscribeEvent + public void onInitGuiForNEI(GuiScreenEvent.InitGuiEvent event){ + if(event.gui instanceof GuiRecipe){ + GuiRecipe theGui = (GuiRecipe)event.gui; + + int xSize = 176; + int ySize = 166; + int guiLeft = (event.gui.width-xSize)/2; + int guiTop = (event.gui.height-ySize)/2; + + this.neiButton = new GuiBooklet.TexturedButton(NEI_BUTTON_ID, guiLeft+xSize-24, guiTop+ySize/2-20, 146, 154, 20, 20){ + @Override + public void drawButton(Minecraft minecraft, int x, int y){ + super.drawButton(minecraft, x, y); + if(this.visible && this.field_146123_n){ + this.drawString(Minecraft.getMinecraft().fontRenderer, "View more Information", this.xPosition+this.width+5, this.yPosition+this.height/2-Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT/2, StringUtil.DECIMAL_COLOR_WHITE); + } + } + }; + + event.buttonList.add(this.neiButton); + this.neiButton.visible = theGui.getCurrentRecipeHandlers().get(theGui.recipetype) instanceof INeiRecipeHandler; + } + } + + @Optional.Method(modid = CompatUtil.NEI_MOD_ID) + @SubscribeEvent + public void guiPostAction(GuiScreenEvent.ActionPerformedEvent.Post event){ + if(this.neiButton != null && event.gui instanceof GuiRecipe){ + GuiRecipe theGui = (GuiRecipe)event.gui; + + IRecipeHandler handler = theGui.getCurrentRecipeHandlers().get(theGui.recipetype); + boolean isPage = handler instanceof INeiRecipeHandler && ((INeiRecipeHandler)handler).getStackForInfo() != null; + this.neiButton.visible = isPage; + + if(isPage && event.button.id == NEI_BUTTON_ID){ + for(BookletPage page : InitBooklet.pagesWithItemStackData){ + if(ItemUtil.contains(page.getItemStacksForPage(), ((INeiRecipeHandler)handler).getStackForInfo(), true)){ + GuiBooklet book = new GuiBooklet(Minecraft.getMinecraft().currentScreen); + Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); + Minecraft.getMinecraft().displayGuiScreen(book); + book.openIndexEntry(page.getChapter().entry, InitBooklet.entries.indexOf(page.getChapter().entry)/GuiBooklet.CHAPTER_BUTTONS_AMOUNT+1, true); + book.openChapter(page.getChapter(), page); + } + } + } + } + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/nei/TreasureChestRecipeHandler.java b/src/main/java/ellpeck/actuallyadditions/nei/TreasureChestRecipeHandler.java new file mode 100644 index 000000000..8c59a59c4 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/nei/TreasureChestRecipeHandler.java @@ -0,0 +1,146 @@ +/* + * This file ("TreasureChestRecipeHandler.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 + * http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md + * View the source code at https://github.com/Ellpeck/ActuallyAdditions + * + * © 2015 Ellpeck + */ + +package ellpeck.actuallyadditions.nei; + +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.NEIServerUtils; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.RecipeInfo; +import codechicken.nei.recipe.TemplateRecipeHandler; +import ellpeck.actuallyadditions.blocks.InitBlocks; +import ellpeck.actuallyadditions.recipe.TreasureChestHandler; +import ellpeck.actuallyadditions.util.ModUtil; +import ellpeck.actuallyadditions.util.StringUtil; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.item.ItemStack; +import org.lwjgl.opengl.GL11; + +import java.awt.*; +import java.util.ArrayList; +import java.util.Collections; + +public class TreasureChestRecipeHandler extends TemplateRecipeHandler implements INeiRecipeHandler{ + + public static final String NAME = "actuallyadditions.treasureChest"; + + public TreasureChestRecipeHandler(){ + super(); + RecipeInfo.setGuiOffset(this.getGuiClass(), 0, 0); + } + + @Override + public ItemStack getStackForInfo(){ + return new ItemStack(InitBlocks.blockTreasureChest); + } + + public class CachedTreasure extends CachedRecipe{ + + public PositionedStack result; + public PositionedStack input; + public int chance; + public int minAmount; + public int maxAmount; + + public CachedTreasure(ItemStack input, ItemStack result, int chance, int minAmount, int maxAmount){ + this.result = new PositionedStack(result, 67+32, 19); + this.chance = chance; + this.input = new PositionedStack(input, 5+32, 19); + this.minAmount = minAmount; + this.maxAmount = maxAmount; + } + + @Override + public PositionedStack getIngredient(){ + return input; + } + + @Override + public PositionedStack getResult(){ + return result; + } + } + + @Override + public int recipiesPerPage(){ + return 2; + } + + @Override + public Class getGuiClass(){ + return null; + } + + @Override + public String getRecipeName(){ + return StringUtil.localize("container.nei."+NAME+".name"); + } + + @Override + public void loadTransferRects(){ + transferRects.add(new RecipeTransferRect(new Rectangle(31+32, 18, 22, 16), NAME)); + } + + @Override + public void loadCraftingRecipes(String outputId, Object... results){ + if(outputId.equals(NAME) && getClass() == TreasureChestRecipeHandler.class){ + ArrayList recipes = TreasureChestHandler.returns; + for(TreasureChestHandler.Return recipe : recipes){ + arecipes.add(new CachedTreasure(recipe.input, recipe.returnItem, recipe.itemWeight, recipe.minAmount, recipe.maxAmount)); + } + } + else super.loadCraftingRecipes(outputId, results); + } + + @Override + public void loadCraftingRecipes(ItemStack result){ + ArrayList recipes = TreasureChestHandler.returns; + for(TreasureChestHandler.Return recipe : recipes){ + if(NEIServerUtils.areStacksSameType(recipe.returnItem, result)) arecipes.add(new CachedTreasure(recipe.input, recipe.returnItem, recipe.itemWeight, recipe.minAmount, recipe.maxAmount)); + } + } + + @Override + public void loadUsageRecipes(ItemStack ingredient){ + ArrayList recipes = TreasureChestHandler.returns; + for(TreasureChestHandler.Return recipe : recipes){ + if(NEIServerUtils.areStacksSameTypeCrafting(recipe.input, ingredient)){ + CachedTreasure theRecipe = new CachedTreasure(recipe.input, recipe.returnItem, recipe.itemWeight, recipe.minAmount, recipe.maxAmount); + theRecipe.setIngredientPermutation(Collections.singletonList(theRecipe.input), ingredient); + arecipes.add(theRecipe); + } + } + } + + @Override + public String getGuiTexture(){ + return ModUtil.MOD_ID_LOWER + ":textures/gui/guiNEISimple.png"; + } + + @Override + public void drawBackground(int recipeIndex){ + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GuiDraw.changeTexture(getGuiTexture()); + GuiDraw.drawTexturedModalRect(32, 0, 0, 0, 96, 60); + } + + @Override + public void drawExtras(int rec){ + CachedTreasure recipe = (CachedTreasure)this.arecipes.get(rec); + if(recipe.result != null){ + GuiDraw.drawString(recipe.minAmount+"-"+recipe.maxAmount+" "+StringUtil.localize("container.nei."+ModUtil.MOD_ID_LOWER+".treasureChest.info")+" "+recipe.chance+"%", 55, 45, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false); + } + } + + @Override + public String getOverlayIdentifier(){ + return NAME; + } +} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/util/CompatUtil.java b/src/main/java/ellpeck/actuallyadditions/util/CompatUtil.java index 56c905d05..cd0e29196 100644 --- a/src/main/java/ellpeck/actuallyadditions/util/CompatUtil.java +++ b/src/main/java/ellpeck/actuallyadditions/util/CompatUtil.java @@ -19,6 +19,8 @@ import net.minecraft.nbt.NBTTagCompound; public class CompatUtil{ + public static final String NEI_MOD_ID = "NotEnoughItems"; + public static void registerMFRPlant(Block block){ FMLInterModComms.sendMessage("MineFactoryReloaded", "registerHarvestable_Crop", new ItemStack(block, 1, 7)); diff --git a/src/main/resources/assets/actuallyadditions/lang/en_US.lang b/src/main/resources/assets/actuallyadditions/lang/en_US.lang index 1e0727b34..5a51bfae0 100644 --- a/src/main/resources/assets/actuallyadditions/lang/en_US.lang +++ b/src/main/resources/assets/actuallyadditions/lang/en_US.lang @@ -10,6 +10,20 @@ key.actuallyadditions.openBooklet.name=Open Booklet in Inventory fluid.oil=Oil fluid.canolaoil=Canola Oil +#NEI Integration +container.nei.actuallyadditions.crushing.name=Crusher +container.nei.actuallyadditions.crushingDouble.name=Double Crusher +container.nei.actuallyadditions.ballOfHair.name=Ball Of Hair Usage +container.nei.actuallyadditions.compost.name=Compost +container.nei.actuallyadditions.furnaceDouble.name=Double Furnace +container.nei.actuallyadditions.treasureChest.name=Treasure Chest +container.nei.actuallyadditions.treasureChest.info=Items at +container.nei.actuallyadditions.coffee.name=Coffee Machine +container.nei.actuallyadditions.coffee.special=Special Feature +container.nei.actuallyadditions.coffee.maxAmount=Max Amount +container.nei.actuallyadditions.coffee.shift=[SHIFT]! +container.nei.actuallyadditions.coffee.extra.milk=+01:00, -1 Level + #Blocks tile.actuallyadditions.blockCompost.name=Compost tile.actuallyadditions.blockMiscOreBlackQuartz.name=Black Quartz Ore @@ -391,7 +405,6 @@ booklet.actuallyadditions.indexEntry.itemsRF.name=Items that use RF booklet.actuallyadditions.recipeDisabled=The crafting recipe for this item is disabled in the Config File! If you're on a server, ask the server author to enable it in the config. If you're on a client, press the 'Open Config'-Button on the top right and enable the recipe! booklet.actuallyadditions.clickToSeeRecipe=Click to see more Information booklet.actuallyadditions.keyToSeeRecipe=Press %s to see more Information -booklet.actuallyadditions.noBookletInInventory=Get an Actually Additions Manual to see more Information! #Booklet Chapters booklet.actuallyadditions.chapter.intro.name=An Introduction to ActAdd diff --git a/src/main/resources/assets/actuallyadditions/textures/gui/guiBooklet.png b/src/main/resources/assets/actuallyadditions/textures/gui/guiBooklet.png index e9bce02f5..2a1d816df 100644 Binary files a/src/main/resources/assets/actuallyadditions/textures/gui/guiBooklet.png and b/src/main/resources/assets/actuallyadditions/textures/gui/guiBooklet.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/gui/guiNEICoffeeMachine.png b/src/main/resources/assets/actuallyadditions/textures/gui/guiNEICoffeeMachine.png new file mode 100644 index 000000000..45b997d4a Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/gui/guiNEICoffeeMachine.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/gui/guiNEISimple.png b/src/main/resources/assets/actuallyadditions/textures/gui/guiNEISimple.png new file mode 100644 index 000000000..8f0ac2bc8 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/gui/guiNEISimple.png differ