Posted October 21, 20168 yr In 1.710, I had this nifty piece of code that could pull the ModId from an item. In 1.10.2, GameRegistry has changed, and with it, it seems, is the path to get ModId. Can anyone point me in the correct direction? I use the modid for various purposes. 1.7.10 code that worked: public static String getModId(Item item) { GameRegistry.UniqueIdentifier id = GameRegistry.findUniqueIdentifierFor(item); return id == null || id.modId.equals("") ? "minecraft" : id.modId; } public static String getModId(ItemStack key) { return getModId(key.getItem()); }
October 21, 20168 yr Wait, so do you not know your ModID? When you make your mom, one of the first steps is making YOUR OWN ModID. You set it early on. There are several ways to do this too. my personal favorite, is @Mod(modid = Reference.MOD_ID); Refernece is another class, where i did public static final String MOD_ID = "tmm"; I Love To Help People. Unless They Are The Kind Of People Who Just Doesn't Know Anything. Those People Need Some Serious Help. This Could Help But...... https://www.youtube.com/watch?v=6t0GlXWx_PY ThingsMod Git: https://github.com/EscapeMC/Things-Mod-1.10.2 TeamMadness Mod Git: https://github.com/EscapeMC/TeamMadness-Mod-1.10.2 If I somehow help you, please click the "Thank You" button. If I am a total waste of time, please click the "Applaud" button.
October 21, 20168 yr Author No, I know my own ModId, ha ha I'm talking about getting the ModId from another mod's item. The code above provides that in 1.7.10. I'm looking for a way to do it in 1.10.2
October 21, 20168 yr I have not yet seen a way to get -only- the modid, but as you have an item, you can get the registryname which contains it, then split the string with the regex ":". Hacky way, but should be do-able. Also previously known as eAndPi. "Pi, is there a station coming up where we can board your train of thought?" -Kronnn Published Mods: Underworld Handy links: Vic_'s Forge events Own WIP Tutorials.
October 21, 20168 yr Author Yes, that will work. I'm used to parsing these strings by now, so I am ok with the 'hackiness'. Thanks for the suggestion.
October 21, 20168 yr The registry name is a ResourceLocation , the domain of which ( ResourceLocation#getResourceDomain ) is the mod ID. You don't need to resort to string parsing. Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
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.