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

Started by chuiod steve on Mon, 08/31/2020 - 22:10

Topic category: User side tutorials

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

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
How can I make the creature follow me for a long distance?
Mon, 08/31/2020 - 22:10
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 18:22, 21. Oct 2020
Joined Jan 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • 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
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • 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 01:49, 16. Sep 2020
Joined Aug 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • 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 01:27, 5. Sep 2020
Joined Apr 2017
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • 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 01:27, 5. Sep 2020
Joined Apr 2017
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • 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.