Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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());
}

 

 

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.

  • 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

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.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.