Jump to content

[1.7.10] Move entity mob.


zlappedx3

Recommended Posts

You need to give your mob some AI. Using vanilla classes, you can add things like:

// your mob will wander aimlessly
tasks.addTask(5, new EntityAIWander(this, 1.0D));

// your mob will move towards and attack players
targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true));

There are lots of other examples in vanilla code - check out the various mobs such as Zombies, Skeletons, etc.

 

Spiders are a good example of a custom movement / navigation type, and you can override #getBlockPathWeight in any mob using movement AI to modify what it considers a good path.

 

Link to comment
Share on other sites

I create new class name AIMoveHuman by this class is EntityAIWander.

 

public class AIMoveHuman extends EntityAIBase
{
    private EntitySoliderMelee entity;
    private int xPosition;
    private double yPosition;
    private int zPosition;
    private double speed;
    
    private static int n = 0;
    
    public AIMoveHuman(EntitySoliderMelee p_i1648_1_, double p_i1648_2_)
    {
        this.entity = p_i1648_1_;
        this.speed = p_i1648_2_;
        this.setMutexBits(1);
    }

    /**
     * Returns whether the EntityAIBase should begin execution.
     */
    public boolean shouldExecute()
    {
    	this.xPosition = this.entity.PositionX.get(n);
        this.yPosition = this.entity.posY;
        this.zPosition = this.entity.PositionZ.get(n);
    	
        int a = this.n + 1;
        
        if(a != this.entity.PositionX.size()){
        	this.n++;
        }
	return true;
    }
    
    /**
     * Returns whether an in-progress EntityAIBase should continue executing
     */
    public boolean continueExecuting()
    {
        return !this.entity.getNavigator().noPath();
    }

    /**
     * Execute a one shot task or start executing a continuous task
     */
    public void startExecuting()
    {
        this.entity.getNavigator().tryMoveToXYZ(this.xPosition, this.yPosition, this.zPosition, this.speed);
    }
}

 

it will move follow list in entity.

 

I will try add EntityAINearestAttackableTarget, if i have a problem, i will comback this post.

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.