Posted June 19, 20232 yr 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 June 19, 20232 yr by DinoPawz more info
June 19, 20232 yr 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.
June 26, 20232 yr 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.