Jump to content

Recommended Posts

Posted (edited)

The code for Block.getBlockFromItem() checks for ItemBlock, but not ItemBlockSpecial.  As a result getting the block for, say,  Sugar Cane would return null since it is an ItemBlockSpecial.  What I am wondering is if getBlockFromItem() should be modified to handle ItemBlockSpecial as well, or is there a fundamental difference between an ItemBlock and an ItemBlockSpecial that is not apparent to me.

Edited by OreCruncher
Posted

The code I have iterates through the ItemStacks of a ore dictionary collection (ex. "sugarcane"), trying to identify any of those entries that have associated blocks by using the Item returned from ItemStack.getItem() passed into Block.getBlockFromItem().  The code I have originated with the 1.7.10 version of the mod so it is very possible I have to change my approach.

Posted

The problem is I need to get the block, if any, associated with a given ItemStack. :)

 

My mod is heavily configuration driven.  The configuration allows for the me, or a modpack author, to specify a Forge dictionary collection when defining sound profiles for footsteps, a sound profile being something within my mod.  During startup the defined the Forge dictionary name is used to query the dictionary to get a list of ItemStack members.  I need to crack each of those ItemStacks to get the Block references, if any, in order to populate my internal data maps.  As an example, it expands "oreIron" in order to identify the various iron ore ItemStacks in the modpack to determine which blocks the "ore" sound profile.  There are a lot more details to this process (like meta handling) - I just wanted to give a broad brush outline as to what the mod is doing.

 

During runtime I use IBlockState information to resolve a sound profile based on the data maps mentioned above.  Once it is resolved that solution is inserted into a map using the IBlockState as key.

Posted

I do realize this stretches ore dictionary use in ways that weren't expected/intended.  But for my mod for what it does it helps a lot with things such as "out of the box" default configs for mods that I haven't seen.  The information your provided above is helpful and I think I know which direction I need to go.

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.