package viruz.zeamateis.mobs.monster; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EnumCreatureAttribute; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.EntityAIAttackOnCollide; import net.minecraft.entity.ai.EntityAIBreakDoor; import net.minecraft.entity.ai.EntityAIHurtByTarget; import net.minecraft.entity.ai.EntityAILookIdle; import net.minecraft.entity.ai.EntityAIMoveThroughVillage; import net.minecraft.entity.ai.EntityAIMoveTowardsRestriction; import net.minecraft.entity.ai.EntityAINearestAttackableTarget; import net.minecraft.entity.ai.EntityAISwimming; import net.minecraft.entity.ai.EntityAIWander; import net.minecraft.entity.ai.EntityAIWatchClosest; import net.minecraft.entity.ai.attributes.Attribute; import net.minecraft.entity.ai.attributes.RangedAttribute; import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.DamageSource; import net.minecraft.world.World; import net.minecraftforge.common.ForgeDummyContainer; import viruz.zeamateis.achievementsManager.AchievementManager; import viruz.zeamateis.manage.ConfigFileManager; import viruz.zeamateis.manage.DropsManager; import viruz.zeamateis.misc.Effect; import viruz.zeamateis.misc.MalusEffect; import viruz.zeamateis.mobs.agressive.EntityBandit; public class EntityZombieCrawler extends EntityMob { protected static final Attribute field_110186_bp = (new RangedAttribute("zombie.spawnReinforcements", 0.0D, 0.0D, 1.0D)).func_111117_a("Spawn Reinforcements Chance"); public int texture; public EntityZombieCrawler(World par1World) { super(par1World); texture = this.worldObj.rand.nextInt(54)+0; this.setSize(1.3F, 0.7F); this.getNavigator().setBreakDoors(true); this.tasks.addTask(0, new EntityAISwimming(this)); this.tasks.addTask(1, new EntityAIBreakDoor(this)); this.tasks.addTask(2, new EntityAIAttackOnCollide(this, EntityPlayer.class, 1.0D, false)); this.tasks.addTask(3, new EntityAIAttackOnCollide(this, EntityBandit.class, 1.0D, true)); this.tasks.addTask(4, new EntityAIMoveTowardsRestriction(this, 1.0D)); this.tasks.addTask(5, new EntityAIMoveThroughVillage(this, 1.0D, false)); this.tasks.addTask(6, new EntityAIWander(this, 1.0D)); this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); this.tasks.addTask(7, new EntityAILookIdle(this)); this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true)); this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true)); this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityBandit.class, 0, false)); } protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(15D); this.getEntityAttribute(SharedMonsterAttributes.followRange).setAttribute(40.0D); this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setAttribute(0.1D); this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setAttribute(ConfigFileManager.attackStrengthZombieCrawler); this.getAttributeMap().func_111150_b(field_110186_bp).setAttribute(this.rand.nextDouble() * ForgeDummyContainer.zombieSummonBaseChance); } protected boolean canDespawn() { return true; } public void onDeath(DamageSource damagesource) { Entity entity = damagesource.getEntity(); if(entity != null && entity instanceof EntityPlayer) { ((EntityPlayer)entity).triggerAchievement(AchievementManager.AchievementKillZombies); } super.onDeath(damagesource); } /** * Returns true if the newer Entity AI code should be run */ protected boolean isAIEnabled() { return true; } /* public void onLivingUpdate() { super.onLivingUpdate(); }*/ /* public void onUpdate() { super.onUpdate(); }*/ @Override public boolean attackEntityAsMob(Entity entity) { if (worldObj.difficultySetting == 1) { int j = rand.nextInt(10); int k = rand.nextInt(20); if (k == 0) { ((EntityLivingBase) entity).addPotionEffect(new Effect(MalusEffect.zombification.getId(), 20 * 300, 1)); } if (j == 0) { ((EntityLivingBase) entity).addPotionEffect(new PotionEffect(Potion.weakness.getId(), 20 * 120, 1)); } if (k == 0) { ((EntityLivingBase) entity).addPotionEffect(new PotionEffect(Potion.digSlowdown.getId(), 20 * 120, 1)); } return entity.attackEntityFrom(DamageSource.causeMobDamage(this), 2); } else if (worldObj.difficultySetting == 2) { int j = rand.nextInt(5); int k = rand.nextInt(10); if (k == 0) { ((EntityLivingBase) entity).addPotionEffect(new Effect(MalusEffect.zombification.getId(), 20 * 300, 1)); } if (j == 0) { ((EntityLivingBase) entity).addPotionEffect(new PotionEffect(Potion.weakness.getId(), 20 * 120, 1)); } if (k == 0) { ((EntityLivingBase) entity).addPotionEffect(new PotionEffect(Potion.digSlowdown.getId(), 20 * 120, 1)); } return entity.attackEntityFrom(DamageSource.causeMobDamage(this), 3); } else if (worldObj.difficultySetting == 3) { int j = rand.nextInt(3); int k = rand.nextInt(6); if (k == 0) { ((EntityLivingBase) entity).addPotionEffect(new Effect(MalusEffect.zombification.getId(), 20 * 300, 1)); } if (j == 0) { ((EntityLivingBase) entity).addPotionEffect(new PotionEffect(Potion.weakness.getId(), 20 * 120, 1)); } if (k == 0) { ((EntityLivingBase) entity).addPotionEffect(new PotionEffect(Potion.digSlowdown.getId(), 20 * 120, 1)); } return entity.attackEntityFrom(DamageSource.causeMobDamage(this), 6); } else { return false; } } /** * Returns the sound this mob makes while it's alive. */ protected String getLivingSound() { return "viruz:moaning.moan"; } /** * Returns the sound this mob makes when it is hurt. */ protected String getHurtSound() { return "viruz:punch_it"; } /** * Returns the sound this mob makes on death. */ protected String getDeathSound() { return "viruz:male.death"; } /** * Plays step sound at given x, y, z for the entity */ protected void playStepSound(int p1, int p2, int p3, int p4) { this.playSound("mob.zombie.step", 0.15F, 1.0F); } protected void dropFewItems(boolean par1, int par2) { int j = this.rand.nextInt(3) + 1; if (par1) { int j1 = this.rand.nextInt(2 + par2); for (int k = 0; k < j1; ++k) { this.dropItem(Item.netherStalkSeeds.itemID, 1); } } for (int k = 0; k < j; ++k) { int l = this.rand.nextInt(3); int i1 = DropsManager.ZombiesDrops1[this.rand.nextInt(DropsManager.ZombiesDrops1.length)]; if (par2 > 0) { l += this.rand.nextInt(par2 + 1); } for (int j1 = 0; j1 < l; ++j1) { this.dropItem(i1, 1); } } } protected void dropRareDrop(int par1) { this.entityDropItem(new ItemStack(Item.diamond.itemID, 1, 1), 0.0F); this.entityDropItem(new ItemStack(Item.ingotGold.itemID, 1, 1), 0.0F); this.entityDropItem(new ItemStack(Item.ingotIron.itemID, 1, 1), 0.0F); } /** * Get this Entity's EnumCreatureAttribute */ public EnumCreatureAttribute getCreatureAttribute() { return EnumCreatureAttribute.UNDEAD; } }