DrEinsteinium Posted August 7, 2013 Posted August 7, 2013 Hi guys, I've got a pretty small problem while working with NEI to add a new keybind to my mod WikiLink. I've registered the key binding matching what is in chickenbones's files and this what I have: API.addKeyBind("gui.wiki", Keyboard.KEY_W); And since chicken_bones doesn't register the name of the keybind for some reason, it shows up like this ingame: What should I do? Do I have to create my own language file or is there a method/way I can add the name without it? I don't really want to have to make a language file, because this button would be the only thing in it.. Thanks Quote Follow me on twitter! @keepablock Read up on whats new! www.catacombs.co http://electronic-chronic.com/assets/keep-a-block/wikilink/wikilink_logo.png[/img]
GotoLink Posted August 7, 2013 Posted August 7, 2013 Maybe giving "wiki" as first argument would work ? Just saying, I didn't know this API existed till now. If you are sure about this API being necessary, you can suggest the author to add a API.addKeyBindWithName(args) method. (I personally don't think you need an external API to make this KeyBind, unless it gives special properties ?) Quote
DrEinsteinium Posted August 7, 2013 Author Posted August 7, 2013 Well since I am adding integration for NEI into my mod WikiLink, I need to use chicken_bones' API in order to add another keybinding to his mod. Essentially, what I'm trying to accomplish is this: 1. While NEI and WikiLink are both installed at the same time, WikiLink will add a key binding to NEI just like the preexisting recipe finder but with different functions. I will have to figure out how to extend NEI's API without making my mod totally dependent on NEI. I still want it to be a standalone mod. 2. Whenever the key is pressed while the mouse is hovering an item, it will get two things from the item the mouse is hovering: The name of the item and the @modid of the mod that it came from. 3. Now that WikiLink has the information it needs, it can check to see if the @modid corresponds with a wiki already in it's database. If so, it will open the wiki of the mod with the item name as the search term. If the wiki is smart enough, it will even open the page of the item. It all seems like a simple task but after trying to work with NEI's API last night I was having trouble getting it going. It may not help that I'm a novice programmer, but once I get past this API part I can persevere on my own with the rest of the features. Quote Follow me on twitter! @keepablock Read up on whats new! www.catacombs.co http://electronic-chronic.com/assets/keep-a-block/wikilink/wikilink_logo.png[/img]
GotoLink Posted August 7, 2013 Posted August 7, 2013 On the "standalone" part, I can safely say you will need reflection to accomplish this. Depending on how well written the API is, it could be pretty simple, that is, if you can subscribe to an event or call back for your key binding without actually implementing an interface. I must say your idea is interesting. You could even provide an API with some IWikiLinkable interface so that modders add their blocks/items wiki link. Quote
DrEinsteinium Posted August 7, 2013 Author Posted August 7, 2013 Thanks for mentioning reflection. I didn't realize this existed until now. I'm still learning all of the tricks of the trait. And do you mean an interface where the blocks and items are all linked to a wiki? The NEI integration was supposed to accomplish this, but now NEI is looking like a problem. Now that you mention this though, I think that adding a system for this without using NEI is possible. Is there a way to get the mod id that an ItemStack is from? Such as ItemStack.getModId() or something lol. Quote Follow me on twitter! @keepablock Read up on whats new! www.catacombs.co http://electronic-chronic.com/assets/keep-a-block/wikilink/wikilink_logo.png[/img]
hydroflame Posted August 7, 2013 Posted August 7, 2013 no but the interface could force the Item and Block to implement a method called "getMod" or wtv and then youd have access super easy btw your mod is a f***ing great idea can i haz ? Quote how to debug 101:http://www.minecraftforge.net/wiki/Debug_101 -hydroflame, author of the forge revolution-
DrEinsteinium Posted August 7, 2013 Author Posted August 7, 2013 There's a 1.6.2 and a 1.5.2 backport if you click the picture in my signature. My source is also on GitHub, but let me warn you: It's bad... Quote Follow me on twitter! @keepablock Read up on whats new! www.catacombs.co http://electronic-chronic.com/assets/keep-a-block/wikilink/wikilink_logo.png[/img]
GotoLink Posted August 7, 2013 Posted August 7, 2013 Thanks for mentioning reflection. I didn't realize this existed until now. I'm still learning all of the tricks of the trait. And do you mean an interface where the blocks and items are all linked to a wiki? The NEI integration was supposed to accomplish this, but now NEI is looking like a problem. Now that you mention this though, I think that adding a system for this without using NEI is possible. Is there a way to get the mod id that an ItemStack is from? Such as ItemStack.getModId() or something lol. I was thinking about something like this: public interface IWikiLinkable{ String getWikiLink(); String[] getDisplayInfo(); } For modders to implement items and blocks. As for mods information: Loader.instance().getIndexedModList(); Returns an immutable map of ModContainer (an interface in cpw.mods.fml.common package) key-ed by their modid. Quote
DrEinsteinium Posted August 7, 2013 Author Posted August 7, 2013 Thanks for mentioning reflection. I didn't realize this existed until now. I'm still learning all of the tricks of the trait. And do you mean an interface where the blocks and items are all linked to a wiki? The NEI integration was supposed to accomplish this, but now NEI is looking like a problem. Now that you mention this though, I think that adding a system for this without using NEI is possible. Is there a way to get the mod id that an ItemStack is from? Such as ItemStack.getModId() or something lol. I was thinking about something like this: public interface IWikiLinkable{ String getWikiLink(); String[] getDisplayInfo(); } For modders to implement items and blocks. As for mods information: Loader.instance().getIndexedModList(); Returns an immutable map of ModContainer (an interface in cpw.mods.fml.common package) key-ed by their modid. I still don't understand what that interface would do. I already have an interface in my mod that other modders may access to add their mods to my wiki database, if that's what you mean. My whole problem is linking the mod items to the database. When WikiLink's PluginManager finds a new mod that is implementing my interface. Upon start up, it will load this information: keyList.add(plugin.getWikiKey()); nameList.add(plugin.getWikiName()); domainList.add(plugin.getWikiDomain()); softwareList.add(plugin.getWikiSoftware()); The getWikiKey method returns the acronym users currently use to access a wiki. It's like the access code. So, /wiki <key> <search term> The getWikiName method returns the english name of the wiki. Eg: "Example Wiki" The getWikiDomain method returns the website that the wiki is loaded on. Eg: "minecraftwiki.net" Finally, the getWikiSoftware method returns the type of wiki it is. Eg MediaWiki, Wikia, DokuWiki, ect Each mod being added goes through this loop once, and all of their data is added to the list simultaneously so the indexes all correspond with each other. Eg: Mod 1 loads, and takes up getWikiKey[0], getWikiName[0], getWikiDomain[0], getWikiSoftware[0]. Mod 2 loads, and takes up getWikiKey[1], getWikiName[1], getWikiDomain[1], getWikiSoftware[1]. And so on. So now that my mod has the extra wikis in it's database, it can better suit the needs of the user when they are looking for something. When the user enters the command /wiki <key> <search term> WikiLink will match the index of the key with the indexes of the other lists and build the hyperlink accordingly. Once done it will send the hyperlink to the browser handler and open up the wiki page in your computers default browser. (Untested for Linux / Unix, but it should work) -- That's the run down of how my mod works currently, but this is how I want it to work: It will go through the same steps and all of the current features will be enabled, but I want an extra and easier way of getting a mod's wiki open. If possible, I plan to get the @modId of the item someone wants to look up. Now how the player declares the item they want to look up, I haven't decided yet. This is why I wanted to extend NEI's already built system, but it appears to be more trouble than I thought and I'm too much of a newbie of a programmer to figure it out. I was planning on just looking at the way the recipe system works and changing the methods, but chicken_bones' code is much too complex for my skill level. But, after the @modId is obtained, it can be matched with one of the mod wikis in my database. If no match is found then it will take you to the default wiki. So I guess the question is: Is there a method that I can use to get the mod an item came from? Quote Follow me on twitter! @keepablock Read up on whats new! www.catacombs.co http://electronic-chronic.com/assets/keep-a-block/wikilink/wikilink_logo.png[/img]
GotoLink Posted August 7, 2013 Posted August 7, 2013 Well my suggested interface would be Item/Block specific, so that huge mods with dozens of items and a huge wiki would actually return a direct link for each one. This is an addition rather than a change of your current API With an item name and a modid, you may do something like: ItemStack searchedItem = GameData.findItemStack(modid, name); if(searchedItem!=null && searchedItem.getItem() instanceof IWikiLinkable) //get specific item wiki link else //get global mod wiki link Quote
DrEinsteinium Posted August 7, 2013 Author Posted August 7, 2013 Well my suggested interface would be Item/Block specific, so that huge mods with dozens of items and a huge wiki would actually return a direct link for each one. This is an addition rather than a change of your current API With an item name and a modid, you may do something like: ItemStack searchedItem = GameData.findItemStack(modid, name); if(searchedItem!=null && searchedItem.getItem() instanceof IWikiLinkable) //get specific item wiki link else //get global mod wiki link If a modder has to add each and every individual item to the API, wouldn't that get a bit tedious? Especially for large mods such as Buildcraft, Thaumcraft 3 or IC2 Quote Follow me on twitter! @keepablock Read up on whats new! www.catacombs.co http://electronic-chronic.com/assets/keep-a-block/wikilink/wikilink_logo.png[/img]
hydroflame Posted August 7, 2013 Posted August 7, 2013 yes but i dont think you can make a generic method for everything to give you an idea, i have a LOT of object, and i would deff do it Quote how to debug 101:http://www.minecraftforge.net/wiki/Debug_101 -hydroflame, author of the forge revolution-
Mazetar Posted August 7, 2013 Posted August 7, 2013 yes but i dont think you can make a generic method for everything to give you an idea, i have a LOT of object, and i would deff do it This. The mod I'm working on now has a lot of weird stuff inside it, But for such an nice idea I might coonsider the trouble of manualy adding it all to be worth it Just adding my line to the ones above Quote If you guys dont get it.. then well ya.. try harder...
DrEinsteinium Posted August 7, 2013 Author Posted August 7, 2013 I mean, your method would work and I know exactly how I program it, but that still doesn't solve the problem of getting the item the player wants to search for. There has to be a different system rather than a slash command that gets the item name. Quote Follow me on twitter! @keepablock Read up on whats new! www.catacombs.co http://electronic-chronic.com/assets/keep-a-block/wikilink/wikilink_logo.png[/img]
hydroflame Posted August 7, 2013 Posted August 7, 2013 make sure your mod runs after everyone else, make a menu with a search bar (like creative) and all ALL the items in it Quote how to debug 101:http://www.minecraftforge.net/wiki/Debug_101 -hydroflame, author of the forge revolution-
DrEinsteinium Posted August 7, 2013 Author Posted August 7, 2013 Here is what I was thinking: 1. Add a keybinding. 2. When the keybinding is pressed, it will get the name of the item in your hand. 3. The name of the item would get matched with a name inside of a modder's plugin and open their wiki. 4. If the name of the item does not have a wiki, it will just search the name on the default wiki. While playing survival, the user probably won't want information on an item if it's not even in their possession, so adding a simple keybinding would work. I could also add an extra system to where if there is no item in their hand, it gets the block they are looking at. Quote Follow me on twitter! @keepablock Read up on whats new! www.catacombs.co http://electronic-chronic.com/assets/keep-a-block/wikilink/wikilink_logo.png[/img]
hydroflame Posted August 7, 2013 Posted August 7, 2013 While playing survival, the user probably won't want information on an item if it's not even in their possession, so adding a simple keybinding would work. actually when using IC2 or EE theres was a LOT of item i wanted to know why what they were doing, before i had them Quote how to debug 101:http://www.minecraftforge.net/wiki/Debug_101 -hydroflame, author of the forge revolution-
DrEinsteinium Posted August 7, 2013 Author Posted August 7, 2013 Well I think at that point you can just pull up the industrialcraft wiki and get that information yourself. Atleast until I make an NEI compatibility addon for WikiLink. Edit: You'll still also be able to do /wiki ic2 <name of item> Quote Follow me on twitter! @keepablock Read up on whats new! www.catacombs.co http://electronic-chronic.com/assets/keep-a-block/wikilink/wikilink_logo.png[/img]
hydroflame Posted August 7, 2013 Posted August 7, 2013 just saying my menu thing wouldnt be that bad Quote how to debug 101:http://www.minecraftforge.net/wiki/Debug_101 -hydroflame, author of the forge revolution-
Mew Posted August 7, 2013 Posted August 7, 2013 Ill agree with Hydroflame on this. But to expand on his idea, have a config file that can switch between the two methods. It means more work, but then it adds diversity, and with diversity comes heaps of users (if it is the right diversity). So you would have say a boolean in the config that is true if the player wants the menu with ALL items, and false if they want the keybinding. I would definitely use the menu, but hey, you have to have diversity Quote I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes. I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there
DrEinsteinium Posted August 7, 2013 Author Posted August 7, 2013 I like his idea, but the only problem I see is that I lack the knowledge to make such a menu. I'll look into it though. Quote Follow me on twitter! @keepablock Read up on whats new! www.catacombs.co http://electronic-chronic.com/assets/keep-a-block/wikilink/wikilink_logo.png[/img]
hydroflame Posted August 7, 2013 Posted August 7, 2013 ohhhhhhh, well then, i can guarantee you that what you're generally trying to do is harder then making a menu Quote how to debug 101:http://www.minecraftforge.net/wiki/Debug_101 -hydroflame, author of the forge revolution-
DrEinsteinium Posted August 7, 2013 Author Posted August 7, 2013 Well then I need to find a guide for GUIs, because I feel like my way would be so much easier lol Quote Follow me on twitter! @keepablock Read up on whats new! www.catacombs.co http://electronic-chronic.com/assets/keep-a-block/wikilink/wikilink_logo.png[/img]
hydroflame Posted August 7, 2013 Posted August 7, 2013 I feel like my way would be so much easier lol kindof like the difference between bukkit and forge, its so much easier in bukkit because you have to take care of 1 side, commands only but forge is way better because we can create menu, make things intutive etc Quote how to debug 101:http://www.minecraftforge.net/wiki/Debug_101 -hydroflame, author of the forge revolution-
Mew Posted August 7, 2013 Posted August 7, 2013 I feel like my way would be so much easier lol kindof like the difference between bukkit and forge, its so much easier in bukkit because you have to take care of 1 side, commands only but forge is way better because we can create menu, make things intutive etc Haha, agreed whole heartedly mate! Well then I need to find a guide for GUIs, because I feel like my way would be so much easier lol Well hydroflame here seems to be a semi master of GUI's, he helped me with a draggable GUI Quote I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes. I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there
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.