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

Recently I came up with another idea of making "counters" in my mod. (To place-hold energy generation)

And then I came across the issue that the TE does not save its counter count.

 

This time, it is VERY different, as I use a separate *class* to handle counter count and counter generation.

Actual counter count and generation rates are stored in separate classes.

 

Now, I just wanna ask:

1. Is NBT Tag Compound capable of writing a different data structure (such as a class) into that save file?

2. If answering yes in Q1, how to implement it?

3. If answering no in Q1, then I have to read the values from the class, store them with the TE (by writeToNBT()), and write them back to their classes once I readFromNBT() :(...?

1. yes.

2. every complex complex consists of many simple parts. blockpos is a "complex" class that contains 3 values. so to write a blockpos to a nbt u need to write 3 values to the nbt, x,y,z.

So to save ur class to nbt u need to write all the values it needs to reconstruct it as simple values (string/float/bool etc)

  • Author

I also heard of adding something like NBT into another NBT (cant remember correctly)

So can someone explain a bit on this and give me an example?

I also heard of adding something like NBT into another NBT (cant remember correctly)

So can someone explain a bit on this and give me an example?

Make a new NBTTagCompound, add stuff to it, then add that compound to the first one. Simple as that.

 

Your best bet is to just start playing around with it, looking at vanilla examples (tile entities and mob-like entities are all good places to start), etc.

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.