@Override public void readEntityFromNBT(NBTTagCompound tag) { super.readEntityFromNBT(tag); if (tag.hasKey("phase") && tag.hasKey("phaseDamage")) { float f = this.getMaxHealth() / 5; switch (tag.getInteger("phase")) { case 0: f *= 5; break; case 1: f *= 4; break; case 2: f *= 3; break; case 3: f *= 2; break; case 4: default: break; } this.setHealth(f - tag.getFloat("phaseDamage")); } if (tag.hasKey("phaseTicks")) this.setPhaseTicks(tag.getInteger("phaseTicks")); }
@Override public void writeEntityToNBT(NBTTagCompound tag) { super.writeEntityToNBT(tag); tag.setInteger("phase", this.getCurrentPhase()); tag.setBoolean("phaseChange", this.phaseChange); tag.setFloat("phaseDamage", this.phaseDamage); tag.setInteger("phaseTicks", this.getPhaseTicks()); }
@Override protected void applyEntityAttributes() { super.applyEntityAttributes(); double[] overlordCocoonStats = TragicConfig.getMobStat("overlordCocoonStats").getStats(); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(overlordCocoonStats[0]); this.getEntityAttribute(SharedMonsterAttributes.movementSpeed) .setBaseValue(overlordCocoonStats[1]); this.getEntityAttribute(SharedMonsterAttributes.attackDamage) .setBaseValue(overlordCocoonStats[2]); this.getEntityAttribute(SharedMonsterAttributes.followRange) .setBaseValue(overlordCocoonStats[3]); this.getEntityAttribute(SharedMonsterAttributes.knockbackResistance) .setBaseValue(overlordCocoonStats[4]); }
@Override public void onDeath(DamageSource par1DamageSource) { super.onDeath(par1DamageSource); if (par1DamageSource.getEntity() instanceof EntityPlayerMP) ((EntityPlayerMP) par1DamageSource.getEntity()) .triggerAchievement(TragicAchievements.overlord2); List<EntityPlayerMP> list = this.worldObj.getEntitiesWithinAABB( EntityPlayerMP.class, this.getEntityBoundingBox().expand(24.0, 24.0, 24.0)); if (!list.isEmpty()) { for (EntityPlayerMP mp : list) { mp.triggerAchievement(TragicAchievements.overlord2); } } }
@Override public void onLivingUpdate() { this.rotationYaw = this.rotationPitch = this.prevRotationPitch = this.prevRotationYaw = 0; this.motionX = this.motionZ = 0D; this.motionY = -1D; super.onLivingUpdate(); if (this.worldObj.isRemote) return; EntitySeeker seek; for (int i = 0; i < this.seekers.size(); i++) { seek = this.seekers.get(i); if (seek.isDead || seek.getHealth() <= 0 || this.getDistanceToEntity(seek) >= 32.0) this.seekers.remove(seek); } List<EntitySeeker> lst = this.worldObj.getEntitiesWithinAABB( EntitySeeker.class, this.getEntityBoundingBox().expand(32.0, 32.0, 32.0)); for (EntitySeeker sk : lst) { if (sk.getOwner() == null) { sk.setOwner(this); this.seekers.add(sk); } else if (sk.getOwner() == this && !this.seekers.contains(sk)) { this.seekers.add(sk); } } if (this.seekers.isEmpty() && this.ticksExisted % 100 == 0 && !TragicConfig.getBoolean("overlordPhases")) this.spawnSeekers(); if (this.seekers.isEmpty() && this.getPhaseTicks() == 0 && this.deathTime == 0 && TragicConfig.getBoolean("overlordPhases")) this.setPhaseTicks(200); if (this.getPhaseTicks() > 0 && TragicConfig.getBoolean("overlordPhases")) { this.setPhaseTicks(this.getPhaseTicks() - 1); if (TragicConfig.getBoolean("overlordGas")) { List<BlockPos> lst2 = WorldHelper.getBlocksInSphericalRange( this.worldObj, 3.5, this.posX + rand.nextInt(4) - rand.nextInt(4), this.posY, this.posZ + rand.nextInt(4) - rand.nextInt(4)); for (BlockPos coords : lst2) { if (World.doesBlockHaveSolidTopSurface(this.worldObj, coords.down()) && EntityOverlordCore.replaceableBlocks.contains( this.worldObj.getBlockState(coords).getBlock())) { this.worldObj.setBlockState(coords, TragicBlocks.CorruptedGas.getDefaultState()); } } } if (this.phaseChange) { this.phaseChange = false; this.setPhaseTicks(0); for (EntitySeeker sk : this.seekers) sk.setDead(); this.spawnSeekers(); this.phaseDamage = 0F; if (this.getHealth() > 0F) { float f = this.getMaxHealth() / 5; switch (this.getCurrentPhase()) { case 0: f *= 4; break; case 1: f *= 3; break; case 2: f *= 2; break; case 3: break; case 4: f = 0; break; default: break; } this.setHealth(f); } if (TragicConfig.getBoolean("allowDivinity")) { List<Entity> list = this.worldObj.getEntitiesWithinAABBExcludingEntity( this, this.getEntityBoundingBox().expand(64.0, 64.0, 64.0)); for (Entity e : list) { if (e instanceof EntityLivingBase && ((EntityLivingBase) e).isPotionActive(TragicPotion.Divinity)) ((EntityLivingBase) e).removePotionEffect(TragicPotion.Divinity.id); } } if (TragicConfig.getBoolean("allowMobSounds")) this.worldObj.playSoundAtEntity( this, "tragicmc:boss.overlordcocoon.phasecomplete", 1.8F, 1.0F); } else { if (this.getPhaseTicks() == 199) { if (TragicConfig.getBoolean("allowDivinity")) { List<Entity> list = this.worldObj.getEntitiesWithinAABBExcludingEntity( this, this.getEntityBoundingBox().expand(64.0, 64.0, 64.0)); for (Entity e : list) { if (e instanceof EntityLivingBase && !((EntityLivingBase) e).isPotionActive(TragicPotion.Divinity)) ((EntityLivingBase) e) .addPotionEffect(new PotionEffect(TragicPotion.Divinity.id, 200)); } } } if (this.getPhaseTicks() == 0) { if (this.getHealth() > 0F) { float f = this.getMaxHealth() / 5; switch (this.getCurrentPhase()) { case 0: f *= 5; break; case 1: f *= 4; break; case 2: f *= 3; break; case 3: f *= 2; break; case 4: default: break; } this.setHealth(f); } this.phaseDamage = 0F; for (EntitySeeker sk : this.seekers) sk.setDead(); this.spawnSeekers(); if (TragicConfig.getBoolean("allowDivinity")) { List<Entity> list = this.worldObj.getEntitiesWithinAABBExcludingEntity( this, this.getEntityBoundingBox().expand(64.0, 64.0, 64.0)); for (Entity e : list) { if (e instanceof EntityLivingBase && ((EntityLivingBase) e).isPotionActive(TragicPotion.Divinity)) ((EntityLivingBase) e).removePotionEffect(TragicPotion.Divinity.id); } } if (TragicConfig.getBoolean("allowMobSounds")) this.worldObj.playSoundAtEntity( this, "tragicmc:boss.overlordcocoon.phasefail", 1.8F, 1.0F); } if (TragicConfig.getBoolean("allowMobSounds") && this.getPhaseTicks() % 10 == 0) this.worldObj.playSoundAtEntity(this, "tragicmc:boss.overlordcocoon.wah", 1.4F, 1.0F); } } }
@Override protected void entityInit() { super.entityInit(); this.dataWatcher.addObject(DW_PHASE_TICKS, Integer.valueOf(0)); // phaseTicks }