public EntityAnimalTFC(World par1World, EntityAnimalTFC mother, float F_size) { super(par1World); animalID = TFCSeasons.getTotalTicks() + entityId; hunger = 168000; pickUp = 0; breeding = 0; matingStart = 0; matingEnd = 0; mateForLife = false; rutting = false; ruttVictor = false; pregnant = false; pregnancyTime = 120; conception = 0; mateSizeMod = 0; parent = mother; mate = null; sex = rand.nextInt(2); tasks.addTask(1, new EntityAIMoveTowardsFood(this, 0.4F, 20F)); tasks.addTask(3, new EntityAITargetTFC(this, 12.0F, false)); tasks.addTask(2, new EntityAIFollowParentTFC(this, 0.2F)); size_mod = (float) (((rand.nextInt(getDegree() + 1) - getDegree() / 2) / 10f) + 1F) * (1.0F - 0.1F * sex) * (float) Math.sqrt((mother.size_mod + F_size) / 1.9F); birthTime = TFCSeasons.getTotalTicks(); adultAge = 90; adultTime = birthTime + TFCSettings.dayLength * adultAge; }
public EntityAnimalTFC(World par1World) { super(par1World); animalID = TFCSeasons.getTotalTicks() + entityId; hunger = 168000; pickUp = 0; panic = 0; breeding = 0; matingStart = 0; matingEnd = 0; mateForLife = false; rutting = false; ruttVictor = false; pregnant = false; pregnancyTime = 120; conception = 0; mateSizeMod = 0; parent = null; mate = null; sex = rand.nextInt(2); tasks.addTask(1, new EntityAIMoveTowardsFood(this, 0.4F, 20F)); tasks.addTask(3, new EntityAITargetTFC(this, 12.0F, false)); tasks.addTask(2, new EntityAIFollowParentTFC(this, 0.2F)); size_mod = (float) (((rand.nextInt(degreeOfDiversion) - 2) / 10f) + 1F) * (1.0F - 0.1F * sex); birthTime = TFCSeasons.getTotalTicks(); adultTime = birthTime; adultAge = 90; }
public void mate(EntityAnimalTFC targetMate) { if (sex == 0) { targetMate.mate(this); return; } conception = TFCSeasons.getTotalTicks(); pregnant = true; targetMate.setGrowingAge(TFCSettings.dayLength); resetInLove(); targetMate.resetInLove(); mateSizeMod = targetMate.size_mod; }
public void onLivingUpdate() { if (hunger > 168000) { hunger = 168000; } if (hunger > 0) { hunger--; } /** This Cancels out the growingAge from EntityAgeable */ int var1 = this.getGrowingAge(); super.onLivingUpdate(); this.setGrowingAge(var1); if (panic > 0) { panic--; } long i = TFCSeasons.getTotalTicks() - adultTime; if (i < 0) { i++; setGrowingAge((int) i); } else if (i > 0) { i--; setGrowingAge((int) i); } /*if(pregnant){ if(TFCSeasons.getTotalTicks() >= conception + pregnancyTime*TFCSettings.dayLength){ EntityAnimalTFC baby = new EntityAnimalTFC(worldObj, this,mateSizeMod); giveBirth(baby); pregnant = false; } }*/ if (this.getGrowingAge() != 0) { this.inLove = 0; } if (this.inLove > 0) { --this.inLove; String heart = "heart"; if (this.inLove % 10 == 0) { double var2 = this.rand.nextGaussian() * 0.02D; double var4 = this.rand.nextGaussian() * 0.02D; double var6 = this.rand.nextGaussian() * 0.02D; this.worldObj.spawnParticle( 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, var2, var4, var6); } } else { this.breeding = 0; } if (pickUp > 0) { pickUp--; } if (hunger > 144000 && rand.nextInt(100) == 0 && health < getMaxHealth()) { health++; } for (EntityItem ei : this.capturedDrops) { ItemStack item = ei.item; if (item != null) { if (hunger < 144000 && fooditems.contains(item.itemID)) { renderBrokenItemStack(item); item = null; hunger += 24000; worldObj.playSoundAtEntity( this, "random.eat", 0.5F + 0.5F * (float) rand.nextInt(2), (rand.nextFloat() - rand.nextFloat()) * 0.2F + 1.0F); } } } if (getHealth() > 0) { List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.expand(1.0D, 0.0D, 1.0D)); if (list != null) { for (int j = 0; j < list.size(); j++) { Entity entity = (Entity) list.get(j); if (!entity.isDead) { // entity.onCollideWithAnimal (this); } } } } if (TFCSeasons.getTotalTicks() > (birthTime + adultAge * TFCSettings.dayLength)) { setGrowingAge(0); } else if (isChild()) { setGrowingAge( (int) (TFCSeasons.getTotalTicks() - (birthTime + adultAge * TFCSettings.dayLength))); } }
@Override public void setGrowingAge(int par1) { adultTime = TFCSeasons.getTotalTicks() - par1; dataWatcher.updateObject(12, Integer.valueOf(par1)); }