Posted August 9, 201510 yr 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.
August 10, 201510 yr 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.
August 10, 201510 yr 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 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.