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

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

  • Author

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.

  • Author

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.

  • Author

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

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.