diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/BookletUtils.java b/src/main/java/ellpeck/actuallyadditions/booklet/BookletUtils.java index 9030ac9f0..f4574a362 100644 --- a/src/main/java/ellpeck/actuallyadditions/booklet/BookletUtils.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/BookletUtils.java @@ -10,6 +10,7 @@ package ellpeck.actuallyadditions.booklet; +import ellpeck.actuallyadditions.achievement.InitAchievements; import ellpeck.actuallyadditions.booklet.chapter.BookletChapter; import ellpeck.actuallyadditions.booklet.entry.BookletEntry; import ellpeck.actuallyadditions.booklet.entry.BookletEntryAllSearch; @@ -19,6 +20,8 @@ import ellpeck.actuallyadditions.util.*; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.item.ItemStack; +import net.minecraft.stats.Achievement; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IChatComponent; import org.lwjgl.opengl.GL11; @@ -76,6 +79,45 @@ public class BookletUtils{ } } + /** + * Draws an Achievement Info if the page has items that trigger achievements + * @param pre If the hover info texts or the icon should be drawn + */ + @SuppressWarnings("unchecked") + public static void drawAchievementInfo(GuiBooklet booklet, boolean pre, int mouseX, int mouseY){ + if(booklet.currentPage == null){ + return; + } + + ItemStack[] stacks = booklet.currentPage.getItemStacksForPage(); + ArrayList list = null; + + for(ItemStack stack : stacks){ + for(Achievement achievement : InitAchievements.achievementList){ + if(stack != null && achievement.theItemStack != null && achievement.theItemStack.isItemEqual(stack)){ + if(pre){ + booklet.drawTexturedModalRect(booklet.guiLeft+booklet.xSize+1, booklet.guiTop-18, 166, 154, 22, 21); + return; + } + else{ + if(mouseX >= booklet.guiLeft+booklet.xSize+1 && mouseX < booklet.guiLeft+booklet.xSize+1+22 && mouseY >= booklet.guiTop-18 && mouseY < booklet.guiTop-18+21){ + if(list == null){ + list = new ArrayList(); + list.add(EnumChatFormatting.GOLD+"Achievements related to this page:"); + } + list.add("-"+StringUtil.localize(achievement.statId)); + list.add(EnumChatFormatting.GRAY+"("+achievement.getDescription()+")"); + } + } + } + } + } + + if(list != null){ + booklet.drawHoveringText(list, mouseX, mouseY); + } + } + /** * Pre-renders the booklet page, including * -the number of a page and its content (text, crafting recipe etc.) diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/GuiBooklet.java b/src/main/java/ellpeck/actuallyadditions/booklet/GuiBooklet.java index a44fed2d4..28107ab1f 100644 --- a/src/main/java/ellpeck/actuallyadditions/booklet/GuiBooklet.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/GuiBooklet.java @@ -102,6 +102,7 @@ public class GuiBooklet extends GuiScreen{ //Pre-Renders the current page's content etc. BookletUtils.renderPre(this, x, y, this.ticksElapsed, this.mousePressed); + BookletUtils.drawAchievementInfo(this, true, x, y); //Does vanilla drawing stuff super.drawScreen(x, y, f); @@ -115,6 +116,7 @@ public class GuiBooklet extends GuiScreen{ //Draws hovering texts for buttons this.fontRendererObj.setUnicodeFlag(false); BookletUtils.doHoverTexts(this, x, y); + BookletUtils.drawAchievementInfo(this, false, x, y); this.fontRendererObj.setUnicodeFlag(unicodeBefore); //Resets mouse diff --git a/src/main/resources/assets/actuallyadditions/textures/gui/booklet/guiBooklet.png b/src/main/resources/assets/actuallyadditions/textures/gui/booklet/guiBooklet.png index 2a1d816df..c76d273e8 100644 Binary files a/src/main/resources/assets/actuallyadditions/textures/gui/booklet/guiBooklet.png and b/src/main/resources/assets/actuallyadditions/textures/gui/booklet/guiBooklet.png differ