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

Hi folks.  Using MC 1.4.6 and current MCP and Forge,  I've been working through the tutorials on this site (for example, Basic Blocks, and Plants), and I run into code that uses the itemID field of objects that are descendants of Item. Examples:

 

[pre]public int idDropped(int par1, Random random, int par2) {

    return BasicBlockMod.basicIngot.itemID;

[/pre]

and

[pre]public int idPicked (World world, int x, int y, int z) {

    return BasicPlantMod.tomatoSeeds.itemID;

[/pre]

 

These samples expect Item to have the field itemID, but it does not -- perhaps it's a field that's been removed?  I'm guessing that itemID used to be set by the int value supplied in the Item constructor -- however that now does this:

 

[pre]    public Item(int par1)    {

        this.shiftedIndex = 256 + par1;[/pre]

 

So, conceptually, Item's memory of an id is in shiftedIndex. But because shiftedIndex is off by 256 from the originally-supplied Id value, it's not clear what the intent is here when an ID needs to be used in, or returned from, other functions. 

 

What should code like idDropped and idPicked be returning?  shiftIndex? shiftIndex-256? Something else?  How is this used elsewhere?

 

Thanks,

 

Graham

  • Author

itemID = deobufscated name of shiftedIndex in 1.4.7

 

Thanks, that was helpful.  But if that's the case, then is it the case that, having given an "Id" value to the Item constructor, the mod code is never supposed to use that "Id" value again, but instead get itemID back from the Item if it's needed later?

 

-- Graham

depends, if the item haves metadata, the mod itself can use again to a new recipe (like new ItemStack(mod.itembla.itemid, how many, metadata)(of course, if you add a recipe using the item)

 

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.