@Override public boolean interact(EntityPlayer player) { ItemStack itemStack = player.inventory.getCurrentItem(); if (itemStack != null && itemStack.getItem() == MPItems.spawn_egg_mp && itemStack.getItemDamage() == 1014) { if (!this.worldObj.isRemote) { EntityAgeable entityageable = this.createChild(this); if (entityageable != null) { entityageable.setGrowingAge(-24000); entityageable.setLocationAndAngles(this.posX, this.posY, this.posZ, 0.0F, 0.0F); this.worldObj.spawnEntityInWorld(entityageable); if (itemStack.hasDisplayName()) { entityageable.setCustomNameTag(itemStack.getDisplayName()); } if (!player.capabilities.isCreativeMode) { --itemStack.stackSize; if (itemStack.stackSize <= 0) { player.inventory.setInventorySlotContents( player.inventory.currentItem, (ItemStack) null); } } } } return true; } return super.interact(player); }
private void spawnBaby() { EntityAgeable var1 = this.theAnimal.createChild(this.targetMate); if (var1 != null) { EntityPlayer var2 = this.theAnimal.func_146083_cb(); if (var2 == null && this.targetMate.func_146083_cb() != null) { var2 = this.targetMate.func_146083_cb(); } if (var2 != null) { var2.triggerAchievement(StatList.animalsBredStat); if (this.theAnimal instanceof EntityCow) { var2.triggerAchievement(AchievementList.breedCow); } } this.theAnimal.setGrowingAge(6000); this.targetMate.setGrowingAge(6000); this.theAnimal.resetInLove(); this.targetMate.resetInLove(); var1.setGrowingAge(-24000); var1.setLocationAndAngles( this.theAnimal.posX, this.theAnimal.posY, this.theAnimal.posZ, 0.0F, 0.0F); this.theWorld.spawnEntityInWorld(var1); Random var3 = this.theAnimal.getRNG(); for (int var4 = 0; var4 < 7; ++var4) { double var5 = var3.nextGaussian() * 0.02D; double var7 = var3.nextGaussian() * 0.02D; double var9 = var3.nextGaussian() * 0.02D; this.theWorld.spawnParticle( EnumParticleTypes.HEART, this.theAnimal.posX + (double) (var3.nextFloat() * this.theAnimal.width * 2.0F) - (double) this.theAnimal.width, this.theAnimal.posY + 0.5D + (double) (var3.nextFloat() * this.theAnimal.height), this.theAnimal.posZ + (double) (var3.nextFloat() * this.theAnimal.width * 2.0F) - (double) this.theAnimal.width, var5, var7, var9, new int[0]); } if (this.theWorld.getGameRules().getGameRuleBooleanValue("doMobLoot")) { this.theWorld.spawnEntityInWorld( new EntityXPOrb( this.theWorld, this.theAnimal.posX, this.theAnimal.posY, this.theAnimal.posZ, var3.nextInt(7) + 1)); } } }
/** * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a * pig. */ public boolean interact(EntityPlayer par1EntityPlayer) { ItemStack var2 = par1EntityPlayer.inventory.getCurrentItem(); if (var2 != null && var2.getItem() == Items.spawn_egg) { if (!this.worldObj.isClient) { Class var3 = EntityList.getClassFromID(var2.getItemDamage()); if (var3 != null && var3.isAssignableFrom(this.getClass())) { EntityAgeable var4 = this.createChild(this); if (var4 != null) { var4.setGrowingAge(-24000); var4.setLocationAndAngles(this.posX, this.posY, this.posZ, 0.0F, 0.0F); this.worldObj.spawnEntityInWorld(var4); if (var2.hasDisplayName()) { var4.setCustomNameTag(var2.getDisplayName()); } if (!par1EntityPlayer.capabilities.isCreativeMode) { --var2.stackSize; if (var2.stackSize <= 0) { par1EntityPlayer.inventory.setInventorySlotContents( par1EntityPlayer.inventory.currentItem, (ItemStack) null); } } } } } return true; } else { return false; } }