deadrecon98 Posted July 15, 2013 Posted July 15, 2013 Im not sure if it's my config or what but my items keep overriding each other. Core class: package cwm; import java.io.File; import javax.swing.text.JTextComponent.KeyBinding; import net.java.games.input.Keyboard; import net.minecraft.block.Block; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import cpw.mods.fml.client.registry.KeyBindingRegistry; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.Init; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.Mod.PostInit; import cpw.mods.fml.common.Mod.PreInit; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; @Mod(modid="CWM",name="Cyph's World Of Magic",version="0.0.1") @NetworkMod(clientSideRequired=true,serverSideRequired=false) public class CWM { @Instance("CyphScape Core") public static CWM instance = new CWM(); public static File configFile; @SidedProxy(clientSide = "cwm.clientSide", serverSide = "cwm.serverSide") public static serverSide proxy; public static CreativeTabs tabCWM = new tabCyphereionsWorldOfMagic(CreativeTabs.getNextID(),"tabCWM"); public static Item Cloth; public static Item ResearchBook; @PreInit() public void PreInitTutorial(FMLPreInitializationEvent e){ Cfg cc = new Cfg(); Cloth = new ItemCloth(cc.itemClothID); ResearchBook = new ItemResearchBook(cc.researchBookID); LanguageRegistry.instance().addStringLocalization("itemGroup.tabCWM","Cyphereion's World of Magic"); Cfg.loadConfig(e); //rubySword = new ItemTutorialSword(cc.toolRubySwordID, rubyMat, 8, "DeverionXRubySword"); //blockRuby = new BlockRuby(cc.blockRubyID); } @Init public void load(FMLInitializationEvent event) { GameRegistry.addShapelessRecipe(new ItemStack(Cloth, 1, 0), Item.silk, Item.silk, Item.silk, Item.silk, Item.silk); GameRegistry.addRecipe(new ItemStack(ResearchBook, 1), "G G"," B ","G G", Character.valueOf('B'), Item.book, Character.valueOf('G'), Item.ingotGold); LanguageRegistry.addName(Cloth, "Cloth"); LanguageRegistry.addName(ResearchBook, "Research Book"); proxy.registerRenderersThings(); } @PostInit public void postInit(){ configFile = proxy.initConfigs(); } } Config: package cwm; import net.minecraft.item.Item; import net.minecraftforge.common.Configuration; import net.minecraftforge.common.Property; import cpw.mods.fml.common.event.FMLPreInitializationEvent; public class Cfg { //Items public static int itemClothID; public static int researchBookID; //General public static void loadConfig(FMLPreInitializationEvent e){ Configuration config = new Configuration(e.getSuggestedConfigurationFile()); config.load(); config.addCustomCategoryComment(config.CATEGORY_GENERAL, "Cheats! (Well, Mostly)"); Property clothItem; Property researchBookItem; clothItem = config.getItem("Cloth", 9000); clothItem.comment = ItemCloth.Comment; itemClothID = clothItem.getInt(); researchBookItem = config.getItem("Research Book", 9001); researchBookItem.comment = ItemResearchBook.Comment; researchBookID = researchBookItem.getInt(); //blockRubyID = config.getBlock("Ruby Block", 300).getInt(); ItemCloth.isClothResearched = config.get(config.CATEGORY_GENERAL, "Is Cloth researched?", false).getBoolean(false); ItemResearchBook.isResearchBookResearched = config.get(config.CATEGORY_GENERAL, "Is Research Book Researched?", false).getBoolean(false); config.save(); } } Quote
mrkirby153 Posted July 16, 2013 Posted July 16, 2013 Define "Overwrite". Is one but not the other showing up? Are the names the same? Also, why would you store if something is researched in the config file? You know that the config file is global right? Edit: Are the configuration settings in the config file overwriting each other? Quote http://i.imgur.com/gWwyMMO.jpg[/img]
deadrecon98 Posted July 16, 2013 Author Posted July 16, 2013 Define "Overwrite". Is one but not the other showing up? Are the names the same? Also, why would you store if something is researched in the config file? You know that the config file is global right? Edit: Are the configuration settings in the config file overwriting each other? Ex: I made cloth it's 5 string to craft and it has a unique id and picture. Then I made a book, Same thing but different recipe. Now the book has taken every single property of the cloth except the picture and the description and the cloth no longer works. I'm honestly not sure what the error is here but that's all I know. If needed I can take some screenshots. Quote
mrkirby153 Posted July 16, 2013 Posted July 16, 2013 Code? (Of ItemCloth and ItemBook) Quote http://i.imgur.com/gWwyMMO.jpg[/img]
deadrecon98 Posted July 16, 2013 Author Posted July 16, 2013 Code? (Of ItemCloth and ItemBook) Heres the book. The cloth is the same except for the nbt saving method. package cwm; import java.util.List; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; public class ItemResearchBook extends Item { private int index; public static String Comment = "Used for basic research."; public static boolean isResearchBookResearched; public ItemResearchBook(int par1) { super(par1); this.setMaxStackSize(64); this.setCreativeTab(CWM.tabCWM); } public void onCreated(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer){ NBTTagCompound nbt = Config.getTagCompoundInFile(Config.getWorldConfig(par2World)); nbt.setInteger("MaxMana", 25); nbt.setInteger("CurrentMana", nbt.getInteger("CurrentMana" + 1)); } public void onItemRightClick(EntityPlayer par1EntityPlayer, World par2World){ NBTTagCompound nbt = Config.getTagCompoundInFile(Config.getWorldConfig(par2World)); par1EntityPlayer.addChatMessage("Current Mana: " + nbt.getInteger("CurrentMana")); } @SideOnly(Side.CLIENT) public void registerIcons(IconRegister iconRegister) { if(itemID == CWM.ResearchBook.itemID) { this.itemIcon = iconRegister.registerIcon("CWM:ItemResearchBook"); } } public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { par3List.add("Kutumika kwa ajili ya utafiti wa msingi."); par3List.add("vipengele:"); par3List.add("uchawi x1"); par3List.add("maarifa x2"); par3List.add("ugumu x1"); if(isResearchBookResearched == true){ par3List.clear(); par3List.add("Used for basic research."); par3List.add("Elements:"); par3List.add("Magic x1"); par3List.add("Knowledge x2"); par3List.add("Hardness x1"); } } } Quote
mrkirby153 Posted July 16, 2013 Posted July 16, 2013 Try adding this.setUnlocalizedName(NAMEHERE) to both the book and cloth constructors. Also, do you know what would be really cool? If you somehow used the enchanting font kinda like thaumcraft Quote http://i.imgur.com/gWwyMMO.jpg[/img]
deadrecon98 Posted July 16, 2013 Author Posted July 16, 2013 Try adding this.setUnlocalizedName(NAMEHERE) to both the book and cloth constructors. Also, do you know what would be really cool? If you somehow used the enchanting font kinda like thaumcraft Oh all the symbols? And it still didn't work Quote
mrkirby153 Posted July 16, 2013 Posted July 16, 2013 Do you have screenshots? And is your mod open source? And if so, can I please see the link? Quote http://i.imgur.com/gWwyMMO.jpg[/img]
deadrecon98 Posted July 16, 2013 Author Posted July 16, 2013 Do you have screenshots? And is your mod open source? And if so, can I please see the link? Mmmk Pictures: https://dl.dropboxusercontent.com/u/73396944/2013-07-16_16.03.11.png[/img] https://dl.dropboxusercontent.com/u/73396944/2013-07-16_16.03.37.png[/img] https://dl.dropboxusercontent.com/u/73396944/2013-07-16_16.03.45.png[/img] Src: https://github.com/deadrecon98/CWMCode Quote
mrkirby153 Posted July 16, 2013 Posted July 16, 2013 I have a solution! Move Cfg.loadConfig(e); to right after Cfg cc = new Cfg(); The Final CWM Class should look like this: package cwm; import java.io.File; import javax.swing.text.JTextComponent.KeyBinding; import net.java.games.input.Keyboard; import net.minecraft.block.Block; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import cpw.mods.fml.client.registry.KeyBindingRegistry; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.Init; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.Mod.PostInit; import cpw.mods.fml.common.Mod.PreInit; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; @Mod(modid="CWM",name="Cyph's World Of Magic",version="0.0.1") @NetworkMod(clientSideRequired=true,serverSideRequired=false) public class CWM { @Instance("CyphScape Core") public static CWM instance = new CWM(); public static File configFile; @SidedProxy(clientSide = "cwm.clientSide", serverSide = "cwm.serverSide") public static serverSide proxy; public static CreativeTabs tabCWM = new tabCyphereionsWorldOfMagic(CreativeTabs.getNextID(),"tabCWM"); public static Item Cloth; public static Item ResearchBook; @PreInit() public void PreInitTutorial(FMLPreInitializationEvent e){ Cfg.loadConfig(e); Cfg cc = new Cfg(); Cloth = new ItemCloth(cc.itemClothID); ResearchBook = new ItemResearchBook(cc.researchBookID); } @Init public void load(FMLInitializationEvent event) { Cloth.setUnlocalizedName("CWM_Cloth"); ResearchBook.setUnlocalizedName("CWM_ResearchBook"); GameRegistry.addShapelessRecipe(new ItemStack(Cloth, 1, 0), Item.silk, Item.silk, Item.silk, Item.silk, Item.silk); GameRegistry.addRecipe(new ItemStack(ResearchBook, 1), "G G"," B ","G G", Character.valueOf('B'), Item.book, Character.valueOf('G'), Item.ingotGold); LanguageRegistry.addName(Cloth, "Cloth"); LanguageRegistry.addName(ResearchBook, "Research Book"); LanguageRegistry.instance().addStringLocalization("itemGroup.tabCWM","Cyphereion's World of Magic"); proxy.registerRenderersThings(); } @PostInit public void postInit(){ configFile = proxy.initConfigs(); } } Here's Why: Originally, you were constructing Items using the default values of the variable (256 i think). Then after the Item was created, you were setting the variables to their proper values. Remember, Java reads code from top to bottom Also, why are you still using @PreInit, @PostInit, @Init, ect.? They are depreciated. Change the @Init annotations to @EventHandler. Quote http://i.imgur.com/gWwyMMO.jpg[/img]
deadrecon98 Posted July 16, 2013 Author Posted July 16, 2013 I have a solution! Move Cfg.loadConfig(e); to right after Cfg cc = new Cfg(); The Final CWM Class should look like this: package cwm; import java.io.File; import javax.swing.text.JTextComponent.KeyBinding; import net.java.games.input.Keyboard; import net.minecraft.block.Block; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import cpw.mods.fml.client.registry.KeyBindingRegistry; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.Init; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.Mod.PostInit; import cpw.mods.fml.common.Mod.PreInit; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; @Mod(modid="CWM",name="Cyph's World Of Magic",version="0.0.1") @NetworkMod(clientSideRequired=true,serverSideRequired=false) public class CWM { @Instance("CyphScape Core") public static CWM instance = new CWM(); public static File configFile; @SidedProxy(clientSide = "cwm.clientSide", serverSide = "cwm.serverSide") public static serverSide proxy; public static CreativeTabs tabCWM = new tabCyphereionsWorldOfMagic(CreativeTabs.getNextID(),"tabCWM"); public static Item Cloth; public static Item ResearchBook; @PreInit() public void PreInitTutorial(FMLPreInitializationEvent e){ Cfg.loadConfig(e); Cfg cc = new Cfg(); Cloth = new ItemCloth(cc.itemClothID); ResearchBook = new ItemResearchBook(cc.researchBookID); } @Init public void load(FMLInitializationEvent event) { Cloth.setUnlocalizedName("CWM_Cloth"); ResearchBook.setUnlocalizedName("CWM_ResearchBook"); GameRegistry.addShapelessRecipe(new ItemStack(Cloth, 1, 0), Item.silk, Item.silk, Item.silk, Item.silk, Item.silk); GameRegistry.addRecipe(new ItemStack(ResearchBook, 1), "G G"," B ","G G", Character.valueOf('B'), Item.book, Character.valueOf('G'), Item.ingotGold); LanguageRegistry.addName(Cloth, "Cloth"); LanguageRegistry.addName(ResearchBook, "Research Book"); LanguageRegistry.instance().addStringLocalization("itemGroup.tabCWM","Cyphereion's World of Magic"); proxy.registerRenderersThings(); } @PostInit public void postInit(){ configFile = proxy.initConfigs(); } } Here's Why: Originally, you were constructing Items using the default values of the variable (256 i think). Then after the Item was created, you were setting the variables to their proper values. Remember, Java reads code from top to bottom Also, why are you still using @PreInit, @PostInit, @Init, ect.? They are depreciated. Change the @Init annotations to @EventHandler. Why can't they just keep everything the way it was before? And btw that did fix it! Thanks loads! Quote
mrkirby153 Posted July 16, 2013 Posted July 16, 2013 About the annotations? They are deprecated. Meaning they probably will be removed soon and are just there for compatability Quote http://i.imgur.com/gWwyMMO.jpg[/img]
deadrecon98 Posted July 16, 2013 Author Posted July 16, 2013 About the annotations? They are deprecated. Meaning they probably will be removed soon and are just there for compatability Just overall lol they keep changing stuff. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.