diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/BookletChapterCrusher.java b/src/main/java/ellpeck/actuallyadditions/booklet/BookletChapterCrusher.java new file mode 100644 index 000000000..03925deb0 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/booklet/BookletChapterCrusher.java @@ -0,0 +1,35 @@ +/* + * This file ("BookletChapterCrusher.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; + +import ellpeck.actuallyadditions.booklet.page.IBookletPage; +import ellpeck.actuallyadditions.booklet.page.PageCrusherRecipe; +import ellpeck.actuallyadditions.recipe.CrusherRecipeManualRegistry; +import scala.actors.threadpool.Arrays; + +import java.util.ArrayList; + +public class BookletChapterCrusher extends BookletChapter{ + + public BookletChapterCrusher(String unlocalizedName, BookletIndexEntry entry, IBookletPage... pages){ + super(unlocalizedName, entry, getAllPages(pages)); + } + + @SuppressWarnings("unchecked") + private static IBookletPage[] getAllPages(IBookletPage... pages){ + ArrayList list = new ArrayList(); + list.addAll(Arrays.asList(pages)); + for(CrusherRecipeManualRegistry.CrusherRecipe rec : CrusherRecipeManualRegistry.recipes){ + list.add(new PageCrusherRecipe(list.size()+1, rec)); + } + return list.toArray(new IBookletPage[list.size()]); + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/GuiBooklet.java b/src/main/java/ellpeck/actuallyadditions/booklet/GuiBooklet.java index 5b5d23173..421cd4960 100644 --- a/src/main/java/ellpeck/actuallyadditions/booklet/GuiBooklet.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/GuiBooklet.java @@ -28,6 +28,8 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; +import java.awt.*; +import java.net.URI; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -51,6 +53,8 @@ public class GuiBooklet extends GuiScreen{ private GuiTextField searchField; + private static final int BUTTON_TWITTER_ID = -4; + private static final int BUTTON_FORUM_ID = -3; private static final int BUTTON_ACHIEVEMENTS_ID = -2; private static final int BUTTON_CONFIG_ID = -1; private static final int BUTTON_FORWARD_ID = 0; @@ -123,6 +127,8 @@ public class GuiBooklet extends GuiScreen{ this.buttonList.add(new TexturedButton(BUTTON_ACHIEVEMENTS_ID, this.guiLeft+138, this.guiTop, 205, 0, 8, 8)); this.buttonList.add(new TexturedButton(BUTTON_CONFIG_ID, this.guiLeft+138, this.guiTop+10, 197, 0, 8, 8)); + this.buttonList.add(new TexturedButton(BUTTON_TWITTER_ID, this.guiLeft, this.guiTop, 213, 0, 8, 8)); + this.buttonList.add(new TexturedButton(BUTTON_FORUM_ID, this.guiLeft, this.guiTop+10, 221, 0, 8, 8)); this.searchField = new GuiTextField(this.unicodeRenderer, guiLeft+148, guiTop+162, 66, 10); this.searchField.setMaxStringLength(30); @@ -191,6 +197,14 @@ public class GuiBooklet extends GuiScreen{ if(x >= this.guiLeft+138 && x <= this.guiLeft+138+7 && y >= this.guiTop+10 && y <= this.guiTop+10+7){ this.func_146283_a(Collections.singletonList("Show Config"), x, y); } + //Twitter Hover Text + if(x >= this.guiLeft && x <= this.guiLeft+7 && y >= this.guiTop && y <= this.guiTop+7){ + this.func_146283_a(Collections.singletonList("Open @ActAddMod on Twitter in Browser"), x, y); + } + //Forum Hover Text + if(x >= this.guiLeft && x <= this.guiLeft+7 && y >= this.guiTop+10 && y <= this.guiTop+10+7){ + this.func_146283_a(Collections.singletonList("Open Minecraft Forum Post in Browser"), x, y); + } if(this.currentIndexEntry != null && this.currentChapter != null && this.currentPage != null){ this.currentPage.render(this, x, y); @@ -221,7 +235,27 @@ public class GuiBooklet extends GuiScreen{ @Override public void actionPerformed(GuiButton button){ - if(button.id == BUTTON_CONFIG_ID){ + if(button.id == BUTTON_TWITTER_ID){ + try{ + if(Desktop.isDesktopSupported()){ + Desktop.getDesktop().browse(new URI("https://twitter.com/ActAddMod")); + } + } + catch(Exception e){ + e.printStackTrace(); + } + } + else if(button.id == BUTTON_FORUM_ID){ + try{ + if(Desktop.isDesktopSupported()){ + Desktop.getDesktop().browse(new URI("http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/wip-mods/2374910-actually-additions-a-bunch-of-awesome-gadgets")); + } + } + catch(Exception e){ + e.printStackTrace(); + } + } + else if(button.id == BUTTON_CONFIG_ID){ mc.displayGuiScreen(new GuiConfiguration(this)); } else if(button.id == BUTTON_ACHIEVEMENTS_ID){ diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/InitBooklet.java b/src/main/java/ellpeck/actuallyadditions/booklet/InitBooklet.java index 81f7a67a8..11cf58729 100644 --- a/src/main/java/ellpeck/actuallyadditions/booklet/InitBooklet.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/InitBooklet.java @@ -40,6 +40,7 @@ public class InitBooklet{ new BookletChapter("esd", entryFunctionalNonRF, new PageText(1), new PageCrafting(2, BlockCrafting.recipeESD), new PageCrafting(3, BlockCrafting.recipeAdvancedESD)); new BookletChapter("coffeeMachine", entryFunctionalRF, new PageText(1), new PageText(2), new PageText(3), new PageCrafting(4, BlockCrafting.recipeCoffeeMachine)); + new BookletChapterCrusher("crusher", entryFunctionalRF, new PageText(1), new PageCrafting(2, BlockCrafting.recipeCrusher), new PageCrafting(3, BlockCrafting.recipeDoubleCrusher)); new BookletChapter("craftingIngs", entryMisc, new PageText(1), new PageCrafting(2, ItemCrafting.recipeCoil), new PageCrafting(3, ItemCrafting.recipeCoilAdvanced), new PageCrafting(4, BlockCrafting.recipeCase), new PageCrafting(5, BlockCrafting.recipeStoneCase), new PageCrafting(6, BlockCrafting.recipeEnderPearlBlock), new PageCrafting(7, BlockCrafting.recipeEnderCase)); new BookletChapter("cloud", entryMisc, new PageText(1), new PageCrafting(2, BlockCrafting.recipeSmileyCloud)); diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/page/BookletPage.java b/src/main/java/ellpeck/actuallyadditions/booklet/page/BookletPage.java index 45501eced..1d066661b 100644 --- a/src/main/java/ellpeck/actuallyadditions/booklet/page/BookletPage.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/page/BookletPage.java @@ -17,10 +17,14 @@ import ellpeck.actuallyadditions.util.ModUtil; import ellpeck.actuallyadditions.util.StringUtil; import net.minecraft.client.Minecraft; import net.minecraft.client.audio.PositionedSoundRecord; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.ResourceLocation; import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; import java.util.List; @@ -97,4 +101,21 @@ public class BookletPage implements IBookletPage{ gui.drawHoveringText(list, x, y); } + + protected void renderItem(GuiBooklet gui, ItemStack stack, int x, int y){ + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + RenderHelper.enableGUIStandardItemLighting(); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glPushMatrix(); + GL11.glTranslated(x, y, 0); + RenderItem.getInstance().renderItemAndEffectIntoGUI(gui.unicodeRenderer, gui.mc.getTextureManager(), stack, 0, 0); + RenderItem.getInstance().renderItemOverlayIntoGUI(gui.mc.fontRenderer, gui.mc.getTextureManager(), stack, 0, 0); + GL11.glPopMatrix(); + RenderHelper.disableStandardItemLighting(); + GL11.glPopMatrix(); + + } } diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrafting.java b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrafting.java index 151279041..3e1a93b3a 100644 --- a/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrafting.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrafting.java @@ -16,8 +16,6 @@ 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; @@ -101,9 +99,7 @@ public class PageCrafting extends BookletPage{ 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(); + this.renderItem(gui, recipe.getRecipeOutput(), xShowOutput, yShowOutput); for(int i = 0; i < 2; i++){ boolean tooltip = i == 1; for(int x = 0; x < width; x++){ @@ -114,9 +110,7 @@ public class PageCrafting extends BookletPage{ 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(); + this.renderItem(gui, stack, xShow, yShow); } else{ if(mouseX >= xShow && mouseX <= xShow+16 && mouseY >= yShow && mouseY <= yShow+16){ diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrusherRecipe.java b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrusherRecipe.java index 5abd21a6d..00c9b9bec 100644 --- a/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrusherRecipe.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrusherRecipe.java @@ -15,23 +15,21 @@ 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 CrusherRecipeManualRegistry.CrusherRecipe recipe; - public PageCrusherRecipe(int id, ItemStack input){ + public PageCrusherRecipe(int id, CrusherRecipeManualRegistry.CrusherRecipe recipe){ super(id); - this.input = input; + this.recipe = recipe; InitBooklet.pagesWithItemStackData.add(this); } @Override public void renderPre(GuiBooklet gui, int mouseX, int mouseY){ - if(CrusherRecipeManualRegistry.getOutput(this.input, false) != null){ + if(recipe.firstOutput != null){ gui.mc.getTextureManager().bindTexture(GuiBooklet.resLoc); gui.drawTexturedModalRect(gui.guiLeft+37, gui.guiTop+20, 60, 180, 60, 60); } @@ -39,14 +37,13 @@ public class PageCrusherRecipe extends BookletPage{ @Override public ItemStack getItemStackForPage(){ - return CrusherRecipeManualRegistry.getOutput(this.input, false); + return recipe.firstOutput; } @SuppressWarnings("unchecked") @Override public void render(GuiBooklet gui, int mouseX, int mouseY){ - ItemStack output = CrusherRecipeManualRegistry.getOutput(this.input, false); - if(output == null){ + if(recipe.firstOutput == null){ gui.unicodeRenderer.drawSplitString(StringUtil.localize("booklet."+ModUtil.MOD_ID_LOWER+".recipeDisabled"), gui.guiLeft+14, gui.guiTop+15, 115, 0); } @@ -55,15 +52,14 @@ public class PageCrusherRecipe extends BookletPage{ gui.unicodeRenderer.drawSplitString(text.replace("", "\n"), gui.guiLeft+14, gui.guiTop+100, 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(recipe.secondChance > 0){ + gui.unicodeRenderer.drawString(recipe.secondChance+"%", gui.guiLeft+37+62, gui.guiTop+20+35, 0); } - if(output != null){ + if(recipe.firstOutput != 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))); + ItemStack stack = (j == 0 ? this.recipe.input : (j == 1 ? recipe.firstOutput : (j == 2 ? recipe.secondOutput : null))); if(stack != null){ boolean tooltip = i == 1; @@ -71,9 +67,7 @@ public class PageCrusherRecipe extends BookletPage{ 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(); + this.renderItem(gui, stack, xShow, yShow); } else{ if(mouseX >= xShow && mouseX <= xShow+16 && mouseY >= yShow && mouseY <= yShow+16){ diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/page/PageFurnace.java b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageFurnace.java index b63bbc360..9ae4102b0 100644 --- a/src/main/java/ellpeck/actuallyadditions/booklet/page/PageFurnace.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageFurnace.java @@ -14,8 +14,6 @@ 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; @@ -66,9 +64,7 @@ public class PageFurnace extends BookletPage{ 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(); + this.renderItem(gui, stack, xShow, yShow); } else{ if(mouseX >= xShow && mouseX <= xShow+16 && mouseY >= yShow && mouseY <= yShow+16){ diff --git a/src/main/java/ellpeck/actuallyadditions/crafting/BlockCrafting.java b/src/main/java/ellpeck/actuallyadditions/crafting/BlockCrafting.java index c729f8ff0..aba050fc8 100644 --- a/src/main/java/ellpeck/actuallyadditions/crafting/BlockCrafting.java +++ b/src/main/java/ellpeck/actuallyadditions/crafting/BlockCrafting.java @@ -46,6 +46,8 @@ public class BlockCrafting{ public static IRecipe recipeAdvancedESD; public static IRecipe recipePhantomBooster; public static IRecipe recipeCoffeeMachine; + public static IRecipe recipeCrusher; + public static IRecipe recipeDoubleCrusher; public static void init(){ @@ -369,6 +371,7 @@ public class BlockCrafting{ 'Q', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.STONE_CASING.ordinal()), 'P', new ItemStack(Blocks.piston), 'F', new ItemStack(Items.flint))); + recipeCrusher = Util.lastIRecipe(); } //Double Crusher @@ -380,6 +383,7 @@ public class BlockCrafting{ 'R', InitBlocks.blockGrinder, 'F', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.STONE_CASING.ordinal()), 'P', new ItemStack(Blocks.piston))); + recipeDoubleCrusher = Util.lastIRecipe(); } //Double Furnace diff --git a/src/main/resources/assets/actuallyadditions/textures/gui/guiBooklet.png b/src/main/resources/assets/actuallyadditions/textures/gui/guiBooklet.png index 5d05a8fe3..843edc944 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