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 have created a Block and a TileEntity. The TileEntity can either be filled with water or not, this is determined by the isFull boolean value. In the Block using the #onBlockActivated() method I check if the TileEntity contains water or not. Based on this I either fill or empty a water bucket and add the water into the TileEntity, then change the BlockState of the Block to correspond with this.

 

The problem is that the value isFull is not getting synchronized properly between the server/client (I think). In 1.9 the World#markBlockForUpdate() method was removed/changed and as a result have skipped this and just used #markDirty() on the TileEntity.

 

Any help in fixing this would be greatly appreciated. Thanks!

 

TileEntity Code

 

Reveal hidden contents

 

 

Block #onBlockActivated()

 

Reveal hidden contents

 

  • Author

Solved the problem by changing sorter.isFull = true / false; into ((TileSedimentSorter)worldIn.getTileEntity(pos)).isFull = true / false;

 

For some reason when I change the value after storing it as a variable my changes don't stick. Would anyone care to explain why this happens?

 

Fixed #onBlockActivated()

 

Reveal hidden contents

 

The default behavior for non-vanilla TileEntities is to destroy any data it may have whenever the blockstate changes (this is the opposite behavior of vanilla TEs).

 

If you want your data to persist across changes in block state, you can override the #shouldRefresh method in your TE:

@Override
public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newState) {
return (oldState.getBlock() != newState.getBlock());
}

  • Author

Thank you very much. Marked as solved.

 

EDIT: For anyone who sees this thread in the future, I left out the super call in the writeToNBT() function which is preventing the data from saving properly:

 

super.writeToNBT(compound);

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.