Jump to content

1.7.10 problem with mob not defending


DarkFlameMaster

Recommended Posts

Here are my ai classes OwnerHurtbyTarget and OwnerHurtTarget i dont know why he is not defending me when he is tamed just runs away xD help pls

 

 

 

OwnerHurtbyTarget

 

package com.medamobs.AI;

 

import java.util.Iterator;

import java.util.List;

 

import net.minecraft.entity.EntityCreature;

import net.minecraft.entity.EntityLivingBase;

import net.minecraft.entity.ai.EntityAITarget;

import net.minecraft.util.AxisAlignedBB;

 

import com.medamobs.entities.MedabotBase;

 

public class MedamobsEntityAIOwnerHurtByTarget extends EntityAITarget

{

    MedabotBase theDefendingTameable;

    EntityLivingBase theOwnerAttacker;

    private int field_142051_e;

private int field_142052_b;

private boolean entityCallsForHelp;

 

    public MedamobsEntityAIOwnerHurtByTarget(MedabotBase par1EntityTameable)

    {

        super(par1EntityTameable, false);

        this.theDefendingTameable = par1EntityTameable;

        this.setMutexBits(1);

    }

 

    /**

    * Returns whether the EntityAIBase should begin execution.

    */

    public boolean shouldExecute()

    {

        int i = this.taskOwner.func_142015_aE();

        return i != this.field_142052_b && this.isSuitableTarget(this.taskOwner.getAITarget(), false);

    }

 

    /**

    * Execute a one shot task or start executing a continuous task

    */

    public void startExecuting()

    {

        this.taskOwner.setAttackTarget(this.taskOwner.getAITarget());

        this.field_142052_b = this.taskOwner.func_142015_aE();

 

        if (this.entityCallsForHelp)

        {

            double d0 = this.getTargetDistance();

            List list = this.taskOwner.worldObj.getEntitiesWithinAABB(this.taskOwner.getClass(), AxisAlignedBB.getBoundingBox(this.taskOwner.posX, this.taskOwner.posY, this.taskOwner.posZ, this.taskOwner.posX + 1.0D, this.taskOwner.posY + 1.0D, this.taskOwner.posZ + 1.0D).expand(d0, 10.0D, d0));

            Iterator iterator = list.iterator();

 

            while (iterator.hasNext())

            {

                EntityCreature entitycreature = (EntityCreature)iterator.next();

 

                if (this.taskOwner != entitycreature && entitycreature.getAttackTarget() == null && !entitycreature.isOnSameTeam(this.taskOwner.getAITarget()))

                {

                    entitycreature.setAttackTarget(this.taskOwner.getAITarget());

                }

            }

        }

 

        super.startExecuting();

    }

}

 

 

 

OwnerHurtTarget

 

package com.medamobs.AI;

 

import java.util.Iterator;

import java.util.List;

 

import net.minecraft.entity.EntityCreature;

import net.minecraft.entity.EntityLivingBase;

import net.minecraft.entity.ai.EntityAITarget;

import net.minecraft.util.AxisAlignedBB;

 

import com.medamobs.entities.MedabotBase;

 

public class MedamobsEntityAIOwnerHurtTarget extends EntityAITarget

{

MedabotBase theEntityTameable;

    EntityLivingBase theTarget;

    private int field_142050_e;

private boolean entityCallsForHelp;

private int field_142052_b;

 

    public MedamobsEntityAIOwnerHurtTarget(MedabotBase par1EntityTameable)

    {

        super(par1EntityTameable, false);

        this.theEntityTameable = par1EntityTameable;

        this.setMutexBits(1);

    }

 

    /**

    * Returns whether the EntityAIBase should begin execution.

    */

    public boolean shouldExecute()

    {

        if (!this.theEntityTameable.isTamed())

        {

            return false;

        }

        else

        {

            EntityLivingBase entitylivingbase = this.theEntityTameable.func_130012_q();

 

            if (entitylivingbase == null)

            {

                return false;

            }

            else

            {

                this.theTarget = entitylivingbase.getLastAttacker();

                int i = entitylivingbase.getLastAttackerTime();

                return i != this.field_142050_e && this.isSuitableTarget(this.theTarget, false) && this.theEntityTameable.func_142018_a(this.theTarget, entitylivingbase);

            }

        }

    }

 

    /**

    * Execute a one shot task or start executing a continuous task

    */

    public void startExecuting()

    {

        this.taskOwner.setAttackTarget(this.taskOwner.getAITarget());

        this.field_142052_b = this.taskOwner.func_142015_aE();

 

        if (this.entityCallsForHelp)

        {

            double d0 = this.getTargetDistance();

            List list = this.taskOwner.worldObj.getEntitiesWithinAABB(this.taskOwner.getClass(), AxisAlignedBB.getBoundingBox(this.taskOwner.posX, this.taskOwner.posY, this.taskOwner.posZ, this.taskOwner.posX + 1.0D, this.taskOwner.posY + 1.0D, this.taskOwner.posZ + 1.0D).expand(d0, 10.0D, d0));

            Iterator iterator = list.iterator();

 

            while (iterator.hasNext())

            {

                EntityCreature entitycreature = (EntityCreature)iterator.next();

 

                if (this.taskOwner != entitycreature && entitycreature.getAttackTarget() == null && !entitycreature.isOnSameTeam(this.taskOwner.getAITarget()))

                {

                    entitycreature.setAttackTarget(this.taskOwner.getAITarget());

                }

            }

        }

 

        super.startExecuting();

    }

}

 

Link to comment
Share on other sites

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.