Jump to content

[1.10.2] Getting the dropped item of an IBlockState


Recommended Posts


I'm trying to get a dropped item equivalent of an IBlockState. I presumed this would be as simple as this:

state.getBlock().getItemDropped(state, new Random(), 0);

But that seems to ignore the block state. Why doesn't this work? Is it to do with the Random? (I wasn't sure what that was for).

Thanks in advance,


Link to comment
Share on other sites

That isn't the correct method to use. Block#getItemDropped() returns the Item the Block should drop. You want Block#getDrops(), which returns a List<ItemStack>. Block#getDrops() will work for all blocks, whereas using solely Block#getItemDropped() will only work for blocks that drop 1 of a single item type that does not use metadata. The Random parameter can be used to randomly return a different result. Generally you pass an existing Random like World#rand, rather than creating a new one.


For future reference, you need to give more information than "it doesn't work". There are a number of ways something can not work. In this case it could be dropping an incorrect item, dropping too few of the correct item, or not dropping anything at all.


Note: In case you haven't seen it before, class#method() is shorthand for the non-static method method of the class class. Similarly, class#field is shorthand for the non-static field field of the class class.Static methods and fields use a similar shorthand, but the '#' is replaced with a '.'

Edited by Leviathan143
Link to comment
Share on other sites

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.

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.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.