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 read so many of the posts where people just stick the two lines of code that they think are causing the problem, and tell others to fix it. I am sorry if this comes off as one of those posts, but i am using code borrowed from build craft for saving the nbt of my tank and it is not working, and i cannot figure out why, because it traces back to code from KingLemming.

 

 

This is my nbt saving code:

 

the class extends the FluidTank class

 

@Override

public final NBTTagCompound writeToNBT(NBTTagCompound nbt) {

NBTTagCompound tankData = new NBTTagCompound();

super.writeToNBT(tankData);

this.writeTankToNBT(tankData);

nbt.setCompoundTag(this.name, tankData);

return nbt;

}

 

@Override

public final FluidTank readFromNBT(NBTTagCompound nbt) {

if (nbt.hasKey(this.name)) {

NBTTagCompound tankData = nbt.getCompoundTag(this.name);

super.readFromNBT(tankData);

this.readTankFromNBT(tankData);

}

return this;

}

 

 

public void writeTankToNBT(NBTTagCompound nbt) {

 

}

 

public void readTankFromNBT(NBTTagCompound nbt) {

 

}

 

Thank you for your time.

 

@Override

  public final NBTTagCompound writeToNBT(NBTTagCompound nbt) {

      NBTTagCompound tankData = new NBTTagCompound();

      super.writeToNBT(tankData);

      this.writeTankToNBT(tankData);

      nbt.setCompoundTag(this.name, tankData);

      return nbt;

  }

 

Woah.  Slow down.

 

First, you've unneccessarily duplicated your functions.  You shouldn't need the

 this.writeTankToNBT(tankData);

part at all (not to mention that that function is empty and does nothing).

Second, you've marked that function as final.  You don't need that.  In fact, probably shouldn't have it.

 

I have half a mind saying that because you marked it as final, the function signature changed and it's no longer overriding.  Though my other half says not.  Either way, you don't need it.

 

Third, don't use

this.name

as a key...you can't be sure that that name won't change between a save and a load...

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

  • Author

ok i fixed up the method, but the nbt is still not saving. I am sorry for asking, but i have been trying to figure this out for a week.

 

Here is the total source code:

https://github.com/chbachman/ModularStorage

with the relevant code here (i think):

https://github.com/chbachman/ModularStorage/blob/master/common/io/github/chbachman/fluid/Tank.java

and here:

https://github.com/chbachman/ModularStorage/blob/master/common/io/github/chbachman/blocks/modulartank/TileModularTank.java

 

Thank you for your help

 

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.