return spawnedCreature;
}
private static Entity spawnCreature(World world, NBTTagCompound mobTag, double x, double y, double z, int side)
{
Entity e;
if(mobTag.getBoolean("hide"))
{
List<RandomMob> mobs = new ArrayList<RandomMob>();
for(IRandomMobProvider p : MFRRegistry.getRandomMobProviders())
{
System.out.println("Adding mobs from " + p.getClass().getName());
mobs.addAll(p.getRandomMobs(world));
}
e = ((RandomMob)WeightedRandom.getRandomItem(world.rand, mobs)).getMob();
}
else
{
NBTTagList pos = mobTag.getTagList("Pos");
((NBTTagDouble)pos.tagAt(0)).data = x;
((NBTTagDouble)pos.tagAt(1)).data = y;
((NBTTagDouble)pos.tagAt(2)).data = z;
e = EntityList.createEntityFromNBT(mobTag, world);
if (e != null)
{
if(e instanceof EntityLiving)
{
((EntityLiving)e).initCreature();
}
e.readFromNBT(mobTag);
}
}
if(e != null)
{
int offsetX = Facing.offsetsXForSide[side];
int offsetY = side == 0 ? -1 : 0;
int offsetZ = Facing.offsetsZForSide[side];
AxisAlignedBB bb = e.boundingBox;
e.setLocationAndAngles(x + (bb.maxX - bb.minX) * 0.5 * offsetX,
y + (bb.maxY - bb.minY) * 0.5 * offsetY,
z + (bb.maxZ - bb.minZ) * 0.5 * offsetZ,
world.rand.nextFloat() * 360.0F, 0.0F);
world.spawnEntityInWorld(e);
if(e instanceof EntityLiving)
{
((EntityLiving)e).playLivingSound();
}
Entity riddenByEntity = e.riddenByEntity;
while(riddenByEntity != null)
{
riddenByEntity.setLocationAndAngles(x, y, z, world.rand.nextFloat() * 360.0F, 0.0F);
world.spawnEntityInWorld(riddenByEntity);
if(riddenByEntity instanceof EntityLiving)
{
((EntityLiving)riddenByEntity).playLivingSound();