Posted March 11, 20178 yr Hi, 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, -Matthew
March 11, 20178 yr 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 March 11, 20178 yr by Leviathan143
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.