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

I have created a plant using a seed item using ItemNameBlockItem and the corresponding block using the BushBlock classes.

However when setting the block as an entity's favorite block, I need to test it as an item, but when I use the block.asItem() I target the seed, not the plant. I cannot figure out a way to get a block from an ItemStack, cos casting to ItemLike and BlockItem don't work and Item doesn't have an Item.getItemFromBlock method (and perhaps if it did it would just return the seed item, not the plant block as an item). I tried using the block's resource location to identify the block but ItemStack doesn't return a resource location. I printed out the block name and mc just adds prepends item to the block name. So, is this the correct way to do it?

 

if (stack.getDescriptionId().equalsIgnoreCase("itemblock_name")) {}

Edited by DinoPawz
more info

outside of registration class, there should be no "string representations" or paths to your items and blocks (tags are okay). and what you used is for translation and displaying on screen.

now during registration, did you make a BlockItem instance for the purpose of creative tab? if you did, do stack.getItem().equals(staticBlockItemFromRegistration)

frankly, i'm not sure what you need to do so if the above row didn't help, please paste problematic method.

  • Author

Oh, thanks I felt dumb after posting this I deleted but here it is. And yes, I found my BlockItem instance in my Item registration class.

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.