How can I make the creature follow me for a long distance?

Started by chuiod steve on

Topic category: User side tutorials

Last seen on 17:57, 3. Sep 2020
Joined Feb 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How can I make the creature follow me for a long distance?
The title says it all, how can I make a creature follow me long distances? If you know please tell me, I would really appreciate it.
Last seen on 22:49, 17. Mar 2021
Joined Jan 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You could get it to follow…
Tue, 09/01/2020 - 16:25

You could get it to follow you if you're holding something, the way pigs follow carrots or sheep/cows follow wheat, in the AI section.

Last seen on 17:57, 3. Sep 2020
Joined Feb 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I didn't say exactly that,…
Thu, 09/03/2020 - 03:57
I didn't say exactly that, but I want him to follow me long distances to attack me.

Last seen on 00:02, 26. Mar 2021
Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
First make sure that mob can…
Thu, 09/03/2020 - 05:44

First make sure that mob can see long distances(AI tasks), then make it attack when it sees you, that simple :)

Last seen on 19:38, 13. Jul 2023
Joined Apr 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Here's a solution you can do…
Sat, 09/05/2020 - 01:27

Here's a solution you can do in the code for your mob. It is really simple, and easy to do.

Go down to the section of the code that looks something like this:

@Override
		protected void registerAttributes() {
			super.registerAttributes();
			if (this.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED) != null)
				this.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.3);
			if (this.getAttribute(SharedMonsterAttributes.MAX_HEALTH) != null)
				this.getAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(300);
			if (this.getAttribute(SharedMonsterAttributes.ARMOR) != null)
				this.getAttribute(SharedMonsterAttributes.ARMOR).setBaseValue(20);
			if (this.getAttribute(SharedMonsterAttributes.ATTACK_DAMAGE) == null)
				this.getAttributes().registerAttribute(SharedMonsterAttributes.ATTACK_DAMAGE);
			this.getAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(3);
		}

In the code, you'll want to add:

if (this.getAttribute(SharedMonsterAttributes.FOLLOW_RANGE) != null)
                this.getAttribute(SharedMonsterAttributes.FOLLOW_RANGE).setBaseValue(50);   <--- (this number can be whatever you want)

 

It should now look something like this:

@Override
		protected void registerAttributes() {
			super.registerAttributes();
			if (this.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED) != null)
				this.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.3);
			if (this.getAttribute(SharedMonsterAttributes.MAX_HEALTH) != null)
				this.getAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(300);
			if (this.getAttribute(SharedMonsterAttributes.FOLLOW_RANGE) != null)
				this.getAttribute(SharedMonsterAttributes.FOLLOW_RANGE).setBaseValue(50);
			if (this.getAttribute(SharedMonsterAttributes.ARMOR) != null)
				this.getAttribute(SharedMonsterAttributes.ARMOR).setBaseValue(20);
			if (this.getAttribute(SharedMonsterAttributes.ATTACK_DAMAGE) == null)
				this.getAttributes().registerAttribute(SharedMonsterAttributes.ATTACK_DAMAGE);
			this.getAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(3);
		}

 

Last seen on 19:38, 13. Jul 2023
Joined Apr 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Also, I apologize for the…
Sat, 09/05/2020 - 01:28

Also, I apologize for the janky code snippet. I never use code snippets as you might imagine.

Last seen on 14:19, 13. Feb 2022
Joined Nov 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Hey, how can i do this in…
Thu, 10/07/2021 - 20:59

Hey, how can i do this in 2021.2?