Posted March 14, 20196 yr 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
March 14, 20196 yr Author Thank you very mutch. The lines you quoted were my very first attempts to spawn something. I will remove them and, in the long run, make the spawned entity depend on the held item datavalue. For now i just tried to figure out, how to get baby animals. I try to set the growingAge. Thanks for that.
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.