Jump to content

Item.itemID vs shiftedIndex?


gwideman

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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