package micdoodle8.mods.galacticraft.planets.mars.entities; import micdoodle8.mods.galacticraft.api.entity.IEntityBreathable; import micdoodle8.mods.galacticraft.core.entities.EntityEvolvedCreeper; import micdoodle8.mods.galacticraft.core.entities.EntityEvolvedSkeleton; import micdoodle8.mods.galacticraft.core.entities.EntityEvolvedSpider; import micdoodle8.mods.galacticraft.core.entities.EntityEvolvedZombie; import net.minecraft.block.Block; import net.minecraft.entity.EnumCreatureAttribute; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.EntityAIAttackOnCollide; import net.minecraft.entity.ai.EntityAINearestAttackableTarget; import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.util.BlockPos; import net.minecraft.world.World; public class EntitySludgeling extends EntityMob implements IEntityBreathable { public EntitySludgeling(World par1World) { super(par1World); this.setSize(0.3F, 0.2F); this.tasks.taskEntries.clear(); this.targetTasks.taskEntries.clear(); this.tasks.addTask(1, new EntityAIAttackOnCollide(this, 0.25F, true)); this.tasks.addTask(4, new EntityAIAttackOnCollide(this, EntityPlayer.class, 1.0D, false)); this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, false, true, null)); this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityEvolvedZombie.class, 0, false, true, null)); this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityEvolvedSkeleton.class, 0, false, true, null)); this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityEvolvedSpider.class, 0, false, true, null)); this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityEvolvedCreeper.class, 0, false, true, null)); this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntitySlimeling.class, 200, false, true, null)); } @Override public boolean canBreatheUnderwater() { return true; } @Override protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(7.0D); this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(1.0F); } @Override protected boolean canTriggerWalking() { return false; } @Override protected String getLivingSound() { return "mob.silverfish.say"; } @Override protected String getHurtSound() { return "mob.silverfish.hit"; } @Override protected String getDeathSound() { return "mob.silverfish.kill"; } public EntityPlayer getClosestEntityToAttack(double par1, double par3, double par5, double par7) { double var9 = -1.0D; EntityPlayer var11 = null; for (int var12 = 0; var12 < this.worldObj.loadedEntityList.size(); ++var12) { EntityPlayer var13 = (EntityPlayer) this.worldObj.loadedEntityList.get(var12); double var14 = var13.getDistanceSq(par1, par3, par5); if ((par7 < 0.0D || var14 < par7 * par7) && (var9 == -1.0D || var14 < var9)) { var9 = var14; var11 = var13; } } return var11; } @Override protected void playStepSound(BlockPos pos, Block block) { this.worldObj.playSoundAtEntity(this, "mob.silverfish.step", 1.0F, 1.0F); } @Override protected Item getDropItem() { return Item.getItemFromBlock(Blocks.air); } @Override public void onUpdate() { this.renderYawOffset = this.rotationYaw; super.onUpdate(); } @Override protected boolean isValidLightLevel() { return true; } @Override public boolean getCanSpawnHere() { if (super.getCanSpawnHere()) { EntityPlayer var1 = this.worldObj.getClosestPlayerToEntity(this, 5.0D); return var1 == null; } else { return false; } } @Override public EnumCreatureAttribute getCreatureAttribute() { return EnumCreatureAttribute.ARTHROPOD; } @Override public boolean canBreath() { return true; } }