Jump to content

Recommended Posts

Posted

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()));
    }
}

 

Posted (edited)
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 by TestingSubject002
Posted
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?

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...

×   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.

Announcements



×
×
  • Create New...

Important Information

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