Jump to content

DrEinsteinium

Members
  • Posts

    54
  • Joined

  • Last visited

Everything posted by DrEinsteinium

  1. I expected it to work because chicken_bones did some magical stuff along the same lines. <Link> Obviously that does not work, however, I tried using the GameRegistry method and all I get is null whenever it returns the UniqueIdentifier for my ItemStack. Here is the code I used. ItemStack stackover = gui.manager.getStackMouseOver(); WikiLink.LogHelper.info("" + GameRegistry.findUniqueIdentifierFor(stackover.getItem())); It should work, as it turns the ItemStack into an Item so the GameRegistry method could read it, but all it returns is null. Here is the code from NEI that I am using to return the ItemStack. public ItemStack getStackMouseOver() { Point mousePos = getMousePosition(); ItemStack item = null; for(IContainerObjectHandler objectHandler : objectHandlers) { item = objectHandler.getStackUnderMouse(window, mousePos.x, mousePos.y); if(item != null) return item; } if(!objectUnderMouse(mousePos.x, mousePos.y)) { Slot slot = window.getSlotAtPosition(mousePos.x, mousePos.y); if(slot != null) item = slot.getStack(); } return item; } ---- Edit: My current solution is this: ItemStack stackover = gui.manager.getStackMouseOver(); NBTTagList itemDataList = new NBTTagList(); GameData.writeItemData(itemDataList); for(int i = 0; i < itemDataList.tagCount(); i++) { ItemData itemData = new ItemData((NBTTagCompound) itemDataList.tagAt(i)); if(itemData.getItemId() == stackover.itemID) { WikiLink.LogHelper.info("The ModId is: " + itemData.getModId()); } } It's not exactly the way I want it, as it loops through every item in the game until it matches the ItemData itemId with the ItemStack itemId, but hey. If there's an easier and more efficient solution, do not hesitate to post
  2. Hey everyone, I am working on my mod and I am trying to figure out how to convert ItemStack into ItemData through the use of NBTTagCompound. Despite trying all three methods to write NBTTagCompounds, I crash every single time. Here is my pastebin of my error. http://pastebin.com/XMHzA826 Here is my methodology for converting the itemstack. ItemStack stackover = gui.manager.getStackMouseOver(); NBTTagCompound tag = new NBTTagCompound(); stackover.writeToNBT(tag); ItemData data = new ItemData((NBTTagCompound) tag); It keeps crashing whenever I run the method, even if I use writeToNBT, setTagCompound and stackTagCompound. The whole point of the process is to get an ItemStack from NEI's keybinding and return the @ModId of that particular item's mod (which I can do with ItemData.getModId()). Does someone have an explanation for this? I am really getting annoyed. Here is my GitHub if you want to see the whole code. I am using Wiki and NEIWikiLinkConfig. But just a fair warning, my mod's workspace is so messy. I am in the process of re-writing.
  3. Thank you. I will try these methods. It's a shame I can't reload my mod though lol
  4. Hey guys, I am working on an automatically updating library childmod for my parent WikiLink. I am making some good progress, but I am stuck on two parts. 1. How do I make my mod a "Child mod" so I don't have two entries in the loaded mods screen? 2. This question may be a bit more difficult. How do I "reload" my child mod when it automatically downloads/overrides itself? My first solution was to just have my parent mod do the downloading/overriding and then let the child mod load afterwards, but I'd rather have my child mod do everything. Any suggestions? 3. How do I get the location of the mods folder in 'code form'? I know it's a stupid question, but I want a sure way to find the location for the mods folder on every user's machine. Thanks in advance
  5. Hi guys, I have a problem that I can't figure out. 2013-08-13 18:58:44 [iNFO] [sTDOUT] java.lang.NullPointerException 2013-08-13 18:58:44 [iNFO] [sTDOUT] at wikilink.utility.ItemInfoHandler.getInfo(ItemInfoHandler.java:74) 2013-08-13 18:58:44 [iNFO] [sTDOUT] at wikilink.handlers.PlayerTickHandler.playerTick(PlayerTickHandler.java:46) 2013-08-13 18:58:44 [iNFO] [sTDOUT] at wikilink.handlers.PlayerTickHandler.tickStart(PlayerTickHandler.java:24) 2013-08-13 18:58:44 [iNFO] [sTDOUT] at cpw.mods.fml.common.SingleIntervalHandler.tickStart(SingleIntervalHandler.java:28) 2013-08-13 18:58:44 [iNFO] [sTDOUT] at cpw.mods.fml.common.FMLCommonHandler.tickStart(FMLCommonHandler.java:122) 2013-08-13 18:58:44 [iNFO] [sTDOUT] at cpw.mods.fml.common.FMLCommonHandler.onPlayerPreTick(FMLCommonHandler.java:383) 2013-08-13 18:58:44 [iNFO] [sTDOUT] at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:281) 2013-08-13 18:58:44 [iNFO] [sTDOUT] at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:324) 2013-08-13 18:58:44 [iNFO] [sTDOUT] at net.minecraft.network.NetServerHandler.handleFlying(NetServerHandler.java:304) 2013-08-13 18:58:44 [iNFO] [sTDOUT] at net.minecraft.network.packet.Packet10Flying.processPacket(Packet10Flying.java:51) 2013-08-13 18:58:44 [iNFO] [sTDOUT] at net.minecraft.network.MemoryConnection.processReadPackets(MemoryConnection.java:89) 2013-08-13 18:58:44 [iNFO] [sTDOUT] at net.minecraft.network.NetServerHandler.networkTick(NetServerHandler.java:141) 2013-08-13 18:58:44 [iNFO] [sTDOUT] at net.minecraft.network.NetworkListenThread.networkTick(NetworkListenThread.java:54) 2013-08-13 18:58:44 [iNFO] [sTDOUT] at net.minecraft.server.integrated.IntegratedServerListenThread.networkTick(IntegratedServerListenThread.java:109) 2013-08-13 18:58:44 [iNFO] [sTDOUT] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:689) 2013-08-13 18:58:44 [iNFO] [sTDOUT] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:585) 2013-08-13 18:58:44 [iNFO] [sTDOUT] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:129) 2013-08-13 18:58:44 [iNFO] [sTDOUT] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:482) 2013-08-13 18:58:44 [iNFO] [sTDOUT] at net.minecraft.server.ThreadMinecraftServer.run(ThreadMinecraftServer.java:16) 2013-08-13 18:58:44 [iNFO] [sTDOUT] 2013-08-13 18:58:44 [iNFO] [sTDOUT] 2013-08-13 18:58:44 [iNFO] [sTDOUT] A detailed walkthrough of the error, its code path and all known details is as follows: 2013-08-13 18:58:44 [iNFO] [sTDOUT] --------------------------------------------------------------------------------------- 2013-08-13 18:58:44 [iNFO] [sTDOUT] 2013-08-13 18:58:44 [iNFO] [sTDOUT] -- Head -- 2013-08-13 18:58:44 [iNFO] [sTDOUT] Stacktrace: 2013-08-13 18:58:44 [iNFO] [sTDOUT] at wikilink.utility.ItemInfoHandler.getInfo(ItemInfoHandler.java:74) 2013-08-13 18:58:44 [iNFO] [sTDOUT] at wikilink.handlers.PlayerTickHandler.playerTick(PlayerTickHandler.java:46) 2013-08-13 18:58:44 [iNFO] [sTDOUT] at wikilink.handlers.PlayerTickHandler.tickStart(PlayerTickHandler.java:24) 2013-08-13 18:58:44 [iNFO] [sTDOUT] at cpw.mods.fml.common.SingleIntervalHandler.tickStart(SingleIntervalHandler.java:28) 2013-08-13 18:58:44 [iNFO] [sTDOUT] at cpw.mods.fml.common.FMLCommonHandler.tickStart(FMLCommonHandler.java:122) 2013-08-13 18:58:44 [iNFO] [sTDOUT] at cpw.mods.fml.common.FMLCommonHandler.onPlayerPreTick(FMLCommonHandler.java:383) 2013-08-13 18:58:44 [iNFO] [sTDOUT] at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:281) 2013-08-13 18:58:44 [iNFO] [sTDOUT] 2013-08-13 18:58:44 [iNFO] [sTDOUT] -- Player being ticked -- 2013-08-13 18:58:44 [iNFO] [sTDOUT] Details: 2013-08-13 18:58:44 [iNFO] [sTDOUT] Entity Type: null (net.minecraft.entity.player.EntityPlayerMP) 2013-08-13 18:58:44 [iNFO] [sTDOUT] Entity ID: 22 2013-08-13 18:58:44 [iNFO] [sTDOUT] Entity Name: Player854 2013-08-13 18:58:44 [iNFO] [sTDOUT] Entity's Exact location: -522.75, 4.00, -522.36 2013-08-13 18:58:44 [iNFO] [sTDOUT] Entity's Block location: World: (-523,4,-523), Chunk: (at 5,0,5 in -33,-33; contains blocks -528,0,-528 to -513,255,-513), Region: (-2,-2; contains chunks -64,-64 to -33,-33, blocks -1024,0,-1024 to -513,255,-513) 2013-08-13 18:58:44 [iNFO] [sTDOUT] Entity's Momentum: 0.00, -0.08, 0.00 2013-08-13 18:58:44 [iNFO] [sTDOUT] Stacktrace: 2013-08-13 18:58:44 [iNFO] [sTDOUT] at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:324) 2013-08-13 18:58:44 [iNFO] [sTDOUT] at net.minecraft.network.NetServerHandler.handleFlying(NetServerHandler.java:304) 2013-08-13 18:58:44 [iNFO] [sTDOUT] at net.minecraft.network.packet.Packet10Flying.processPacket(Packet10Flying.java:51) 2013-08-13 18:58:44 [iNFO] [sTDOUT] at net.minecraft.network.MemoryConnection.processReadPackets(MemoryConnection.java:89) 2013-08-13 18:58:44 [iNFO] [sTDOUT] at net.minecraft.network.NetServerHandler.networkTick(NetServerHandler.java:141) 2013-08-13 18:58:44 [iNFO] [sTDOUT] 2013-08-13 18:58:44 [iNFO] [sTDOUT] -- Ticking connection -- 2013-08-13 18:58:44 [iNFO] [sTDOUT] Details: 2013-08-13 18:58:44 [iNFO] [sTDOUT] Connection: net.minecraft.network.NetServerHandler@252b63c7 2013-08-13 18:58:44 [iNFO] [sTDOUT] Stacktrace: 2013-08-13 18:58:44 [iNFO] [sTDOUT] at net.minecraft.network.NetworkListenThread.networkTick(NetworkListenThread.java:54) 2013-08-13 18:58:44 [iNFO] [sTDOUT] at net.minecraft.server.integrated.IntegratedServerListenThread.networkTick(IntegratedServerListenThread.java:109) 2013-08-13 18:58:44 [iNFO] [sTDOUT] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:689) 2013-08-13 18:58:44 [iNFO] [sTDOUT] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:585) 2013-08-13 18:58:44 [iNFO] [sTDOUT] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:129) 2013-08-13 18:58:44 [iNFO] [sTDOUT] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:482) 2013-08-13 18:58:44 [iNFO] [sTDOUT] at net.minecraft.server.ThreadMinecraftServer.run(ThreadMinecraftServer.java:16) 2013-08-13 18:58:44 [iNFO] [sTDOUT] Here is my code. public class ItemInfoHandler { public static boolean found; public static int matchedId; public static String matchedName; public static String matchedModId; // This matches the held item with an ID. public static void idMatcher(EntityPlayer player) { matchedId = (player.getHeldItem().itemID); matchedName = (player.getHeldItem().getDisplayName()); } private static ItemData itemList(NBTBase base) { //Auto-generated method stub return null; } // This gets the NBT info public static void getInfo(EntityPlayer player) { NBTTagList itemList = new NBTTagList(); GameData.writeItemData(itemList); ArrayList<ItemData> data = new ArrayList(); NBTBase base; NBTFinder: for(int i = 0; i < itemList.tagCount(); i++) { base = itemList.tagAt(i); if(base instanceof NBTTagCompound) { found = false; data.add(itemList(base)); for (int x = 0; x < WikiLinkableHandler.modIdList.size(); x++) { // Does this item correspond with a registered mod ID? if((base).toString().contains("ModId:" + ((WikiLinkableHandler.modIdList).get(x))) && (base).toString().contains("ItemId:" + matchedId)) { String currentLanguage = Minecraft.getMinecraft().gameSettings.language; System.out.println(WikiLinkableHandler.localizationList.get(x)); if((WikiLinkableHandler.localizationList.get(x)).toString().equals(currentLanguage)) { String hyperlink = "http://" + WikiLinkableHandler.domainList.get(x) + WikiLinkableHandler.getSearchQuery(x) + matchedName.replace(" ", "+"); //This needs to be localized. //player.addChatMessage("Searching for " + matchedName + " on the " + WikiLinkableHandler.nameList.get(x)); BrowserHandler.browserInit(hyperlink, player); found = true; break NBTFinder; } else if(WikiLinkableHandler.localizationList.get(x).toString().equals(null) && found == false) { player.addChatMessage("Could not find wiki translation for your language: " + (Minecraft.getMinecraft().gameSettings.language)); String hyperlink = "http://" + WikiLinkableHandler.domainList.get(0) + WikiLinkableHandler.getSearchQuery(0) + matchedName.replace(" ", "+"); player.addChatMessage("Searching for " + matchedName + " on the " + WikiLinkableHandler.nameList.get(0)); BrowserHandler.browserInit(hyperlink, player); found = true; break NBTFinder; } else{continue;} } else{continue;} } } } if(found == false) { player.addChatMessage("Cannot find mod-related wiki to search! Searching default wiki."); player.addChatMessage("Could not find an accurate translation for your language: " + (Minecraft.getMinecraft().gameSettings.language)); String hyperlink = "http://" + WikiLinkableHandler.domainList.get(0) + WikiLinkableHandler.getSearchQuery(0) + matchedName.replace(" ", "+"); player.addChatMessage("Searching for " + matchedName + " on the " + WikiLinkableHandler.nameList.get(0)); BrowserHandler.browserInit(hyperlink, player); } } } and I'm getting the error on this line. if((WikiLinkableHandler.localizationList.get(x)).toString().equals(currentLanguage)) I honestly have no explanation. The code worked earlier, but now it doesn't and I have no clue why. Anyone have any clues?
  6. Let me better explain my problem. Users of WikiLink that speak different language and that use different language settings in Minecraft are going to have problems when they go to search one of the wikis. The mod will pick up the display name of the item in their hand and the mod will end up searching the english version of the minecraft wiki for a spanish named item. So here is what I was thinking: Instead of always returning the english version of an item, why not go ahead and find what language the user is set to and search the wiki for their language. After all, the official Minecraft Wiki does have a lot of translations. So it would be a giant if statement public static void getLocalizedWiki() { if (language == "en_US") { return "minecraftwiki.net"; } else if (language == "sp_ES" { return "es.minecraftwiki.net"; } } But the golden question is: How do I get the current language that the user is set to?
  7. Hi guys, one of the users of my mod WikiLink just pointed out that using WikiLink with different languages such as Spanish while trying to automatically search a wiki for the item in your hand searches the wiki for the Spanish name of the item. Does anyone know of a method where I can always get the english name of player.getHeldItem().getDisplayName(); Edit -- Better yet, does anyone know how to get what language someone is using?
  8. I just deleted all of my old problems and replaces them with this thread (no need to re-create threads) I am trying to create a keybind, but since keyDown is a part of an interface, I can't add "EntityPlayer player" to the method params. public void keyDown(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd, boolean isRepeat) { ItemInfoHandler.idMatcher(player); ItemInfoHandler.getInfo(player); } How do I make it so the program knows that the player parameter is = to the player using the method keyDown?
  9. I don't quite understand what your code does. In the final if statement if(base instanceof NBTTagCompound) data.add(ItemData(base)); It's throwing me an error on ItemData where "The method ItemData(NBTBase) is undefined for the type <classname>" If I comment the if statement I see that every time the for loop runs it prints something like [itemId:2257,ItemType:net.minecraft.item.ItemRecord,ModId:Minecraft,ordinal:1,] which has the ModId in it, and that's what I need. Can you better explain your logic? Sorry if it's a dumb question, I'm just trying to understand. And also, how do I get the modId value so I can read it and use it? Eg: if((base.ModId).equals(WikiModId) { } ------- Edit: I figured it out!!!!! static void getInfo(int matchedId) { NBTTagList itemList = new NBTTagList(); GameData.writeItemData(itemList); ArrayList<ItemData> data = new ArrayList(); NBTBase base; for(int i = 0; i< itemList.tagCount(); i++) { base = itemList.tagAt(i); if(base instanceof NBTTagCompound) data.add(itemList(base)); //System.out.println(base); //System.out.println(data); if((base).toString().contains("ModId:" + "Minecraft") && (base).toString().contains("ItemId:" + matchedId)) { System.out.println("Success"); } } The program uses the code that GotoLink gave me and checks to see if one of "base"'s strings contain a specific mod id and item id matching int matchedId = (player.getHeldItem().itemID); I don't think I've ever been more happy in my life to solve a problem. Especially without using reflection. Thank you so much everyone.
  10. Agreed, some else code would be good to use here if(params) { } else if(params) // another specific situation in the same if instance { } else // every other situation { }
  11. These are all good, but is there any way I can correlate the item name or id with the modId? It's the one thing I need and it's the hardest to get.
  12. Okay, so I was thinking, I don't need to have mod authors add the names of their items to their plugin as long as I can get the modId and name of the specific item a user wants to search. GameData.ItemStack findItemStack(String modId, String name) This code seems to be what I could use to get that information, but the method is not public, so I don't know how to get it from the GameData file. (I'm still a novice programmer and I haven't learned these things) Here is the full method. static ItemStack findItemStack(String modId, String name) { ItemStack is = customItemStacks.get(modId, name); if (is == null) { Item i = findItem(modId, name); if (i != null) { is = new ItemStack(i, 0 ,0); } } if (is == null) { Block b = findBlock(modId, name); if (b != null) { is = new ItemStack(b, 0, Short.MAX_VALUE); } } return is; } Is there any way I could implement this method and combine it with player.getHeldItem(); So when a user uses my keybinding it will get the item in their hand and return the name and the modId?
  13. Well then I will consult you both when I am ready to make my GUI. I want to try and make it on my own first, just so I can learn.
  14. Well hydroflame here seems to be a semi master of GUI's, he helped me with a draggable GUI Well then no wonder he said the GUI method would be easier
  15. Well then I need to find a guide for GUIs, because I feel like my way would be so much easier lol
  16. 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.
  17. 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>
  18. 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.
  19. 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.
  20. 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
  21. 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?
  22. 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...
  23. 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.
  24. 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.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.