Jump to content

Recommended Posts

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.

Posted

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

Posted

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

×   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



×
×
  • Create New...

Important Information

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