Posted January 10, 201312 yr 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
January 10, 201312 yr 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
January 10, 201312 yr 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.