Vswe's Summer Courses | You're not logged in. Sign up or log in | Server time: | Donate
One can now see other persons' badge hunts. Simply head over to their profiles to access them.

Go back to course page

Forging a Minecraft mod

Basic Minecraft modding with Minecraft Forge

Entity Not Writing to NBT

  • 2013-07-24 04:00:47
    I have almost finished the assignment except for having my rockets reload after exiting the world. I know that this is because for some reason they are not being written to the NBT file because I have searched for them in there with NBTexplorer. Could anyone please help with why this could be happening?
  • 2013-07-24 07:34:24
    did you register your entity?
  • 2013-07-24 13:15:45
  • 2013-07-24 13:21:30
    what do you mean by your rockets reloading? did you use writeEntityToNbt to save the informations?
  • 2013-07-24 13:25:35
    Yes I used writeEntityToNBT to save the information and by reloading I mean if you exit the world while the entities are still there when you rejoin that world the entities no longer exist.
  • 2013-07-24 13:45:17
    here is a link to all the code in my mod package I figured it may help to be able to see what is going on.
  • 2013-07-24 15:08:13
    I am still having this problem and can't figure out any reason why it would be doing this. Could someone please help me?
  • 2013-07-24 15:51:57
    Help please I am so confused
  • 2013-07-24 17:38:22
    Is there anyone who could help me out with this problem cause i really need it
  • 2013-07-24 18:57:29
    So far i have figured out that my writeEntityToNBT method is not being called by having the method print something out in the console when it is called and that print is not occuring.
    Does anyone know why this method would not be called? Also sorry for the spam it is just that this bug is really starting to frustrate me.
  • 2013-07-24 19:04:37
    Are you using @Override? You're probably typing something wrong.
  • 2013-07-24 19:18:44
    I do have @Override on my methods and maybe I'm just having an issue from staring at it too long but I can't find any typos. I posted a link to a shared version of my code if seeing it would help you understand my problem any better.
  • 2013-07-24 20:03:50
    The rocket is actually never spawned, the client just think that it do exist. Therefore when you restart the world the rocket won't show up, because it was never there.
  • 2013-07-24 20:58:02
    Thank you for all the help. I would like to once again apologize for sending so many messages earlier.
  • 2013-08-22 03:39:47
    I'm getting this same problem, and I'm not sure why. I'm certain I spawned the entity:

                if (fireworkTimer >= fireworkLimit) {
                    emitFirework(xCoord, yCoord, zCoord);
                    fireworkTimer = 0;

    public void emitFirework(int x, int y, int z) {
            EntityRocket firework = new EntityRocket(worldObj);
            firework.posX = x + .5;
            firework.posY = y + 1.5;
            firework.posZ = z + .5;
            firework.setType((byte)(worldObj.getBlockMetadata(x, y, z)));

    What did I do wrong?
  • 2013-08-22 03:40:41
    The top part is inside of the updateEntity method in my code
  • 2013-08-22 07:52:02
    Why are you doing emitFirework(xCoord, yCoord, zCoord) in your updateEntity method?(top part)

    Also, you should check !worldObj.isRemote before creating the firework and spawning it.

    You can also have the writeEntityToNBT print something out and then check your console to see if that method is being called when you quit the world. If it didn't print anything in your console, the entity probably doesn't really exist.
  • 2013-08-22 12:50:46
    I did check !worldObj.isRemote, and in the updateEntity method I increase the firework timer, then emit the firework if the timer has reached the goal. To clarify, this code is from the tileEntity that spawns the rocket. And the writeEntityToNBT is being called, so I'm not sure why the rockets dissappear.
  • 2013-08-22 12:51:26
    This is the full method, if it helps:

        public void updateEntity() {
                if (particleTimer >= particleLimit) {
                    particleTimer = 0;

                if (fireworkTimer >= fireworkLimit) {
                    emitFirework(xCoord, yCoord, zCoord);
                    fireworkTimer = 0;
        public void emitFirework(int x, int y, int z) {
            EntityRocket firework = new EntityRocket(worldObj);
            firework.posX = x + .5;
            firework.posY = y + 1.5;
            firework.posZ = z + .5;
            firework.setType((byte)(worldObj.getBlockMetadata(x, y, z)));
  • 2013-08-22 16:11:08
    I thinki had the same problem but i had no wifi so i spend 5 hours finding it, but i think my problem was that i wasnt saving the tyoe of the rocket, so you set the type in emitFirework, but are you also writing it to nbt and reading it?
  • 2013-08-22 19:50:26
    Yes, I did save the rocket type, but it turns out I wasn't saving the target Y for the rocket. I fixed it, and now it works fine!
  • 2013-08-26 13:33:45
    Don't know why but NBT:s don't work on my mods (I've had this problem before, luckily I finally found a fix) unless I implement these overrides:
    public Packet getDescriptionPacket()
    NBTTagCompound var1 = new NBTTagCompound();
    return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 1, var1);
    public void onDataPacket(INetworkManager net, Packet132TileEntityData pkt) {readFromNBT(pkt.customParam1);}

    If I don't then the NBT data is not send to the client and it just keeps the default values.
  • 2013-08-27 07:33:25
    have you overwrite readFromNBT()? if you did, then provide us with your code so we can help you
  • 2017-06-18 18:37:07
    ???? ??????!???? ???????????? ????-????? ??????? ???????????? ? ???????????? ???????????!????????? https://www.youtube.com/channel/UCDs70rs-zKySDE9lwaAHLvQ
    Hello everyone! I want to advise you YouTube channel of Russian cartoons with daily updates! Subscribe https://www.youtube.com/channel/UCDs70rs-zKySDE9lwaAHLvQ
  • 2018-01-01 05:46:18
    The ED resulting from that surgery might be either temporary or permanent. However, it is important to find the doctor's opinion first before taking these oral medications since these could have pessimistic effects about the body.
    <a href="http://www.generiqueviagrafr.fr/viagra-tom-kaulitz">http://www.generiqueviagrafr.fr/viagra-tom-kaulitz</a>
  • Log in or sign up to reply to this thread