Mob that doesnt attack mobs of the same type

Started by Chiwi on

Topic category: Help with modding (Java Edition)

Last seen on 20:41, 16. Apr 2024
Joined Jun 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Mob that doesnt attack mobs of the same type

Is it possible that mobs that makes ranged attacks dont attack other mobs like them. I mean, when they are shooting, if accidentally hit other mob of the same type, they start to shoot each other. I tried a lot of different combinations but i dont get it 

Last seen on 16:18, 11. Feb 2024
Joined Apr 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You could possibly make the…
Sun, 05/03/2020 - 16:01

You could possibly make the mob immune to ranged attacks, but this would also prevent he player from using ranged weapons on the mob.

Otherwise;

I do not believe there is a way to do this without using the built in code editor, and if it comes down to writing AI task codes, I would get lost.

Last seen on 14:43, 2. Aug 2022
Joined Nov 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I was looking for this post…
Thu, 05/07/2020 - 20:50

I was looking for this post for hours because I saw it and found the answer.

 

if (source.getImmediateSource() instanceof this.getType())
				return false;

//paste this in : public boolean attackEntityFrom(DamageSource source, float amount) {