Posted January 2, 20196 yr I was working on this getDrops method, but everytime I broke a block the console threw a NullPointerException error. I fixed that, but now the block isn't returning the correct blockstate color from the tileentity. Not sure if the null check is the problem, here is my code: Spoiler @Override public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { super.getDrops(drops, world, pos, state, fortune); TileEntityColored te = (TileEntityColored) world.getTileEntity(pos); if (te!= null) { drops.add(new ItemStack(this, 1, te.getColor().getDyeDamage())); } }
January 2, 20196 yr 2 hours ago, Siqhter said: I was working on this getDrops method, but everytime I broke a block the console threw a NullPointerException error. I fixed that, but now the block isn't returning the correct blockstate color from the tileentity. Not sure if the null check is the problem, here is my code: Reveal hidden contents @Override public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { super.getDrops(drops, world, pos, state, fortune); TileEntityColored te = (TileEntityColored) world.getTileEntity(pos); if (te!= null) { drops.add(new ItemStack(this, 1, te.getColor().getDyeDamage())); } } Please submit your crash report and (preferably) post your modification on github. Edited January 2, 20196 yr by TestingSubject002
January 2, 20196 yr Author 5 hours ago, diesieben07 said: Look at the three patched methods in BlockFlowerPot I had looked at it yesterday, and didn't understand what the code in the FORGE START section did, but I do know and finally got it working. For blocks with tileentities, do you really need the 3 methods all the time?
January 2, 20196 yr Author 50 minutes ago, diesieben07 said: If you need the tile entity during calculation of drops: Yes. Thanks.
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.