From 47890c5012d0705cf71f66d4f1c845b371f9ab68 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Mon, 14 Sep 2015 11:02:16 +0200 Subject: [PATCH] Made pages show even unlocalized text if it isn't turned off by default now, made you have to have a booklet in your inventory to use the keybind --- .../booklet/InitBooklet.java | 10 ++++----- .../booklet/page/BookletPage.java | 10 +++++++++ .../booklet/page/PageCrafting.java | 2 +- .../booklet/page/PageCrusherRecipe.java | 2 +- .../booklet/page/PageFurnace.java | 2 +- .../booklet/page/PageTextOnly.java | 2 +- .../actuallyadditions/event/TooltipEvent.java | 22 ++++++++++++------- .../assets/actuallyadditions/lang/en_US.lang | 4 ++++ 8 files changed, 37 insertions(+), 17 deletions(-) diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/InitBooklet.java b/src/main/java/ellpeck/actuallyadditions/booklet/InitBooklet.java index 3a060e34f..d7a9296c9 100644 --- a/src/main/java/ellpeck/actuallyadditions/booklet/InitBooklet.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/InitBooklet.java @@ -50,11 +50,11 @@ public class InitBooklet{ chapterIntro = new BookletChapter("intro", entryMisc, new ItemStack(InitItems.itemLexicon), new PageTextOnly(1), new PageTextOnly(2), new PageCrafting(3, ItemCrafting.recipeBook)); //Miscellaneous - new BookletChapter("craftingIngs", entryMisc, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL.ordinal()), new PageTextOnly(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 PageCrafting(8, ItemCrafting.recipeRing), new PageCrafting(9, ItemCrafting.recipeKnifeHandle), new PageCrafting(10, ItemCrafting.recipeKnifeBlade), new PageCrafting(11, ItemCrafting.recipeKnife), new PageCrafting(12, ItemCrafting.recipeDough), new PageCrafting(13, ItemCrafting.recipeRiceDough)); - new BookletChapter("quartz", entryMisc, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal()), new PageTextOnly(1).setStack(new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.ORE_QUARTZ.ordinal())).addTextReplacement("", ConfigIntValues.BLACK_QUARTZ_MIN_HEIGHT.getValue()).addTextReplacement("", ConfigIntValues.BLACK_QUARTZ_MAX_HEIGHT.getValue()), new PageTextOnly(2).setStack(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal())), new PageCrafting(3, BlockCrafting.recipeQuartzBlock), new PageCrafting(4, BlockCrafting.recipeQuartzPillar), new PageCrafting(5, BlockCrafting.recipeQuartzChiseled)); - new BookletChapter("cloud", entryMisc, new ItemStack(InitBlocks.blockSmileyCloud), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeSmileyCloud)); - new BookletChapter("coalStuff", entryMisc, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.TINY_COAL.ordinal()), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeTinyCoal), new PageCrafting(3, ItemCrafting.recipeTinyChar), new PageCrafting(4, BlockCrafting.recipeBlockChar)); - new BookletChapter("lamps", entryMisc, new ItemStack(InitBlocks.blockColoredLampOn, 1, TheColoredLampColors.GREEN.ordinal()), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipePowerer), new PageCrafting(3, BlockCrafting.recipesLamps[0]), new PageCrafting(4, BlockCrafting.recipesLamps[1]), new PageCrafting(5, BlockCrafting.recipesLamps[2]), new PageCrafting(6, BlockCrafting.recipesLamps[3]), new PageCrafting(7, BlockCrafting.recipesLamps[4]), new PageCrafting(8, BlockCrafting.recipesLamps[5]), new PageCrafting(9, BlockCrafting.recipesLamps[6]), new PageCrafting(10, BlockCrafting.recipesLamps[7]), new PageCrafting(11, BlockCrafting.recipesLamps[8]), new PageCrafting(12, BlockCrafting.recipesLamps[9]), new PageCrafting(13, BlockCrafting.recipesLamps[10]), new PageCrafting(14, BlockCrafting.recipesLamps[11]), new PageCrafting(15, BlockCrafting.recipesLamps[12]), new PageCrafting(16, BlockCrafting.recipesLamps[13]), new PageCrafting(17, BlockCrafting.recipesLamps[14]), new PageCrafting(18, BlockCrafting.recipesLamps[15])); + new BookletChapter("craftingIngs", entryMisc, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL.ordinal()), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeCoil).setNoText(), new PageCrafting(3, ItemCrafting.recipeCoilAdvanced).setNoText(), new PageCrafting(4, BlockCrafting.recipeCase).setNoText(), new PageCrafting(5, BlockCrafting.recipeStoneCase).setNoText(), new PageCrafting(6, BlockCrafting.recipeEnderPearlBlock).setNoText(), new PageCrafting(7, BlockCrafting.recipeEnderCase).setNoText(), new PageCrafting(8, ItemCrafting.recipeRing).setNoText(), new PageCrafting(9, ItemCrafting.recipeKnifeHandle).setNoText(), new PageCrafting(10, ItemCrafting.recipeKnifeBlade).setNoText(), new PageCrafting(11, ItemCrafting.recipeKnife).setNoText(), new PageCrafting(12, ItemCrafting.recipeDough).setNoText(), new PageCrafting(13, ItemCrafting.recipeRiceDough).setNoText()); + new BookletChapter("quartz", entryMisc, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal()), new PageTextOnly(1).setStack(new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.ORE_QUARTZ.ordinal())).addTextReplacement("", ConfigIntValues.BLACK_QUARTZ_MIN_HEIGHT.getValue()).addTextReplacement("", ConfigIntValues.BLACK_QUARTZ_MAX_HEIGHT.getValue()), new PageTextOnly(2).setStack(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal())), new PageCrafting(3, BlockCrafting.recipeQuartzBlock).setNoText(), new PageCrafting(4, BlockCrafting.recipeQuartzPillar).setNoText(), new PageCrafting(5, BlockCrafting.recipeQuartzChiseled).setNoText()); + new BookletChapter("cloud", entryMisc, new ItemStack(InitBlocks.blockSmileyCloud), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeSmileyCloud).setNoText()); + new BookletChapter("coalStuff", entryMisc, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.TINY_COAL.ordinal()), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeTinyCoal).setNoText(), new PageCrafting(3, ItemCrafting.recipeTinyChar).setNoText(), new PageCrafting(4, BlockCrafting.recipeBlockChar).setNoText()); + new BookletChapter("lamps", entryMisc, new ItemStack(InitBlocks.blockColoredLampOn, 1, TheColoredLampColors.GREEN.ordinal()), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipePowerer).setNoText(), new PageCrafting(3, BlockCrafting.recipesLamps[0]).setNoText(), new PageCrafting(4, BlockCrafting.recipesLamps[1]).setNoText(), new PageCrafting(5, BlockCrafting.recipesLamps[2]).setNoText(), new PageCrafting(6, BlockCrafting.recipesLamps[3]).setNoText(), new PageCrafting(7, BlockCrafting.recipesLamps[4]).setNoText(), new PageCrafting(8, BlockCrafting.recipesLamps[5]).setNoText(), new PageCrafting(9, BlockCrafting.recipesLamps[6]).setNoText(), new PageCrafting(10, BlockCrafting.recipesLamps[7]).setNoText(), new PageCrafting(11, BlockCrafting.recipesLamps[8]).setNoText(), new PageCrafting(12, BlockCrafting.recipesLamps[9]).setNoText(), new PageCrafting(13, BlockCrafting.recipesLamps[10]).setNoText(), new PageCrafting(14, BlockCrafting.recipesLamps[11]).setNoText(), new PageCrafting(15, BlockCrafting.recipesLamps[12]).setNoText(), new PageCrafting(16, BlockCrafting.recipesLamps[13]).setNoText(), new PageCrafting(17, BlockCrafting.recipesLamps[14]).setNoText(), new PageCrafting(18, BlockCrafting.recipesLamps[15]).setNoText()); new BookletChapter("treasureChest", entryMisc, new ItemStack(InitBlocks.blockTreasureChest), new PageTextOnly(1).setStack(new ItemStack(InitBlocks.blockTreasureChest))); //No RF Using Blocks diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/page/BookletPage.java b/src/main/java/ellpeck/actuallyadditions/booklet/page/BookletPage.java index afe0a436b..8196d6569 100644 --- a/src/main/java/ellpeck/actuallyadditions/booklet/page/BookletPage.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/page/BookletPage.java @@ -35,11 +35,17 @@ public class BookletPage{ protected int id; protected BookletChapter chapter; + private boolean hasNoText; public BookletPage(int id){ this.id = id; } + public BookletPage setNoText(){ + this.hasNoText = true; + return this; + } + public int getID(){ return this.id; } @@ -53,6 +59,10 @@ public class BookletPage{ } public final String getText(){ + if(this.hasNoText){ + return null; + } + String base = StringUtil.localize("booklet."+ModUtil.MOD_ID_LOWER+".chapter."+this.chapter.getUnlocalizedName()+".text."+this.id).replaceAll("", EnumChatFormatting.DARK_GREEN+"").replaceAll("", EnumChatFormatting.BLUE+"").replaceAll("", EnumChatFormatting.BLACK+"").replaceAll("", "\n").replaceAll("", EnumChatFormatting.ITALIC+"").replaceAll("", EnumChatFormatting.RESET+""); for(Object o : this.textReplacements.entrySet()){ Map.Entry e = (Map.Entry)o; diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrafting.java b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrafting.java index f2dd0dbc7..79ec116b2 100644 --- a/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrafting.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrafting.java @@ -60,7 +60,7 @@ public class PageCrafting extends BookletPage{ } String text = gui.currentPage.getText(); - if(text != null && !text.isEmpty() && !text.contains("booklet.")){ + if(text != null && !text.isEmpty()){ gui.unicodeRenderer.drawSplitString(text, gui.guiLeft+14, gui.guiTop+100, 115, 0); } diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrusherRecipe.java b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrusherRecipe.java index 21ea27d6d..a9fedd66f 100644 --- a/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrusherRecipe.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrusherRecipe.java @@ -53,7 +53,7 @@ public class PageCrusherRecipe extends BookletPage{ } String text = gui.currentPage.getText(); - if(text != null && !text.isEmpty() && !text.contains("booklet.")){ + if(text != null && !text.isEmpty()){ gui.unicodeRenderer.drawSplitString(text, gui.guiLeft+14, gui.guiTop+100, 115, 0); } diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/page/PageFurnace.java b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageFurnace.java index d6cdd5621..8547170cd 100644 --- a/src/main/java/ellpeck/actuallyadditions/booklet/page/PageFurnace.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageFurnace.java @@ -61,7 +61,7 @@ public class PageFurnace extends BookletPage{ } String text = gui.currentPage.getText(); - if(text != null && !text.isEmpty() && !text.contains("booklet.")){ + if(text != null && !text.isEmpty()){ gui.unicodeRenderer.drawSplitString(text, gui.guiLeft+14, gui.guiTop+100, 115, 0); } diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/page/PageTextOnly.java b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageTextOnly.java index 86fc39eab..2c9e876c1 100644 --- a/src/main/java/ellpeck/actuallyadditions/booklet/page/PageTextOnly.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageTextOnly.java @@ -38,7 +38,7 @@ public class PageTextOnly extends BookletPage{ @Override public void renderPre(GuiBooklet gui, int mouseX, int mouseY, boolean mouseClick){ String text = gui.currentPage.getText(); - if(text != null && !text.isEmpty() && !text.contains("booklet.")){ + if(text != null && !text.isEmpty()){ gui.unicodeRenderer.drawSplitString(text, gui.guiLeft+14, gui.guiTop+11, 115, 0); } } diff --git a/src/main/java/ellpeck/actuallyadditions/event/TooltipEvent.java b/src/main/java/ellpeck/actuallyadditions/event/TooltipEvent.java index d26ad5159..614441165 100644 --- a/src/main/java/ellpeck/actuallyadditions/event/TooltipEvent.java +++ b/src/main/java/ellpeck/actuallyadditions/event/TooltipEvent.java @@ -16,6 +16,7 @@ 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.KeyBinds; import ellpeck.actuallyadditions.util.KeyUtil; import ellpeck.actuallyadditions.util.ModUtil; @@ -61,15 +62,20 @@ public class TooltipEvent{ for(BookletPage page : InitBooklet.pagesWithItemStackData){ if(page.getItemStackForPage() != null && page.getItemStackForPage().isItemEqual(stack)){ 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]")); + if(Minecraft.getMinecraft().thePlayer.inventory.hasItem(InitItems.itemLexicon)){ + event.toolTip.add(EnumChatFormatting.GOLD+StringUtil.localizeFormatted("booklet."+ModUtil.MOD_ID_LOWER+".keyToSeeRecipe", keyCode > 0 && keyCode < Keyboard.KEYBOARD_SIZE ? "'"+Keyboard.getKeyName(keyCode)+"'" : "[NONE]")); - //TODO Find a better method to do this eventually - if(Keyboard.isKeyDown(KeyBinds.keybindOpenBooklet.getKeyCode())){ - GuiBooklet book = new GuiBooklet(); - 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.BUTTONS_PER_PAGE+1, true); - book.openChapter(page.getChapter(), page); + //TODO Find a better method to do this eventually + if(Keyboard.isKeyDown(KeyBinds.keybindOpenBooklet.getKeyCode())){ + GuiBooklet book = new GuiBooklet(); + 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.BUTTONS_PER_PAGE+1, true); + book.openChapter(page.getChapter(), page); + } + } + else{ + event.toolTip.addAll(Minecraft.getMinecraft().fontRenderer.listFormattedStringToWidth(EnumChatFormatting.DARK_RED+StringUtil.localizeFormatted("booklet."+ModUtil.MOD_ID_LOWER+".noBookletInInventory"), GuiBooklet.TOOLTIP_SPLIT_LENGTH)); } break; } diff --git a/src/main/resources/assets/actuallyadditions/lang/en_US.lang b/src/main/resources/assets/actuallyadditions/lang/en_US.lang index b82bf13c2..ac78e1226 100644 --- a/src/main/resources/assets/actuallyadditions/lang/en_US.lang +++ b/src/main/resources/assets/actuallyadditions/lang/en_US.lang @@ -1,6 +1,9 @@ itemGroup.actuallyadditions=Actually Additions achievement.page.actuallyadditions=Actually Additions +key.actuallyadditions.category=Actually Additions +key.actuallyadditions.openBooklet.name=Open Booklet in Inventory + fluid.oil=Oil fluid.canolaoil=Canola Oil @@ -380,6 +383,7 @@ booklet.actuallyadditions.recipeDisabled=The crafting recipe for this item is di booklet.actuallyadditions.clickToSeeRecipe=Click to see more Information booklet.actuallyadditions.keyToSeeRecipe=Press %s to see more Information +booklet.actuallyadditions.noBookletInInventory=If you had an Actually Additions Information Manual, you could check out more Information :( booklet.actuallyadditions.chapter.intro.name=An Introduction to ActAdd booklet.actuallyadditions.chapter.intro.text.1=This book, written years ago, found by the player, used to help understand the wonders of this world, finally opened, finally looked at, full of glory, full of grace, will be used to help the player along on their journey through Actually Additions. What is Actually Additions, you may ask. Actually Additions adds blocks, items, and features to make the player's experience easier, automate the world and properly do what you've always wanted to do.