Hey there,
i am programming a villager mod for Minecraft 1.12.2 and i want my villagers to trade special Items.
Now I'm struggling with the code of one of these items.
I want an Item, that can spawn only baby vanilla animals, like baby pigs, baby cows and so on.
But i don't really know, how to spawn baby animals.
At the moment, the following code in the items 'onItemRightClick' function spawns only adult vanilla pigs.
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) {
ItemStack itemstack = playerIn.getHeldItem(hand);
if(!worldIn.isRemote){
EntityPig pig = new EntityPig(worldIn);
EntityAgeable child = new EntityPig(worldIn).createChild(pig);
child.setPosition(playerIn.posX + 0.5D , playerIn.posY, playerIn.posZ + 0.5D);
worldIn.spawnEntity(child);
itemstack.shrink(1);
return new ActionResult(EnumActionResult.SUCCESS,itemstack);
}
return super.onItemRightClick(worldIn, playerIn, hand);
}
What can i do, to get only baby pigs?
And is this even possible?
Thank you very mutch