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 a boolean that is set to false.

An event changes this boolean to true.

But after I close minecraft and restart it, its set back to false.

 

I have this problem with an item and my tameable mob (he stops following me after restart).

 

How can I permenantly set this in a save file?

 

Thanks!

Basically, NBT is a thing that Notch made to save states of things, if I'm not mistaken. Lots of things use it, like Furnaces. I can't really explain it much further.

 

But has your mob class extended EntityTameable? I think that does it for you.

Thanks...!

  • Author

Basically, NBT is a thing that Notch made to save states of things, if I'm not mistaken. Lots of things use it, like Furnaces. I can't really explain it much further.

 

But has your mob class extended EntityTameable? I think that does it for you.

I've looked at your code, but I can't find anything that sets the boolean to true.

When a mob is defeated, the boolean is set to true, allowing an item to do something. But how can I do this with NBT?

 

And yes, I have a tamable entity too, that resets after restarts, even tough it extends EntityTameable.

 

No, you have a method which sets a boolean to true, and when you exit, it will save the boolean to NBT, and when you enter, it will read it from NBT.

Thanks...!

  • Author

No, you have a method which sets a boolean to true, and when you exit, it will save the boolean to NBT, and when you enter, it will read it from NBT.

I've edited your code, but it still just reverts back to normal after restart.

Here is how it looks:

 

    public void writeToNBT(NBTTagCompound par1NBTTagCompound)
    {
        super.writeToNBT(par1NBTTagCompound);
        par1NBTTagCompound.setBoolean("defeat", mobisdefeated);
        NBTTagList nbttaglist = new NBTTagList();

        par1NBTTagCompound.setTag("tag", nbttaglist);
    }

public void readFromNBT(NBTTagCompound par1NBTTagCompound)
    {
        super.readFromNBT(par1NBTTagCompound);
        NBTTagList nbttaglist = par1NBTTagCompound.getTagList("tag");

        for (int i = 0; i < nbttaglist.tagCount(); ++i)
        {
            NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbttaglist.tagAt(i);
            byte slot = nbttagcompound1.getByte("Slot");
        }

        mobisdefeated = par1NBTTagCompound.getBoolean("defeat");
    }

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.