Posted May 6, 201312 yr 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!
May 6, 201312 yr Use an NBT Tag. I think this should work: http://paste.minecraftforge.net/view/432625b0 Thanks...!
May 6, 201312 yr Author Use an NBT Tag. I think this should work: http://paste.minecraftforge.net/view/432625b0 Ehm, sorry if I have to ask, but could you explain that for me? I have this boolean called "DefeatedMob" that is set to true.
May 6, 201312 yr 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...!
May 6, 201312 yr 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.
May 6, 201312 yr 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...!
May 6, 201312 yr 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.