mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-12-26 21:09:23 +01:00
Made the page that was open stay, added persistant variables
This commit is contained in:
parent
390ea2a2a6
commit
a3eb4721b3
16 changed files with 262 additions and 34 deletions
|
@ -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.");
|
||||
}
|
||||
|
|
|
@ -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<IBookletPage> list = new ArrayList<IBookletPage>();
|
||||
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()]);
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
|
|
|
@ -28,12 +28,16 @@ public class InitBooklet{
|
|||
public static ArrayList<BookletIndexEntry> entries = new ArrayList<BookletIndexEntry>();
|
||||
public static ArrayList<IBookletPage> pagesWithItemStackData = new ArrayList<IBookletPage>();
|
||||
|
||||
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));
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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{
|
||||
|
|
|
@ -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)));
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()){
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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...");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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...");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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 <item>Smiley Cloud<r> 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 <imp>"Ellpeck"<r>, <imp>"Glenthor"<r> or <imp>"AcidBlues"<r>.
|
||||
|
@ -413,4 +413,10 @@ booklet.actuallyadditions.chapter.esd.text.3=The <item>Advanced ESD<r> has a fil
|
|||
booklet.actuallyadditions.chapter.coffeeMachine.name=Coffee Machine
|
||||
booklet.actuallyadditions.chapter.coffeeMachine.text.1=The <item>Coffee Machine<r> is a very powerful block that is basically a <item>extended brewing stand<r>. After adding <item>Coffee Beans<r>, a <item>Cup<r> and some <imp>RF<r> and <imp>Water<r>, you can add up to 8 different Items to the extra slots to <imp>give your coffee potion effects<r> 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 <n><n>Magma Cream > Fire Resistance 20s <n><n>Pufferfish > Water Breathing 10s <n><n>Golden Carrot > Night Vision 30s <n><n>Ghast Tear > Regeneration 5s <n><n>Blaze Powder > Strength 15s <n><n>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. <n>A <item>bucket of milk<r> (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 <imp>2 Minutes longer<r>, but <imp>lose one amplifier level<r>, meaning that you always have to add two of one item before you add a bucket of milk.
|
||||
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. <n>A <item>bucket of milk<r> (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 <imp>2 Minutes longer<r>, but <imp>lose one amplifier level<r>, 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 <item>Crusher<r> is a machine that uses <imp>RF<r> to <imp>double ores<r>, meaning when you put in any ore block, it gets broken down to two dust items which can be <imp>smelted in a furnace<r> afterwards. <n>See all of the recipes on the following pages.
|
||||
|
||||
booklet.actuallyadditions.chapter.furnaceDouble.name=Double Furnace
|
||||
booklet.actuallyadditions.chapter.furnaceDouble.text.1=The <item>Double Furnace<r> is a block that works exactly <imp>like a furnace<r>, but it can smelt <imp>two items at a time<r> and uses <imp>RF<r> to work. <n>See all of the recipes on the following pages.
|
Loading…
Reference in a new issue