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 was trying to spawn an entity like for example an mine cart chest or even the mine cart mob spawner

 

I can get them to spawn fine but I not sure how to edit the nbt data for them.  I wanted to be able to spawn mine cart chests with an item in it  or able to spawn minecart mob spawners that would spawn other stuff I tried to do it this way but it's not working lol I'm really new to this so I don't know how to edit the nbt the right way.

          EntityMinecart entitySpawnCart = EntityMinecart.createMinecart(par1World, par1, par2, par3, 4);
          NBTTagCompound nbt = entitySpawnCart.getEntityData();
          nbt.setString("EntityId", "SnowMan");
          entitySpawnCart.writeToNBT(nbt);
          par1World.spawnEntityInWorld(entitySpawnCart);

 

  • Author

I was trying to spawn an entity like for example an mine cart chest or even the mine cart mob spawner

 

I can get them to spawn fine but I not sure how to edit the nbt data for them.  I wanted to be able to spawn mine cart chests with an item in it  or able to spawn minecart mob spawners that would spawn other stuff I tried to do it this way but it's not working lol I'm really new to this so I don't know how to edit the nbt the right way.

          EntityMinecart entitySpawnCart = EntityMinecart.createMinecart(par1World, par1, par2, par3, 4);
          NBTTagCompound nbt = entitySpawnCart.getEntityData();
          nbt.setString("EntityId", "SnowMan");
          entitySpawnCart.writeToNBT(nbt);
          par1World.spawnEntityInWorld(entitySpawnCart);

 

getEntityData() doesn't guarantee that you'll get the data you want. In fact forge code:

public NBTTagCompound getEntityData()
    {
        if (customEntityData == null)
        {
            customEntityData = new NBTTagCompound();
        }
        return customEntityData;
    }

this means you don't get any data aside from a new tag compound. the easiest way to work around this though is to pseudo load the entity ie

EnitytMineCart e =  yadda yadda initialization stuff;
NBTTagCompound data = new NBTTagCompound();
e.writeToNBT(data);
data.setString("EntityId", "SnowMan");
e.readFromNBT(data);
w.spawnEntityInWorld(e);

 

I think its my java of the variables.

getEntityData() doesn't guarantee that you'll get the data you want. In fact forge code:

public NBTTagCompound getEntityData()
    {
        if (customEntityData == null)
        {
            customEntityData = new NBTTagCompound();
        }
        return customEntityData;
    }

this means you don't get any data aside from a new tag compound. the easiest way to work around this though is to pseudo load the entity ie

EnitytMineCart e =  yadda yadda initialization stuff;
NBTTagCompound data = new NBTTagCompound();
e.writeToNBT(data);
data.setString("EntityId", "SnowMan");
e.readFromNBT(data);
w.spawnEntityInWorld(e);

 

I think its my java of the variables.

  • Author

Thanks that worked it spawned the test snow mans although it still showed a pig in it, is there a way I can fix that or does that have to be done with forge it self?

  • Author

Thanks that worked it spawned the test snow mans although it still showed a pig in it, is there a way I can fix that or does that have to be done with forge it self?

I have a feeling that it's not being done locally, you'll need to send a packet to notify the client of the changes too

I think its my java of the variables.

I have a feeling that it's not being done locally, you'll need to send a packet to notify the client of the changes too

I think its my java of the variables.

  • Author

thanks well right I don't know how use packets yet, but if I did I don't know what packet data I would need to send and what to do with it on the client side for it to update tell what do do to she the right mob in the mine cart spawner. I'll take a look at some tutorials when I get time but I don't know if any will teach me any more that how to send and handle the packets.

 

so any pointers or links you can give  I'll be sure to check out. thanks again.

  • Author

thanks well right I don't know how use packets yet, but if I did I don't know what packet data I would need to send and what to do with it on the client side for it to update tell what do do to she the right mob in the mine cart spawner. I'll take a look at some tutorials when I get time but I don't know if any will teach me any more that how to send and handle the packets.

 

so any pointers or links you can give  I'll be sure to check out. thanks again.

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.