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'm not sure how to do this. I have already a block that will spawn entities when someone breaks it.

 

Now I want to make it so it also spawn entities riding other entities, like for example a Slime riding another Slime.

 

I only know it's possible, and I think it's done with NBT (Topic that I really don't understand much how to handle)

 

Does anyone has some example code on how to spawn an entity riding another entity. And also, is there a limitation to, like what combinations would works and what no?

 

Thanks a lot in advance.

  • Author

Create both entities. Then call mountEntity on the one that should mount the other and then spawn the ridden entity in the world. Done.

 

Thanks diesieben07. So apparently it was much easier then what I thought. But I still have a problem. Spawning other mobs I had no problem, but when I spawn this ones, they don't "render" correctly till I relog.

 

The code for example is:

 

		Entity entityX1;
	Entity entityX2;

	//Bat
   		entityX1 = new EntityBat(world);
   		entityX1.setPosition(x+0.5, y+1, z+0.5);
   		

   		//Creeper
   		entityX2 = new EntityCreeper(world);
   		//entityX2.setPosition(x+0.5, y+1, z+0.5);

        
        entityX2.mountEntity(entityX1);
        
        world.spawnEntityInWorld(entityX1);   

 

The Bats spawn, but you can't see the Creeper, however, when you relog, you can see them.

 

dcHaFyU.png

  • Author

I was not quite sure and apparently I was wrong: set the position of the creeper as well and spawn it into the word, too, before mounting it.

 

Thanks a lot man ;) Now it's working perfect and I'm so happy it doesn't involve working with NBTTags :D

 

Once again, thanks for the great help as usual.

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.