Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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.

 

  • Author

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.