Mobs Run Away

Started by DeathD84 on

Topic category: Help with Minecraft modding (Java Edition)

Joined Jan 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Mobs Run Away

Back at it again, I'm using the latest snapshot, is there any way I can make it so, with an effect or item, when you have it, mobs will be repelled/run away?

Joined Nov 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
create a procedure like this…
Mon, 03/15/2021 - 14:11

create a procedure like this:

https://cdn.discordapp.com/attachments/599250311852458006/821020637912498226/unknown.png

save and build it. my procedure is named Bbb, whatever your procedure name is, remember it.

next, create another procedure like this:

https://cdn.discordapp.com/attachments/599250311852458006/821021254282641408/unknown.png

in the custom code snippet box, put this piece of code in:

((MobEntity)entity).goalSelector.addGoal(1, new AvoidEntityGoal((CreatureEntity)entity, PlayerEntity.class, 10f, 1, 1.2) {
    @Override
    public boolean shouldExecute() {
        return super.shouldExecute() && BbbProcedure.executeProcedure(ImmutableMap.of("entity", this.avoidTarget, "world", this.avoidTarget.world));
    }
});

replace the BbbProcedure with the name of your procedure, for example, if the procedure is named CheckHelmet, then its CheckHelmetProcedure. also, very important, remove all the spaces in the code snippet.

save and build it. if you wear a diamond helmet, monsters should now avoid you.

 

Joined Jan 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
intructions confusing,…
Tue, 03/16/2021 - 02:14

intructions confusing, couldnt get it to work

Joined Nov 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
thats too bad. it works fine…
Tue, 03/16/2021 - 02:52

thats too bad. it works fine when i tested it.

maybe you should ask for help on the parts that are confusing you

Joined Sep 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
when you say remove all…
Thu, 12/30/2021 - 22:49

when you say remove all spaces you mean all the spaces outside the parentheses right?

Joined Sep 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
or i guess i should say what…
Thu, 12/30/2021 - 23:01

or i guess i should say what spaces exactly do we delete

Joined Feb 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
He means with "removing the…
Thu, 02/02/2023 - 14:06

He means with "removing the spaces" that the Code Snippet should be in one line.

Joined Aug 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
@ahznb it gives an error
Fri, 09/01/2023 - 10:26

@ahznb it gives an error