Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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

 

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

  • 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?

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

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.