From 3f09889e7f786e99336a0eb233f035a53cecc5dd Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sat, 29 Aug 2015 23:01:13 +0200 Subject: [PATCH] Moved Booklet package --- .../gui => }/booklet/BookletChapter.java | 3 +- .../booklet/BookletEntryAllSearch.java | 2 +- .../gui => }/booklet/BookletIndexEntry.java | 2 +- .../gui => }/booklet/GuiAAAchievements.java | 2 +- .../gui => }/booklet/GuiBooklet.java | 3 +- .../gui => }/booklet/InitBooklet.java | 6 +- .../booklet/page/BookletPage.java | 94 +++++++++++++ .../booklet/page/IBookletPage.java | 32 +++++ .../booklet/page/PageCrafting.java | 132 ++++++++++++++++++ .../booklet/page/PageCrusherRecipe.java | 85 +++++++++++ .../booklet/page/PageFurnace.java | 87 ++++++++++++ .../booklet/page/PageText.java | 32 +++++ .../inventory/GuiHandler.java | 2 +- .../assets/actuallyadditions/lang/en_US.lang | 2 +- 14 files changed, 476 insertions(+), 8 deletions(-) rename src/main/java/ellpeck/actuallyadditions/{inventory/gui => }/booklet/BookletChapter.java (92%) rename src/main/java/ellpeck/actuallyadditions/{inventory/gui => }/booklet/BookletEntryAllSearch.java (93%) rename src/main/java/ellpeck/actuallyadditions/{inventory/gui => }/booklet/BookletIndexEntry.java (95%) rename src/main/java/ellpeck/actuallyadditions/{inventory/gui => }/booklet/GuiAAAchievements.java (95%) rename src/main/java/ellpeck/actuallyadditions/{inventory/gui => }/booklet/GuiBooklet.java (99%) rename src/main/java/ellpeck/actuallyadditions/{inventory/gui => }/booklet/InitBooklet.java (91%) create mode 100644 src/main/java/ellpeck/actuallyadditions/booklet/page/BookletPage.java create mode 100644 src/main/java/ellpeck/actuallyadditions/booklet/page/IBookletPage.java create mode 100644 src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrafting.java create mode 100644 src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrusherRecipe.java create mode 100644 src/main/java/ellpeck/actuallyadditions/booklet/page/PageFurnace.java create mode 100644 src/main/java/ellpeck/actuallyadditions/booklet/page/PageText.java diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/gui/booklet/BookletChapter.java b/src/main/java/ellpeck/actuallyadditions/booklet/BookletChapter.java similarity index 92% rename from src/main/java/ellpeck/actuallyadditions/inventory/gui/booklet/BookletChapter.java rename to src/main/java/ellpeck/actuallyadditions/booklet/BookletChapter.java index 7d588040b..a1ebbbbd3 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/gui/booklet/BookletChapter.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/BookletChapter.java @@ -8,8 +8,9 @@ * © 2015 Ellpeck */ -package ellpeck.actuallyadditions.inventory.gui.booklet; +package ellpeck.actuallyadditions.booklet; +import ellpeck.actuallyadditions.booklet.page.IBookletPage; import ellpeck.actuallyadditions.util.ModUtil; import ellpeck.actuallyadditions.util.StringUtil; diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/gui/booklet/BookletEntryAllSearch.java b/src/main/java/ellpeck/actuallyadditions/booklet/BookletEntryAllSearch.java similarity index 93% rename from src/main/java/ellpeck/actuallyadditions/inventory/gui/booklet/BookletEntryAllSearch.java rename to src/main/java/ellpeck/actuallyadditions/booklet/BookletEntryAllSearch.java index 63507ec15..df900dcc1 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/gui/booklet/BookletEntryAllSearch.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/BookletEntryAllSearch.java @@ -8,7 +8,7 @@ * © 2015 Ellpeck */ -package ellpeck.actuallyadditions.inventory.gui.booklet; +package ellpeck.actuallyadditions.booklet; import java.util.ArrayList; diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/gui/booklet/BookletIndexEntry.java b/src/main/java/ellpeck/actuallyadditions/booklet/BookletIndexEntry.java similarity index 95% rename from src/main/java/ellpeck/actuallyadditions/inventory/gui/booklet/BookletIndexEntry.java rename to src/main/java/ellpeck/actuallyadditions/booklet/BookletIndexEntry.java index 999c7bdca..1c0c87363 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/gui/booklet/BookletIndexEntry.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/BookletIndexEntry.java @@ -8,7 +8,7 @@ * © 2015 Ellpeck */ -package ellpeck.actuallyadditions.inventory.gui.booklet; +package ellpeck.actuallyadditions.booklet; import ellpeck.actuallyadditions.util.ModUtil; import ellpeck.actuallyadditions.util.StringUtil; diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/gui/booklet/GuiAAAchievements.java b/src/main/java/ellpeck/actuallyadditions/booklet/GuiAAAchievements.java similarity index 95% rename from src/main/java/ellpeck/actuallyadditions/inventory/gui/booklet/GuiAAAchievements.java rename to src/main/java/ellpeck/actuallyadditions/booklet/GuiAAAchievements.java index c573709ab..a3a8cfe6c 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/gui/booklet/GuiAAAchievements.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/GuiAAAchievements.java @@ -8,7 +8,7 @@ * © 2015 Ellpeck */ -package ellpeck.actuallyadditions.inventory.gui.booklet; +package ellpeck.actuallyadditions.booklet; import cpw.mods.fml.relauncher.ReflectionHelper; import ellpeck.actuallyadditions.achievement.InitAchievements; diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/gui/booklet/GuiBooklet.java b/src/main/java/ellpeck/actuallyadditions/booklet/GuiBooklet.java similarity index 99% rename from src/main/java/ellpeck/actuallyadditions/inventory/gui/booklet/GuiBooklet.java rename to src/main/java/ellpeck/actuallyadditions/booklet/GuiBooklet.java index 71dec8279..5f3717b53 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/gui/booklet/GuiBooklet.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/GuiBooklet.java @@ -8,10 +8,11 @@ * © 2015 Ellpeck */ -package ellpeck.actuallyadditions.inventory.gui.booklet; +package ellpeck.actuallyadditions.booklet; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.booklet.page.IBookletPage; import ellpeck.actuallyadditions.config.GuiConfiguration; import ellpeck.actuallyadditions.util.AssetUtil; import ellpeck.actuallyadditions.util.ModUtil; diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/gui/booklet/InitBooklet.java b/src/main/java/ellpeck/actuallyadditions/booklet/InitBooklet.java similarity index 91% rename from src/main/java/ellpeck/actuallyadditions/inventory/gui/booklet/InitBooklet.java rename to src/main/java/ellpeck/actuallyadditions/booklet/InitBooklet.java index 51e3381dd..decd1ad66 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/gui/booklet/InitBooklet.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/InitBooklet.java @@ -8,8 +8,12 @@ * © 2015 Ellpeck */ -package ellpeck.actuallyadditions.inventory.gui.booklet; +package ellpeck.actuallyadditions.booklet; +import ellpeck.actuallyadditions.booklet.page.IBookletPage; +import ellpeck.actuallyadditions.booklet.page.PageCrafting; +import ellpeck.actuallyadditions.booklet.page.PageFurnace; +import ellpeck.actuallyadditions.booklet.page.PageText; import ellpeck.actuallyadditions.crafting.BlockCrafting; import ellpeck.actuallyadditions.crafting.FoodCrafting; import ellpeck.actuallyadditions.crafting.ItemCrafting; diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/page/BookletPage.java b/src/main/java/ellpeck/actuallyadditions/booklet/page/BookletPage.java new file mode 100644 index 000000000..7b0b9f669 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/booklet/page/BookletPage.java @@ -0,0 +1,94 @@ +/* + * This file ("BookletPage.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.booklet.page; + +import ellpeck.actuallyadditions.booklet.BookletChapter; +import ellpeck.actuallyadditions.booklet.GuiBooklet; +import ellpeck.actuallyadditions.booklet.InitBooklet; +import ellpeck.actuallyadditions.util.StringUtil; +import net.minecraft.item.ItemStack; +import org.lwjgl.input.Mouse; + +import java.util.List; + +public class BookletPage implements IBookletPage{ + + protected int id; + protected BookletChapter chapter; + + public BookletPage(int id){ + this.id = id; + } + + @Override + public int getID(){ + return this.id; + } + + @Override + public void setChapter(BookletChapter chapter){ + this.chapter = chapter; + } + + @Override + public BookletChapter getChapter(){ + return this.chapter; + } + + @Override + public String getText(){ + return null; + } + + @Override + public void renderPre(GuiBooklet gui, int mouseX, int mouseY){ + + } + + @Override + public void render(GuiBooklet gui, int mouseX, int mouseY){ + + } + + @Override + public ItemStack getItemStackForPage(){ + return null; + } + + @SuppressWarnings("unchecked") + protected void renderTooltipAndTransfer(GuiBooklet gui, ItemStack stack, int x, int y, boolean checkAndTransfer){ + List list = stack.getTooltip(gui.mc.thePlayer, gui.mc.gameSettings.advancedItemTooltips); + + for(int k = 0; k < list.size(); ++k){ + if(k == 0){ + list.set(k, stack.getRarity().rarityColor+(String)list.get(k)); + } + else{ + list.set(k, StringUtil.GRAY+list.get(k)); + } + } + + if(checkAndTransfer){ + for(IBookletPage page : InitBooklet.pagesWithItemStackData){ + if(page.getItemStackForPage() != null && page.getItemStackForPage().isItemEqual(stack)){ + list.add(StringUtil.ORANGE+"Click to see Recipe!"); + + if(Mouse.isButtonDown(0)){ + gui.openChapter(page.getChapter(), page); + } + break; + } + } + } + + gui.drawHoveringText(list, x, y); + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/page/IBookletPage.java b/src/main/java/ellpeck/actuallyadditions/booklet/page/IBookletPage.java new file mode 100644 index 000000000..c864a5652 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/booklet/page/IBookletPage.java @@ -0,0 +1,32 @@ +/* + * This file ("IBookletPage.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.booklet.page; + +import ellpeck.actuallyadditions.booklet.BookletChapter; +import ellpeck.actuallyadditions.booklet.GuiBooklet; +import net.minecraft.item.ItemStack; + +public interface IBookletPage{ + + int getID(); + + void setChapter(BookletChapter chapter); + + BookletChapter getChapter(); + + String getText(); + + void renderPre(GuiBooklet gui, int mouseX, int mouseY); + + void render(GuiBooklet gui, int mouseX, int mouseY); + + ItemStack getItemStackForPage(); +} diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrafting.java b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrafting.java new file mode 100644 index 000000000..9a42d7f09 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrafting.java @@ -0,0 +1,132 @@ +/* + * This file ("PageCrafting.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.booklet.page; + +import cpw.mods.fml.relauncher.ReflectionHelper; +import ellpeck.actuallyadditions.booklet.GuiBooklet; +import ellpeck.actuallyadditions.booklet.InitBooklet; +import ellpeck.actuallyadditions.util.ModUtil; +import ellpeck.actuallyadditions.util.StringUtil; +import ellpeck.actuallyadditions.util.Util; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.item.crafting.ShapedRecipes; +import net.minecraft.item.crafting.ShapelessRecipes; +import net.minecraftforge.oredict.ShapedOreRecipe; +import net.minecraftforge.oredict.ShapelessOreRecipe; + +import java.util.ArrayList; + +public class PageCrafting extends BookletPage{ + + private final IRecipe recipe; + + public PageCrafting(int id, IRecipe recipe){ + super(id); + this.recipe = recipe; + InitBooklet.pagesWithItemStackData.add(this); + } + + @Override + public ItemStack getItemStackForPage(){ + return this.recipe == null ? null : this.recipe.getRecipeOutput(); + } + + @Override + public void renderPre(GuiBooklet gui, int mouseX, int mouseY){ + if(this.recipe != null){ + gui.mc.getTextureManager().bindTexture(GuiBooklet.resLoc); + gui.drawTexturedModalRect(gui.guiLeft+27, gui.guiTop+20, 146, 20, 99, 60); + } + } + + @SuppressWarnings("unchecked") + @Override + public void render(GuiBooklet gui, int mouseX, int mouseY){ + if(this.recipe == null){ + gui.unicodeRenderer.drawSplitString(StringUtil.localize("booklet."+ModUtil.MOD_ID_LOWER+".recipeDisabled"), gui.guiLeft+14, gui.guiTop+15, 115, 0); + } + + gui.unicodeRenderer.drawSplitString(gui.currentPage.getText(), gui.guiLeft+14, gui.guiTop+112, 115, 0); + + if(this.recipe != null){ + + ItemStack[] stacks = new ItemStack[9]; + int width = 3; + int height = 3; + + if(recipe instanceof ShapedRecipes){ + ShapedRecipes shaped = (ShapedRecipes)recipe; + width = shaped.recipeWidth; + height = shaped.recipeHeight; + stacks = shaped.recipeItems; + } + else if(recipe instanceof ShapelessRecipes){ + ShapelessRecipes shapeless = (ShapelessRecipes)recipe; + for(int i = 0; i < shapeless.recipeItems.size(); i++){ + stacks[i] = (ItemStack)shapeless.recipeItems.get(i); + } + } + else if(recipe instanceof ShapedOreRecipe){ + ShapedOreRecipe shaped = (ShapedOreRecipe)recipe; + width = ReflectionHelper.getPrivateValue(ShapedOreRecipe.class, shaped, 4); + height = ReflectionHelper.getPrivateValue(ShapedOreRecipe.class, shaped, 5); + for(int i = 0; i < shaped.getInput().length; i++){ + Object input = shaped.getInput()[i]; + if(input != null){ + stacks[i] = input instanceof ItemStack ? (ItemStack)input : ((ArrayList)input).get(0); + } + } + } + else if(recipe instanceof ShapelessOreRecipe){ + ShapelessOreRecipe shapeless = (ShapelessOreRecipe)recipe; + for(int i = 0; i < shapeless.getInput().size(); i++){ + Object input = shapeless.getInput().get(i); + stacks[i] = input instanceof ItemStack ? (ItemStack)input : ((ArrayList)input).get(0); + } + } + + int xShowOutput = gui.guiLeft+28+82; + int yShowOutput = gui.guiTop+23+20; + RenderHelper.disableStandardItemLighting(); + RenderItem.getInstance().renderItemAndEffectIntoGUI(gui.unicodeRenderer, gui.mc.getTextureManager(), recipe.getRecipeOutput(), xShowOutput, yShowOutput); + RenderHelper.enableStandardItemLighting(); + for(int i = 0; i < 2; i++){ + boolean tooltip = i == 1; + for(int x = 0; x < width; x++){ + for(int y = 0; y < height; y++){ + ItemStack stack = stacks[y*width+x]; + if(stack != null){ + int xShow = gui.guiLeft+28+x*21; + int yShow = gui.guiTop+23+y*21; + if(!tooltip){ + if(stack.getItemDamage() == Util.WILDCARD) stack.setItemDamage(0); + RenderHelper.disableStandardItemLighting(); + RenderItem.getInstance().renderItemAndEffectIntoGUI(gui.unicodeRenderer, gui.mc.getTextureManager(), stack, xShow, yShow); + RenderHelper.enableStandardItemLighting(); + } + else{ + if(mouseX >= xShow && mouseX <= xShow+16 && mouseY >= yShow && mouseY <= yShow+16){ + this.renderTooltipAndTransfer(gui, stack, mouseX, mouseY, true); + } + } + } + } + } + } + if(mouseX >= xShowOutput && mouseX <= xShowOutput+16 && mouseY >= yShowOutput && mouseY <= yShowOutput+16){ + gui.renderToolTip(recipe.getRecipeOutput(), mouseX, mouseY); + } + } + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrusherRecipe.java b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrusherRecipe.java new file mode 100644 index 000000000..f9ec22fa2 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrusherRecipe.java @@ -0,0 +1,85 @@ +/* + * This file ("PageCrusher.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.booklet.page; + +import ellpeck.actuallyadditions.booklet.GuiBooklet; +import ellpeck.actuallyadditions.booklet.InitBooklet; +import ellpeck.actuallyadditions.recipe.CrusherRecipeManualRegistry; +import ellpeck.actuallyadditions.util.ModUtil; +import ellpeck.actuallyadditions.util.StringUtil; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.item.ItemStack; + +public class PageCrusherRecipe extends BookletPage{ + + public ItemStack input; + + public PageCrusherRecipe(int id, ItemStack input){ + super(id); + this.input = input; + InitBooklet.pagesWithItemStackData.add(this); + } + + @Override + public void renderPre(GuiBooklet gui, int mouseX, int mouseY){ + if(CrusherRecipeManualRegistry.getOutput(this.input, false) != null){ + gui.mc.getTextureManager().bindTexture(GuiBooklet.resLoc); + gui.drawTexturedModalRect(gui.guiLeft+37, gui.guiTop+20, 60, 180, 60, 60); + } + } + + @Override + public ItemStack getItemStackForPage(){ + return CrusherRecipeManualRegistry.getOutput(this.input, false); + } + + @SuppressWarnings("unchecked") + @Override + public void render(GuiBooklet gui, int mouseX, int mouseY){ + ItemStack output = CrusherRecipeManualRegistry.getOutput(this.input, false); + if(output == null){ + gui.unicodeRenderer.drawSplitString(StringUtil.localize("booklet."+ModUtil.MOD_ID_LOWER+".recipeDisabled"), gui.guiLeft+14, gui.guiTop+15, 115, 0); + } + + gui.unicodeRenderer.drawSplitString(gui.currentPage.getText(), gui.guiLeft+14, gui.guiTop+112, 115, 0); + + int secondChance = CrusherRecipeManualRegistry.getSecondChance(this.input); + if(secondChance > 0){ + gui.unicodeRenderer.drawString(secondChance+"%", gui.guiLeft+37+62, gui.guiTop+20+35, 0); + } + + if(output != null){ + for(int i = 0; i < 2; i++){ + for(int j = 0; j < 3; j++){ + ItemStack stack = (j == 0 ? this.input : (j == 1 ? output : (j == 2 ? CrusherRecipeManualRegistry.getOutput(this.input, true) : null))); + + if(stack != null){ + boolean tooltip = i == 1; + + int xShow = gui.guiLeft+37+(j == 0 ? 0 : (j == 1 ? 42 : (j == 2 ? 43 : 0))); + int yShow = gui.guiTop+20+(j == 0 ? 18 : (j == 1 ? 12 : (j == 2 ? 30 : 0))); + if(!tooltip){ + RenderHelper.disableStandardItemLighting(); + RenderItem.getInstance().renderItemAndEffectIntoGUI(gui.unicodeRenderer, gui.mc.getTextureManager(), stack, xShow, yShow); + RenderHelper.enableStandardItemLighting(); + } + else{ + if(mouseX >= xShow && mouseX <= xShow+16 && mouseY >= yShow && mouseY <= yShow+16){ + this.renderTooltipAndTransfer(gui, stack, mouseX, mouseY, j == 0); + } + } + } + } + } + } + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/page/PageFurnace.java b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageFurnace.java new file mode 100644 index 000000000..dd5fe7f43 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageFurnace.java @@ -0,0 +1,87 @@ +/* + * This file ("PageFurnace.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.booklet.page; + +import ellpeck.actuallyadditions.booklet.GuiBooklet; +import ellpeck.actuallyadditions.booklet.InitBooklet; +import ellpeck.actuallyadditions.util.ModUtil; +import ellpeck.actuallyadditions.util.StringUtil; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.FurnaceRecipes; + +import java.util.Map; + +public class PageFurnace extends BookletPage{ + + private final ItemStack result; + + public PageFurnace(int id, ItemStack result){ + super(id); + this.result = result; + InitBooklet.pagesWithItemStackData.add(this); + } + + @Override + public ItemStack getItemStackForPage(){ + return this.result; + } + + @Override + public void renderPre(GuiBooklet gui, int mouseX, int mouseY){ + if(this.getInputForOutput(this.result) != null){ + gui.mc.getTextureManager().bindTexture(GuiBooklet.resLoc); + gui.drawTexturedModalRect(gui.guiLeft+37, gui.guiTop+20, 0, 180, 60, 60); + } + } + + @SuppressWarnings("unchecked") + @Override + public void render(GuiBooklet gui, int mouseX, int mouseY){ + ItemStack input = this.getInputForOutput(this.result); + if(input == null){ + gui.unicodeRenderer.drawSplitString(StringUtil.localize("booklet."+ModUtil.MOD_ID_LOWER+".recipeDisabled"), gui.guiLeft+14, gui.guiTop+15, 115, 0); + } + + gui.unicodeRenderer.drawSplitString(gui.currentPage.getText(), gui.guiLeft+14, gui.guiTop+112, 115, 0); + + if(input != null){ + for(int i = 0; i < 2; i++){ + for(int x = 0; x < 2; x++){ + ItemStack stack = x == 0 ? input : this.result; + boolean tooltip = i == 1; + + int xShow = gui.guiLeft+37+1+x*40; + int yShow = gui.guiTop+20+20; + if(!tooltip){ + RenderHelper.disableStandardItemLighting(); + RenderItem.getInstance().renderItemAndEffectIntoGUI(gui.unicodeRenderer, gui.mc.getTextureManager(), stack, xShow, yShow); + RenderHelper.enableStandardItemLighting(); + } + else{ + if(mouseX >= xShow && mouseX <= xShow+16 && mouseY >= yShow && mouseY <= yShow+16){ + this.renderTooltipAndTransfer(gui, stack, mouseX, mouseY, x == 0); + } + } + } + } + } + } + + private ItemStack getInputForOutput(ItemStack output){ + for(Object o : FurnaceRecipes.smelting().getSmeltingList().entrySet()){ + ItemStack stack = (ItemStack)((Map.Entry)o).getValue(); + if(stack.isItemEqual(output)) return (ItemStack)((Map.Entry)o).getKey(); + } + return null; + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/page/PageText.java b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageText.java new file mode 100644 index 000000000..08689070e --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageText.java @@ -0,0 +1,32 @@ +/* + * This file ("PageText.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.booklet.page; + +import ellpeck.actuallyadditions.booklet.GuiBooklet; +import ellpeck.actuallyadditions.util.ModUtil; +import ellpeck.actuallyadditions.util.StringUtil; + +public class PageText extends BookletPage{ + + public PageText(int id){ + super(id); + } + + @Override + public String getText(){ + return StringUtil.localize("booklet."+ModUtil.MOD_ID_LOWER+".chapter."+this.chapter.getUnlocalizedName()+".text."+this.id); + } + + @Override + public void render(GuiBooklet gui, int mouseX, int mouseY){ + gui.unicodeRenderer.drawSplitString(gui.currentPage.getText(), gui.guiLeft+14, gui.guiTop+11, 115, 0); + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/GuiHandler.java b/src/main/java/ellpeck/actuallyadditions/inventory/GuiHandler.java index f9f48e274..47601fe71 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/GuiHandler.java +++ b/src/main/java/ellpeck/actuallyadditions/inventory/GuiHandler.java @@ -13,8 +13,8 @@ package ellpeck.actuallyadditions.inventory; import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.common.network.NetworkRegistry; import ellpeck.actuallyadditions.ActuallyAdditions; +import ellpeck.actuallyadditions.booklet.GuiBooklet; import ellpeck.actuallyadditions.inventory.gui.*; -import ellpeck.actuallyadditions.inventory.gui.booklet.GuiBooklet; import ellpeck.actuallyadditions.tile.TileEntityBase; import ellpeck.actuallyadditions.util.ModUtil; import net.minecraft.entity.player.EntityPlayer; diff --git a/src/main/resources/assets/actuallyadditions/lang/en_US.lang b/src/main/resources/assets/actuallyadditions/lang/en_US.lang index e590ad0a5..db3fe8849 100644 --- a/src/main/resources/assets/actuallyadditions/lang/en_US.lang +++ b/src/main/resources/assets/actuallyadditions/lang/en_US.lang @@ -398,7 +398,7 @@ booklet.actuallyadditions.chapter.phantomfaces.text.3=The Phantom Liquiface can booklet.actuallyadditions.chapter.phantomfaces.text.4=The Phantom Energyface can connect to things like generators and crushers, allowing for RF to flow through them into and out of machines. booklet.actuallyadditions.chapter.phantomfaces.text.5=Shift-Right-Click this onto any inventory and then on the Phantom Device to connect the two. -booklet.actuallyadditions.chapter.phantomBreaker.name=Phantom Breakers & Placers +booklet.actuallyadditions.chapter.phantomBreaker.name=&4Phantom&0 Breakers & Placers booklet.actuallyadditions.chapter.phantomBreaker.text.1=Phantom Breakers and Placers have very similar mechanics to Phantomfaces: They can be connected to Blocks via Phantom Connectors and interact with the environment. Phantom Breakers and Placers only have a range of 3 blocks, however, in which they can destroy and place blocks in connected places. Shift-right-clicking will supply you with information about the connection, right-clicking normally will open its interface. booklet.actuallyadditions.chapter.phantomBreaker.text.2=The Phantom Placer places Blocks that you supply it with. booklet.actuallyadditions.chapter.phantomBreaker.text.3=The Phantom Placer breaks blocks and stores them in its internal inventory.