Jump to content

Recommended Posts

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!

Posted

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...!

Posted

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.

 

Posted

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...!

Posted

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I tried do download the essential mod to my mod pack but i didnt work. I paly on 1.21 and it should work. I use neoforge for my modding. The weird things is my friend somehow added the mod to his modpack and many others that I somehow can´t. Is there anything i can do? 
    • Thanks, I've now installed a slightly newer version and the server is at least starting up now.
    • i have the same issue. Found 1 Create mod class dependency(ies) in createdeco-1.3.3-1.19.2.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Found 11 Create mod class dependency(ies) in createaddition-fabric+1.19.2-20230723a.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Detailed walkthrough of mods which rely on missing Create mod classes: Mod: createaddition-fabric+1.19.2-20230723a.jar Missing classes of create: com/simibubi/create/compat/jei/category/sequencedAssembly/JeiSequencedAssemblySubCategory com/simibubi/create/compat/recipeViewerCommon/SequencedAssemblySubCategoryType com/simibubi/create/compat/rei/CreateREI com/simibubi/create/compat/rei/EmptyBackground com/simibubi/create/compat/rei/ItemIcon com/simibubi/create/compat/rei/category/CreateRecipeCategory com/simibubi/create/compat/rei/category/WidgetUtil com/simibubi/create/compat/rei/category/animations/AnimatedBlazeBurner com/simibubi/create/compat/rei/category/animations/AnimatedKinetics com/simibubi/create/compat/rei/category/sequencedAssembly/ReiSequencedAssemblySubCategory com/simibubi/create/compat/rei/display/CreateDisplay Mod: createdeco-1.3.3-1.19.2.jar Missing classes of create: com/simibubi/create/content/kinetics/fan/SplashingRecipe
    • The crash points to moonlight lib - try other builds or make a test without this mod and the mods requiring it
    • Do you have shaders enabled? There is an issue with the mod simpleclouds - remove this mod or disable shaders, if enabled  
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.