diff --git a/src/main/java/ellpeck/actuallyadditions/ActuallyAdditions.java b/src/main/java/ellpeck/actuallyadditions/ActuallyAdditions.java index 55390e0e1..d8a19515a 100644 --- a/src/main/java/ellpeck/actuallyadditions/ActuallyAdditions.java +++ b/src/main/java/ellpeck/actuallyadditions/ActuallyAdditions.java @@ -64,7 +64,7 @@ public class ActuallyAdditions{ InitItems.init(); InitVillager.init(); FuelHandler.init(); - proxy.preInit(); + proxy.preInit(event); ModUtil.LOGGER.info("PreInitialization Finished."); } @@ -81,7 +81,7 @@ public class ActuallyAdditions{ InitEvents.init(); InitCrafting.init(); FMLInterModComms.sendMessage("Waila", "register", "ellpeck.actuallyadditions.waila.WailaDataProvider.register"); - proxy.init(); + proxy.init(event); ModUtil.LOGGER.info("Initialization Finished."); } @@ -96,7 +96,7 @@ public class ActuallyAdditions{ HairyBallHandler.init(); TreasureChestHandler.init(); InitForeignPaxels.init(); - proxy.postInit(); + proxy.postInit(event); ModUtil.LOGGER.info("PostInitialization Finished."); } diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/BookletChapterFurnace.java b/src/main/java/ellpeck/actuallyadditions/booklet/BookletChapterFurnace.java new file mode 100644 index 000000000..a68fe0b67 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/booklet/BookletChapterFurnace.java @@ -0,0 +1,37 @@ +/* + * This file ("BookletChapterFurnace.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.PageFurnace; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.FurnaceRecipes; +import scala.actors.threadpool.Arrays; + +import java.util.ArrayList; +import java.util.Map; + +public class BookletChapterFurnace extends BookletChapter{ + + public BookletChapterFurnace(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(Object o : FurnaceRecipes.smelting().getSmeltingList().entrySet()){ + list.add(new PageFurnace(list.size()+1, (ItemStack)((Map.Entry)o).getKey(), (ItemStack)((Map.Entry)o).getValue())); + } + 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 421cd4960..adfe84cf7 100644 --- a/src/main/java/ellpeck/actuallyadditions/booklet/GuiBooklet.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/GuiBooklet.java @@ -16,6 +16,7 @@ import ellpeck.actuallyadditions.booklet.page.IBookletPage; import ellpeck.actuallyadditions.config.GuiConfiguration; import ellpeck.actuallyadditions.util.AssetUtil; import ellpeck.actuallyadditions.util.ModUtil; +import ellpeck.actuallyadditions.util.PersistantVariables; import ellpeck.actuallyadditions.util.StringUtil; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; @@ -23,6 +24,7 @@ import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiTextField; import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.ResourceLocation; @@ -64,9 +66,12 @@ public class GuiBooklet extends GuiScreen{ private static final int BUTTONS_PER_PAGE = 15; - public GuiBooklet(){ + private EntityPlayer player; + + public GuiBooklet(EntityPlayer player){ this.xSize = 146; this.ySize = 180; + this.player = player; } @Override @@ -103,6 +108,11 @@ public class GuiBooklet extends GuiScreen{ } } + @Override + public void onGuiClosed(){ + PersistantVariables.saveBookPage(this.currentIndexEntry, this.currentChapter, this.currentPage, this.pageOpenInIndex); + } + @Override protected void mouseClicked(int par1, int par2, int par3){ this.searchField.mouseClicked(par1, par2, par3); @@ -138,7 +148,15 @@ public class GuiBooklet extends GuiScreen{ this.currentChapter = null; this.currentIndexEntry = null; - this.openIndexEntry(null, 1, true); + if(!PersistantVariables.getBoolean("BookAlreadyOpened")){ + this.openIndexEntry(InitBooklet.chapterIntro.entry, 1, true); + this.openChapter(InitBooklet.chapterIntro, null); + + PersistantVariables.setBoolean("BookAlreadyOpened", true); + } + else{ + PersistantVariables.openLastBookPage(this); + } } private GuiButton getButton(int id){ @@ -284,7 +302,7 @@ public class GuiBooklet extends GuiScreen{ } } else if(button.id == BUTTON_RETURN_ID){ - if(this.currentChapter != null){ + if(this.currentChapter != null && this.currentChapter != InitBooklet.chapterIntro){ this.openIndexEntry(this.currentIndexEntry, this.pageOpenInIndex, true); } else{ @@ -319,7 +337,7 @@ public class GuiBooklet extends GuiScreen{ } @SuppressWarnings("unchecked") - private void openIndexEntry(BookletIndexEntry entry, int page, boolean resetTextField){ + public void openIndexEntry(BookletIndexEntry entry, int page, boolean resetTextField){ if(resetTextField){ this.searchField.setVisible(entry instanceof BookletEntryAllSearch); this.searchField.setFocused(entry instanceof BookletEntryAllSearch); diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/InitBooklet.java b/src/main/java/ellpeck/actuallyadditions/booklet/InitBooklet.java index 11cf58729..3a3fbbcd0 100644 --- a/src/main/java/ellpeck/actuallyadditions/booklet/InitBooklet.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/InitBooklet.java @@ -28,12 +28,16 @@ public class InitBooklet{ public static ArrayList entries = new ArrayList(); public static ArrayList pagesWithItemStackData = new ArrayList(); + public static BookletChapter chapterIntro; + public static BookletIndexEntry entryFunctionalNonRF = new BookletIndexEntry("functionalNoRF"); public static BookletIndexEntry entryFunctionalRF = new BookletIndexEntry("functionalRF"); public static BookletIndexEntry entryMisc = new BookletIndexEntry("misc"); public static BookletIndexEntry allAndSearch = new BookletEntryAllSearch("allAndSearch"); static{ + chapterIntro = new BookletChapter("intro", entryMisc, new PageText(1), new PageText(2), new PageCrafting(3, ItemCrafting.recipeBook)); + new BookletChapter("breaker", entryFunctionalNonRF, new PageCrafting(1, BlockCrafting.recipeBreaker), new PageCrafting(2, BlockCrafting.recipePlacer), new PageCrafting(3, BlockCrafting.recipeLiquidPlacer), new PageCrafting(4, BlockCrafting.recipeLiquidCollector)); new BookletChapter("phantomfaces", entryFunctionalNonRF, new PageText(1), new PageCrafting(2, BlockCrafting.recipePhantomface), new PageCrafting(3, BlockCrafting.recipeLiquiface), new PageCrafting(4, BlockCrafting.recipeEnergyface), new PageCrafting(5, ItemCrafting.recipePhantomConnector), new PageCrafting(6, BlockCrafting.recipePhantomBooster)); new BookletChapter("phantomBreaker", entryFunctionalNonRF, new PageText(1), new PageCrafting(2, BlockCrafting.recipePhantomPlacer), new PageCrafting(3, BlockCrafting.recipePhantomBreaker)); @@ -41,6 +45,7 @@ public class InitBooklet{ 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 BookletChapterFurnace("furnaceDouble", entryFunctionalRF, new PageCrafting(1, BlockCrafting.recipeFurnace)); 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 1d066661b..a65f507fe 100644 --- a/src/main/java/ellpeck/actuallyadditions/booklet/page/BookletPage.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/page/BookletPage.java @@ -33,6 +33,8 @@ public class BookletPage implements IBookletPage{ protected int id; protected BookletChapter chapter; + private boolean mouseWasDown; + public BookletPage(int id){ this.id = id; } @@ -88,12 +90,17 @@ public class BookletPage implements IBookletPage{ if(checkAndTransfer){ for(IBookletPage page : InitBooklet.pagesWithItemStackData){ if(page.getItemStackForPage() != null && page.getItemStackForPage().isItemEqual(stack)){ - list.add(EnumChatFormatting.GOLD+"Click to see Recipe!"); + list.add(EnumChatFormatting.GOLD+StringUtil.localize("booklet."+ModUtil.MOD_ID_LOWER+".clickToSeeRecipe")); - if(Mouse.isButtonDown(0)){ - gui.openChapter(page.getChapter(), page); - Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); + boolean isDown = Mouse.isButtonDown(0); + if(!this.mouseWasDown){ + if(isDown){ + gui.openChapter(page.getChapter(), page); + Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); + } } + this.mouseWasDown = isDown; + break; } } diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrafting.java b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrafting.java index 3e1a93b3a..c1d7cc7b8 100644 --- a/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrafting.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrafting.java @@ -106,10 +106,10 @@ public class PageCrafting extends BookletPage{ for(int y = 0; y < height; y++){ ItemStack stack = stacks[y*width+x]; if(stack != null){ + if(stack.getItemDamage() == Util.WILDCARD) stack.setItemDamage(0); int xShow = gui.guiLeft+28+x*21; int yShow = gui.guiTop+23+y*21; if(!tooltip){ - if(stack.getItemDamage() == Util.WILDCARD) stack.setItemDamage(0); this.renderItem(gui, stack, xShow, yShow); } else{ diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrusherRecipe.java b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrusherRecipe.java index 00c9b9bec..4c8df7fc4 100644 --- a/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrusherRecipe.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageCrusherRecipe.java @@ -15,6 +15,7 @@ import ellpeck.actuallyadditions.booklet.InitBooklet; import ellpeck.actuallyadditions.recipe.CrusherRecipeManualRegistry; import ellpeck.actuallyadditions.util.ModUtil; import ellpeck.actuallyadditions.util.StringUtil; +import ellpeck.actuallyadditions.util.Util; import net.minecraft.item.ItemStack; public class PageCrusherRecipe extends BookletPage{ @@ -29,7 +30,7 @@ public class PageCrusherRecipe extends BookletPage{ @Override public void renderPre(GuiBooklet gui, int mouseX, int mouseY){ - if(recipe.firstOutput != null){ + if(recipe != null){ gui.mc.getTextureManager().bindTexture(GuiBooklet.resLoc); gui.drawTexturedModalRect(gui.guiLeft+37, gui.guiTop+20, 60, 180, 60, 60); } @@ -37,13 +38,13 @@ public class PageCrusherRecipe extends BookletPage{ @Override public ItemStack getItemStackForPage(){ - return recipe.firstOutput; + return this.recipe == null ? null : this.recipe.firstOutput; } @SuppressWarnings("unchecked") @Override public void render(GuiBooklet gui, int mouseX, int mouseY){ - if(recipe.firstOutput == null){ + if(recipe == null){ gui.unicodeRenderer.drawSplitString(StringUtil.localize("booklet."+ModUtil.MOD_ID_LOWER+".recipeDisabled"), gui.guiLeft+14, gui.guiTop+15, 115, 0); } @@ -62,6 +63,8 @@ public class PageCrusherRecipe extends BookletPage{ ItemStack stack = (j == 0 ? this.recipe.input : (j == 1 ? recipe.firstOutput : (j == 2 ? recipe.secondOutput : null))); if(stack != null){ + if(stack.getItemDamage() == Util.WILDCARD) stack.setItemDamage(0); + boolean tooltip = i == 1; int xShow = gui.guiLeft+37+(j == 0 ? 0 : (j == 1 ? 42 : (j == 2 ? 43 : 0))); diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/page/PageFurnace.java b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageFurnace.java index 9ae4102b0..9dc968832 100644 --- a/src/main/java/ellpeck/actuallyadditions/booklet/page/PageFurnace.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/page/PageFurnace.java @@ -14,6 +14,7 @@ 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.item.ItemStack; import net.minecraft.item.crafting.FurnaceRecipes; @@ -22,12 +23,17 @@ import java.util.Map; public class PageFurnace extends BookletPage{ private final ItemStack result; + private final ItemStack input; - public PageFurnace(int id, ItemStack result){ + public PageFurnace(int id, ItemStack input, ItemStack result){ super(id); this.result = result; + this.input = input; InitBooklet.pagesWithItemStackData.add(this); } + public PageFurnace(int id, ItemStack result){ + this(id, null, result); + } @Override public ItemStack getItemStackForPage(){ @@ -36,7 +42,7 @@ public class PageFurnace extends BookletPage{ @Override public void renderPre(GuiBooklet gui, int mouseX, int mouseY){ - if(this.getInputForOutput(this.result) != null){ + if(this.input != null || this.getInputForOutput(this.result) != null){ gui.mc.getTextureManager().bindTexture(GuiBooklet.resLoc); gui.drawTexturedModalRect(gui.guiLeft+37, gui.guiTop+20, 0, 180, 60, 60); } @@ -45,7 +51,7 @@ public class PageFurnace extends BookletPage{ @SuppressWarnings("unchecked") @Override public void render(GuiBooklet gui, int mouseX, int mouseY){ - ItemStack input = this.getInputForOutput(this.result); + ItemStack input = this.input != null ? this.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); } @@ -59,6 +65,7 @@ public class PageFurnace extends BookletPage{ for(int i = 0; i < 2; i++){ for(int x = 0; x < 2; x++){ ItemStack stack = x == 0 ? input : this.result; + if(stack.getItemDamage() == Util.WILDCARD) stack.setItemDamage(0); boolean tooltip = i == 1; int xShow = gui.guiLeft+37+1+x*40; diff --git a/src/main/java/ellpeck/actuallyadditions/crafting/BlockCrafting.java b/src/main/java/ellpeck/actuallyadditions/crafting/BlockCrafting.java index aba050fc8..b8170276a 100644 --- a/src/main/java/ellpeck/actuallyadditions/crafting/BlockCrafting.java +++ b/src/main/java/ellpeck/actuallyadditions/crafting/BlockCrafting.java @@ -48,6 +48,7 @@ public class BlockCrafting{ public static IRecipe recipeCoffeeMachine; public static IRecipe recipeCrusher; public static IRecipe recipeDoubleCrusher; + public static IRecipe recipeFurnace; public static void init(){ @@ -395,6 +396,7 @@ public class BlockCrafting{ 'R', new ItemStack(Blocks.furnace), 'F', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.STONE_CASING.ordinal()), 'P', "ingotBrick")); + recipeFurnace = Util.lastIRecipe(); } //Feeder diff --git a/src/main/java/ellpeck/actuallyadditions/crafting/ItemCrafting.java b/src/main/java/ellpeck/actuallyadditions/crafting/ItemCrafting.java index 5dff36794..258d20eae 100644 --- a/src/main/java/ellpeck/actuallyadditions/crafting/ItemCrafting.java +++ b/src/main/java/ellpeck/actuallyadditions/crafting/ItemCrafting.java @@ -35,15 +35,13 @@ public class ItemCrafting{ public static IRecipe recipePhantomConnector; public static IRecipe recipeCoil; public static IRecipe recipeCoilAdvanced; - + public static IRecipe recipeBook; public static void init(){ //Booklet GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(InitItems.itemLexicon), new ItemStack(InitItems.itemCanolaSeed), new ItemStack(Items.paper))); - GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(InitItems.itemLexicon), new ItemStack(InitItems.itemCoffeeSeed), new ItemStack(Items.paper))); - GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(InitItems.itemLexicon), new ItemStack(InitItems.itemRiceSeed), new ItemStack(Items.paper))); - GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(InitItems.itemLexicon), new ItemStack(InitItems.itemFlaxSeed), new ItemStack(Items.paper))); + recipeBook = Util.lastIRecipe(); //Rice Stuff if(ConfigCrafting.RICE_GADGETS.isEnabled()){ diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/GuiHandler.java b/src/main/java/ellpeck/actuallyadditions/inventory/GuiHandler.java index 47601fe71..843938b3e 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/GuiHandler.java +++ b/src/main/java/ellpeck/actuallyadditions/inventory/GuiHandler.java @@ -140,7 +140,7 @@ public class GuiHandler implements IGuiHandler{ case CLOUD: return new GuiSmileyCloud(tile, x, y, z, world); case BOOK: - return new GuiBooklet(); + return new GuiBooklet(entityPlayer); default: return null; } diff --git a/src/main/java/ellpeck/actuallyadditions/proxy/ClientProxy.java b/src/main/java/ellpeck/actuallyadditions/proxy/ClientProxy.java index 639b68882..0453d5c97 100644 --- a/src/main/java/ellpeck/actuallyadditions/proxy/ClientProxy.java +++ b/src/main/java/ellpeck/actuallyadditions/proxy/ClientProxy.java @@ -13,6 +13,9 @@ package ellpeck.actuallyadditions.proxy; import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.registry.VillagerRegistry; import ellpeck.actuallyadditions.blocks.InitBlocks; import ellpeck.actuallyadditions.blocks.render.*; @@ -23,25 +26,31 @@ import ellpeck.actuallyadditions.tile.*; import ellpeck.actuallyadditions.update.UpdateChecker; import ellpeck.actuallyadditions.util.AssetUtil; import ellpeck.actuallyadditions.util.ModUtil; +import ellpeck.actuallyadditions.util.PersistantVariables; import ellpeck.actuallyadditions.util.Util; import net.minecraft.item.Item; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.MinecraftForgeClient; +import java.io.File; + @SuppressWarnings("unused") public class ClientProxy implements IProxy{ @Override - public void preInit(){ + public void preInit(FMLPreInitializationEvent event){ ModUtil.LOGGER.info("PreInitializing ClientProxy..."); if(ConfigBoolValues.DO_UPDATE_CHECK.isEnabled()){ new UpdateChecker().init(); } + + PersistantVariables.setTheFile(new File(event.getModConfigurationDirectory().getParent(), ModUtil.MOD_ID+"Data.dat")); + } @Override - public void init(){ + public void init(FMLInitializationEvent event){ ModUtil.LOGGER.info("Initializing ClientProxy..."); AssetUtil.COMPOST_RENDER_ID = RenderingRegistry.getNextAvailableRenderId(); @@ -75,7 +84,7 @@ public class ClientProxy implements IProxy{ } @Override - public void postInit(){ + public void postInit(FMLPostInitializationEvent event){ ModUtil.LOGGER.info("PostInitializing ClientProxy..."); } } diff --git a/src/main/java/ellpeck/actuallyadditions/proxy/IProxy.java b/src/main/java/ellpeck/actuallyadditions/proxy/IProxy.java index 3fe74bfca..af8b27ff5 100644 --- a/src/main/java/ellpeck/actuallyadditions/proxy/IProxy.java +++ b/src/main/java/ellpeck/actuallyadditions/proxy/IProxy.java @@ -10,11 +10,15 @@ package ellpeck.actuallyadditions.proxy; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; + public interface IProxy{ - void preInit(); + void preInit(FMLPreInitializationEvent event); - void init(); + void init(FMLInitializationEvent event); - void postInit(); + void postInit(FMLPostInitializationEvent event); } diff --git a/src/main/java/ellpeck/actuallyadditions/proxy/ServerProxy.java b/src/main/java/ellpeck/actuallyadditions/proxy/ServerProxy.java index 242666616..69a0cd35b 100644 --- a/src/main/java/ellpeck/actuallyadditions/proxy/ServerProxy.java +++ b/src/main/java/ellpeck/actuallyadditions/proxy/ServerProxy.java @@ -10,23 +10,26 @@ package ellpeck.actuallyadditions.proxy; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; import ellpeck.actuallyadditions.util.ModUtil; @SuppressWarnings("unused") public class ServerProxy implements IProxy{ @Override - public void preInit(){ + public void preInit(FMLPreInitializationEvent event){ ModUtil.LOGGER.info("PreInitializing ServerProxy..."); } @Override - public void init(){ + public void init(FMLInitializationEvent event){ ModUtil.LOGGER.info("Initializing ServerProxy..."); } @Override - public void postInit(){ + public void postInit(FMLPostInitializationEvent event){ ModUtil.LOGGER.info("PostInitializing ServerProxy..."); } } diff --git a/src/main/java/ellpeck/actuallyadditions/util/PersistantVariables.java b/src/main/java/ellpeck/actuallyadditions/util/PersistantVariables.java new file mode 100644 index 000000000..8ec8ba09c --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/util/PersistantVariables.java @@ -0,0 +1,129 @@ +/* + * This file ("PersistantVariables.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.util; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.booklet.BookletChapter; +import ellpeck.actuallyadditions.booklet.BookletIndexEntry; +import ellpeck.actuallyadditions.booklet.GuiBooklet; +import ellpeck.actuallyadditions.booklet.InitBooklet; +import ellpeck.actuallyadditions.booklet.page.IBookletPage; +import net.minecraft.client.Minecraft; +import net.minecraft.nbt.CompressedStreamTools; +import net.minecraft.nbt.NBTTagCompound; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; + +@SideOnly(Side.CLIENT) +public class PersistantVariables{ + + private static File theFile; + + public static void saveBookPage(BookletIndexEntry entry, BookletChapter chapter, IBookletPage page, int pageInIndex){ + NBTTagCompound compound = getCompound(); + if(compound != null){ + compound.setInteger(getName("Entry"), entry == null ? -1 : InitBooklet.entries.indexOf(entry)); + compound.setInteger(getName("Chapter"), entry == null || chapter == null ? -1 : entry.chapters.indexOf(chapter)); + compound.setInteger(getName("Page"), page == null ? -1 : page.getID()); + compound.setInteger(getName("PageInIndex"), pageInIndex); + writeCompoundToFile(compound); + } + } + + public static void openLastBookPage(GuiBooklet gui){ + NBTTagCompound compound = getCompound(); + if(compound != null){ + if(compound.hasKey(getName("Entry"))){ + int entry = compound.getInteger(getName("Entry")); + int chapter = compound.getInteger(getName("Chapter")); + int page = compound.getInteger(getName("Page")); + + BookletIndexEntry currentIndexEntry = entry == -1 ? null : InitBooklet.entries.get(entry); + BookletChapter currentChapter = chapter == -1 || entry == -1 ? null : currentIndexEntry.chapters.get(chapter); + IBookletPage currentPage = chapter == -1 ? null : currentChapter.pages[page-1]; + int pageInIndex = compound.getInteger(getName("PageInIndex")); + + gui.openIndexEntry(currentIndexEntry, pageInIndex, true); + if(currentChapter != null){ + gui.openChapter(currentChapter, currentPage); + } + } + else{ + gui.openIndexEntry(null, 1, true); + } + } + } + + public static void setBoolean(String name, boolean bool){ + NBTTagCompound compound = getCompound(); + if(compound != null){ + compound.setBoolean(getName(name), bool); + writeCompoundToFile(compound); + } + } + + private static String getName(String name){ + return (Minecraft.getMinecraft().isIntegratedServerRunning() ? Minecraft.getMinecraft().getIntegratedServer().getWorldName() : Minecraft.getMinecraft().func_147104_D().serverIP)+"-"+name; + } + + public static boolean getBoolean(String name){ + NBTTagCompound compound = getCompound(); + return compound != null && compound.getBoolean(getName(name)); + } + + private static File getTheFile() throws Exception{ + if(!theFile.exists()){ + theFile.createNewFile(); + } + return theFile; + } + + public static void setTheFile(File file){ + theFile = file; + } + + private static NBTTagCompound getCompound(){ + try{ + return getCompound(getTheFile()); + } + catch(Exception e){ + ModUtil.LOGGER.fatal("Couldn't read Persistant Variable!", e); + return null; + } + } + + private static NBTTagCompound getCompound(File file) throws Exception{ + try{ + return CompressedStreamTools.readCompressed(new FileInputStream(file)); + } + catch(Exception e){ + return createNewCompound(file); + } + } + + private static NBTTagCompound createNewCompound(File file) throws Exception{ + NBTTagCompound compound = new NBTTagCompound(); + CompressedStreamTools.writeCompressed(compound, new FileOutputStream(file)); + return getCompound(file); + } + + private static void writeCompoundToFile(NBTTagCompound compound){ + try{ + CompressedStreamTools.writeCompressed(compound, new FileOutputStream(getTheFile())); + } + catch(Exception e){ + ModUtil.LOGGER.fatal("Couldn't write Persistant Variable!", e); + } + } +} diff --git a/src/main/resources/assets/actuallyadditions/lang/en_US.lang b/src/main/resources/assets/actuallyadditions/lang/en_US.lang index 75ddb2b28..ca63e7230 100644 --- a/src/main/resources/assets/actuallyadditions/lang/en_US.lang +++ b/src/main/resources/assets/actuallyadditions/lang/en_US.lang @@ -370,9 +370,9 @@ booklet.actuallyadditions.indexEntry.allAndSearch.name=All Items and Search booklet.actuallyadditions.indexEntry.functionalRF.name=Functional Blocks (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 Recipe booklet.actuallyadditions.chapter.foods.name=Food - booklet.actuallyadditions.chapter.cloud.name=Smiley Cloud booklet.actuallyadditions.chapter.cloud.text.1=A Smiley Cloud is a neat little block that you can put down in the world. When in place, it will hover around across the ground, though staying on the block you placed it in. When right-clicking the cloud, it will open a GUI that enables you to change its name, and thus, its appearance if you do it right. On the next page, you can find some examples you can try out. booklet.actuallyadditions.chapter.cloud.text.2=The Crafting Recipe is shown above. If you want to know what certain name changes do, try naming a cloud "Ellpeck", "Glenthor" or "AcidBlues". @@ -413,4 +413,10 @@ booklet.actuallyadditions.chapter.esd.text.3=The Advanced ESD has a fil booklet.actuallyadditions.chapter.coffeeMachine.name=Coffee Machine booklet.actuallyadditions.chapter.coffeeMachine.text.1=The Coffee Machine is a very powerful block that is basically a extended brewing stand. After adding Coffee Beans, a Cup and some RF and Water, you can add up to 8 different Items to the extra slots to give your coffee potion effects of your choosing. When you have added all of the items for the effects you want, just press the OK-button or give the machine a redstone signal. booklet.actuallyadditions.chapter.coffeeMachine.text.2=Sugar > Speed 30s Magma Cream > Fire Resistance 20s Pufferfish > Water Breathing 10s Golden Carrot > Night Vision 30s Ghast Tear > Regeneration 5s Blaze Powder > Strength 15s Fermented Spider Eye > Invisibility 25s -booklet.actuallyadditions.chapter.coffeeMachine.text.3=Every effect has a default amount of time it lasts for and a maximum amount that can be put into a coffee. The default amplifier of the effects is always I. A bucket of milk (or a glass of soy milk if you have HarvestCraft installed!) causes all previously added effects (meaning all items added in slots with smaller numbers!) to last 2 Minutes longer, but lose one amplifier level, meaning that you always have to add two of one item before you add a bucket of milk. \ No newline at end of file +booklet.actuallyadditions.chapter.coffeeMachine.text.3=Every effect has a default amount of time it lasts for and a maximum amount that can be put into a coffee. The default amplifier of the effects is always I. A bucket of milk (or a glass of soy milk if you have HarvestCraft installed!) causes all previously added effects (meaning all items added in slots with smaller numbers!) to last 2 Minutes longer, but lose one amplifier level, meaning that you always have to add two of one item before you add a bucket of milk. + +booklet.actuallyadditions.chapter.crusher.name=Crushers +booklet.actuallyadditions.chapter.crusher.text.1=The Crusher is a machine that uses RF to double ores, meaning when you put in any ore block, it gets broken down to two dust items which can be smelted in a furnace afterwards. See all of the recipes on the following pages. + +booklet.actuallyadditions.chapter.furnaceDouble.name=Double Furnace +booklet.actuallyadditions.chapter.furnaceDouble.text.1=The Double Furnace is a block that works exactly like a furnace, but it can smelt two items at a time and uses RF to work. See all of the recipes on the following pages. \ No newline at end of file