@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); }
public EntityAgeable createChild(EntityAgeable p_90011_1_) { EntityHorse entityhorse = (EntityHorse) p_90011_1_; EntityHorse entityhorse1 = new EntityHorse(this.worldObj); int i = this.getHorseType(); int j = entityhorse.getHorseType(); int k = 0; if (i == j) { k = i; } else if (i == 0 && j == 1 || i == 1 && j == 0) { k = 2; } if (k == 0) { int i1 = this.rand.nextInt(9); int l; if (i1 < 4) { l = this.getHorseVariant() & 255; } else if (i1 < 8) { l = entityhorse.getHorseVariant() & 255; } else { l = this.rand.nextInt(7); } int j1 = this.rand.nextInt(5); if (j1 < 2) { l |= this.getHorseVariant() & 65280; } else if (j1 < 4) { l |= entityhorse.getHorseVariant() & 65280; } else { l |= this.rand.nextInt(5) << 8 & 65280; } entityhorse1.setHorseVariant(l); } entityhorse1.setHorseType(k); double d1 = this.getEntityAttribute(SharedMonsterAttributes.maxHealth).getBaseValue() + p_90011_1_.getEntityAttribute(SharedMonsterAttributes.maxHealth).getBaseValue() + (double) this.func_110267_cL(); entityhorse1.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(d1 / 3.0D); double d2 = this.getEntityAttribute(horseJumpStrength).getBaseValue() + p_90011_1_.getEntityAttribute(horseJumpStrength).getBaseValue() + this.func_110245_cM(); entityhorse1.getEntityAttribute(horseJumpStrength).setBaseValue(d2 / 3.0D); double d0 = this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getBaseValue() + p_90011_1_.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getBaseValue() + this.func_110203_cN(); entityhorse1.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(d0 / 3.0D); return entityhorse1; }
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 frequently so the entity can update its state every tick as required. For example, * zombies and skeletons use this to react to sunlight and start to burn. */ public void onLivingUpdate() { super.onLivingUpdate(); if (this.getGrowingAge() != 0) { this.inLove = 0; } if (this.inLove > 0) { --this.inLove; if (this.inLove % 10 == 0) { double var1 = this.rand.nextGaussian() * 0.02D; double var3 = this.rand.nextGaussian() * 0.02D; double var5 = this.rand.nextGaussian() * 0.02D; this.worldObj.spawnParticle( EnumParticleTypes.HEART, this.posX + (double) (this.rand.nextFloat() * this.width * 2.0F) - (double) this.width, this.posY + 0.5D + (double) (this.rand.nextFloat() * this.height), this.posZ + (double) (this.rand.nextFloat() * this.width * 2.0F) - (double) this.width, var1, var3, var5, new int[0]); } } }
protected void updateAITasks() { if (this.getGrowingAge() != 0) { this.inLove = 0; } super.updateAITasks(); }
protected void func_70629_bd() { if (--this.field_70955_e <= 0) { this.field_70170_p.field_72982_D.func_75551_a( MathHelper.func_76128_c(this.field_70165_t), MathHelper.func_76128_c(this.field_70163_u), MathHelper.func_76128_c(this.field_70161_v)); this.field_70955_e = 70 + this.field_70146_Z.nextInt(50); this.field_70954_d = this.field_70170_p.field_72982_D.func_75550_a( MathHelper.func_76128_c(this.field_70165_t), MathHelper.func_76128_c(this.field_70163_u), MathHelper.func_76128_c(this.field_70161_v), 32); if (this.field_70954_d == null) { this.func_110177_bN(); } else { ChunkCoordinates var1 = this.field_70954_d.func_75577_a(); this.func_110171_b( var1.field_71574_a, var1.field_71572_b, var1.field_71573_c, (int) ((float) this.field_70954_d.func_75568_b() * 0.6F)); if (this.field_82190_bM) { this.field_82190_bM = false; this.field_70954_d.func_82683_b(5); } } } if (!this.func_70940_q() && this.field_70961_j > 0) { --this.field_70961_j; if (this.field_70961_j <= 0) { if (this.field_70959_by) { if (this.field_70963_i.size() > 1) { Iterator var3 = this.field_70963_i.iterator(); while (var3.hasNext()) { MerchantRecipe var2 = (MerchantRecipe) var3.next(); if (var2.func_82784_g()) { var2.func_82783_a( this.field_70146_Z.nextInt(6) + this.field_70146_Z.nextInt(6) + 2); } } } this.func_70950_c(1); this.field_70959_by = false; if (this.field_70954_d != null && this.field_82189_bL != null) { this.field_70170_p.func_72960_a(this, (byte) 14); this.field_70954_d.func_82688_a(this.field_82189_bL, 1); } } this.func_70690_d(new PotionEffect(Potion.field_76428_l.field_76415_H, 200, 0)); } } super.func_70629_bd(); }
public void func_70014_b(NBTTagCompound p_70014_1_) { super.func_70014_b(p_70014_1_); p_70014_1_.func_74768_a("Profession", this.func_70946_n()); p_70014_1_.func_74768_a("Riches", this.field_70956_bz); if (this.field_70963_i != null) { p_70014_1_.func_74782_a("Offers", this.field_70963_i.func_77202_a()); } }
/** (abstract) Protected helper method to write subclass entity data to NBT. */ public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) { super.writeEntityToNBT(par1NBTTagCompound); par1NBTTagCompound.setInteger("Profession", this.getProfession()); par1NBTTagCompound.setInteger("Riches", this.wealth); if (this.buyingList != null) { par1NBTTagCompound.setCompoundTag("Offers", this.buyingList.getRecipiesAsTags()); } }
public void func_70037_a(NBTTagCompound p_70037_1_) { super.func_70037_a(p_70037_1_); this.func_70938_b(p_70037_1_.func_74762_e("Profession")); this.field_70956_bz = p_70037_1_.func_74762_e("Riches"); if (p_70037_1_.func_150297_b("Offers", 10)) { NBTTagCompound var2 = p_70037_1_.func_74775_l("Offers"); this.field_70963_i = new MerchantRecipeList(var2); } }
/** (abstract) Protected helper method to read subclass entity data from NBT. */ public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) { super.readEntityFromNBT(par1NBTTagCompound); this.setProfession(par1NBTTagCompound.getInteger("Profession")); this.wealth = par1NBTTagCompound.getInteger("Riches"); if (par1NBTTagCompound.hasKey("Offers")) { NBTTagCompound nbttagcompound1 = par1NBTTagCompound.getCompoundTag("Offers"); this.buyingList = new MerchantRecipeList(nbttagcompound1); } }
@SideOnly(Side.CLIENT) public void handleHealthUpdate(byte par1) { if (par1 == 12) { this.generateRandomParticles("heart"); } else if (par1 == 13) { this.generateRandomParticles("angryVillager"); } else if (par1 == 14) { this.generateRandomParticles("happyVillager"); } else { super.handleHealthUpdate(par1); } }
@Override protected boolean activateMachine() { List<?> entities = worldObj.getEntitiesWithinAABB( EntityAgeable.class, _areaManager.getHarvestArea().toAxisAlignedBB()); for (Object o : entities) { if (!(o instanceof EntityAgeable)) { continue; } EntityAgeable a = (EntityAgeable) o; if ((a.getGrowingAge() < 0 && !_moveOld) || (a.getGrowingAge() >= 0 && _moveOld)) { BlockPosition bp = BlockPosition.fromFactoryTile(this); bp.moveBackwards(1); a.setPosition(bp.x + 0.5, bp.y + 0.5, bp.z + 0.5); return true; } } setIdleTicks(getIdleTicksMax()); return false; }
public ItemStack compact(EntityLiving entity) { int id = EntityList.getEntityID(entity); ItemStack holder = new ItemStack(CompactMobsItems.fullMobHolder, 1); NBTTagCompound nbttag = holder.stackTagCompound; if (nbttag == null) { nbttag = new NBTTagCompound(); } nbttag.setInteger("entityId", id); if (entity instanceof EntityAgeable) { EntityAgeable entityAge = (EntityAgeable) entity; nbttag.setInteger("entityGrowingAge", entityAge.getGrowingAge()); } if (entity instanceof EntitySheep) { EntitySheep entitySheep = (EntitySheep) entity; nbttag.setBoolean("entitySheared", entitySheep.getSheared()); nbttag.setInteger("entityColor", entitySheep.getFleeceColor()); } if (CompactMobsCore.instance.useFullTagCompound) { NBTTagCompound entityTags = new NBTTagCompound(); NBTTagCompound var2 = new NBTTagCompound(); entity.writeToNBT(var2); nbttag.setCompoundTag("entityTags", var2); CompactMobsCore.instance.cmLog.info(var2.toString()); } String name = entity.getEntityName(); nbttag.setString("name", name); holder.setItemDamage(id); holder.setTagCompound(nbttag); entity.worldObj.removeEntity(entity); return holder; }
/** * 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; } }
public void func_70604_c(EntityLivingBase p_70604_1_) { super.func_70604_c(p_70604_1_); if (this.field_70954_d != null && p_70604_1_ != null) { this.field_70954_d.func_75575_a(p_70604_1_); if (p_70604_1_ instanceof EntityPlayer) { byte var2 = -1; if (this.func_70631_g_()) { var2 = -3; } this.field_70954_d.func_82688_a(p_70604_1_.func_70005_c_(), var2); if (this.func_70089_S()) { this.field_70170_p.func_72960_a(this, (byte) 13); } } } }
public void func_70645_a(DamageSource p_70645_1_) { if (this.field_70954_d != null) { Entity var2 = p_70645_1_.func_76346_g(); if (var2 != null) { if (var2 instanceof EntityPlayer) { this.field_70954_d.func_82688_a(var2.func_70005_c_(), -2); } else if (var2 instanceof IMob) { this.field_70954_d.func_82692_h(); } } else if (var2 == null) { EntityPlayer var3 = this.field_70170_p.func_72890_a(this, 16.0D); if (var3 != null) { this.field_70954_d.func_82692_h(); } } } super.func_70645_a(p_70645_1_); }
public void handleHealthUpdate(byte p_70103_1_) { if (p_70103_1_ == 18) { for (int var2 = 0; var2 < 7; ++var2) { double var3 = this.rand.nextGaussian() * 0.02D; double var5 = this.rand.nextGaussian() * 0.02D; double var7 = this.rand.nextGaussian() * 0.02D; this.worldObj.spawnParticle( EnumParticleTypes.HEART, this.posX + (double) (this.rand.nextFloat() * this.width * 2.0F) - (double) this.width, this.posY + 0.5D + (double) (this.rand.nextFloat() * this.height), this.posZ + (double) (this.rand.nextFloat() * this.width * 2.0F) - (double) this.width, var3, var5, var7, new int[0]); } } else { super.handleHealthUpdate(p_70103_1_); } }
/** Called when the mob's health reaches 0. */ public void onDeath(DamageSource par1DamageSource) { if (this.villageObj != null) { Entity entity = par1DamageSource.getEntity(); if (entity != null) { if (entity instanceof EntityPlayer) { this.villageObj.setReputationForPlayer( ((EntityPlayer) entity).getCommandSenderName(), -2); } else if (entity instanceof IMob) { this.villageObj.endMatingSeason(); } } else if (entity == null) { EntityPlayer entityplayer = this.worldObj.getClosestPlayerToEntity(this, 16.0D); if (entityplayer != null) { this.villageObj.endMatingSeason(); } } } super.onDeath(par1DamageSource); }
public void setRevengeTarget(EntityLiving par1EntityLiving) { super.setRevengeTarget(par1EntityLiving); if (this.villageObj != null && par1EntityLiving != null) { this.villageObj.addOrRenewAgressor(par1EntityLiving); if (par1EntityLiving instanceof EntityPlayer) { byte b0 = -1; if (this.isChild()) { b0 = -3; } this.villageObj.setReputationForPlayer( ((EntityPlayer) par1EntityLiving).getCommandSenderName(), b0); if (this.isEntityAlive()) { this.worldObj.setEntityState(this, (byte) 13); } } } }
/** (abstract) Protected helper method to read subclass entity data from NBT. */ public void readEntityFromNBT(NBTTagCompound tagCompund) { super.readEntityFromNBT(tagCompund); this.inLove = tagCompund.getInteger("InLove"); }
protected void func_70088_a() { super.func_70088_a(); this.field_70180_af.func_75682_a(16, Integer.valueOf(0)); }
protected void entityInit() { super.entityInit(); this.dataWatcher.addObject(16, Integer.valueOf(0)); }
/** main AI tick function, replaces updateEntityActionState */ protected void updateAITick() { if (--this.randomTickDivider <= 0) { this.worldObj.villageCollectionObj.addVillagerPosition( MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)); this.randomTickDivider = 70 + this.rand.nextInt(50); this.villageObj = this.worldObj.villageCollectionObj.findNearestVillage( MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ), 32); if (this.villageObj == null) { this.detachHome(); } else { ChunkCoordinates chunkcoordinates = this.villageObj.getCenter(); this.setHomeArea( chunkcoordinates.posX, chunkcoordinates.posY, chunkcoordinates.posZ, (int) ((float) this.villageObj.getVillageRadius() * 0.6F)); if (this.field_82190_bM) { this.field_82190_bM = false; this.villageObj.func_82683_b(5); } } } if (!this.isTrading() && this.timeUntilReset > 0) { --this.timeUntilReset; if (this.timeUntilReset <= 0) { if (this.needsInitilization) { if (this.buyingList.size() > 1) { Iterator iterator = this.buyingList.iterator(); while (iterator.hasNext()) { MerchantRecipe merchantrecipe = (MerchantRecipe) iterator.next(); if (merchantrecipe.func_82784_g()) { merchantrecipe.func_82783_a(this.rand.nextInt(6) + this.rand.nextInt(6) + 2); } } } this.addDefaultEquipmentAndRecipies(1); this.needsInitilization = false; if (this.villageObj != null && this.lastBuyingPlayer != null) { this.worldObj.setEntityState(this, (byte) 14); this.villageObj.setReputationForPlayer(this.lastBuyingPlayer, 1); } } this.addPotionEffect(new PotionEffect(Potion.regeneration.id, 200, 0)); } } super.updateAITick(); }
protected void func_110147_ax() { super.func_110147_ax(); this.func_110148_a(SharedMonsterAttributes.field_111263_d).func_111128_a(0.5D); }
@Override public EntityAgeable createChildTFC(EntityAgeable entityageable) { ArrayList<Float> data = new ArrayList<Float>(); data.add(entityageable.getEntityData().getFloat("MateSize")); return new EntityChickenTFC(worldObj, this, data); }
/** (abstract) Protected helper method to write subclass entity data to NBT. */ public void writeEntityToNBT(NBTTagCompound tagCompound) { super.writeEntityToNBT(tagCompound); tagCompound.setInteger("InLove", this.inLove); }