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

Hey everyone,

I am coding a freezer for food (in my mod food can decay)

My problem right now is when the freezer gets unloaded (playerr moves away from it) time keeps passing in the world. So when the freezer reloads I need to check how much time has passed, decrement the amount of coolant and if there is not enough coolant reduce the durability of the food.

 

I need the actual world time to check that and wanted to access the worldObj in readFromNBT, but im getting a NPE. I know I can acess an worldObj via MinecraftServer but I feel like this is a dirty way and im asking for the better one.

 

Any help is appreciated

Greetz Fail

I don't think this is possible, since the

TileEntity

isn't added to the

World

until after it's been loaded from NBT.

 

Instead, I'd recommend setting a flag in

readFromNBT

and then checking for this flag in your update method. If it's

true

, set it to

false

and then perform the load-time coolant calculations.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Actually, I just remembered that Forge recently added the

TileEntity#onLoad

method, which is called when the

TileEntity

's block is first placed in the world and when its chunk is loaded from NBT. You should be able to override this to do the coolant calculations instead of using the flag in the update method.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

  • Author

/**

* Called from the Chunk when this is first added to the world. Override instead of adding

* if (firstTick) stuff in update. Happens after validate and after it has been placed into the Chunk tileEntity

* map.

*/

 

Best.comment.ever.

 

 

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.