Jump to content

Recommended Posts

Posted

I am creating a simple enemy that attacks the player, but I cannot make him actually deal damage to the player. All he does is run towards the player and make contact with him. No damage is dealt.

 

Code:

    public EntitySpecGhost(World worldIn)
    {
        super(worldIn);
        this.setSize(1, 2.4f);
    }

    @Override
    protected void initEntityAI()
    {
        tasks.addTask(0, new EntityAISwimming(this));
        tasks.addTask(1, new EntityAIAttackMelee(this, 2, true));
        tasks.addTask(2, new EntityAILookIdle(this));
        tasks.addTask(3, new EntityAIWatchClosest(this, EntityPlayer.class, 100));
        tasks.addTask(4, new EntityAIWander(this, 1));
        targetTasks.addTask(0, new EntityAIHurtByTarget(this, true));
    }

    @Override
    protected void applyEntityAttributes()
    {
        super.applyEntityAttributes();
        getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(15);
    }
    @Nullable
    @Override
    protected SoundEvent getHurtSound(DamageSource damageSourceIn)
    {
        return null;
    }

    @Nullable
    @Override
    protected SoundEvent getDeathSound()
    {
        return null;
    }

    @Override
    protected void playStepSound(BlockPos pos, Block blockIn)
    {
    }

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.