Please help! How to make mobs that can change from hostile to passive?

Started by tyndyrn on

Topic category: Help with modding (Java Edition)

Last seen on 08:37, 6. Oct 2019
Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Please help! How to make mobs that can change from hostile to passive?

I'm trying to create a mob that behaves like wolves do - they become hostile when attacked and can change to neutral, except in this case they become neutral when given an item (e.g. biscuit).

So far I have two mobs - a hostile (put in as monster) and a passive (put in as creature) version of the same critter - and I have placed these processes:

Passive mob -- when directly hit, if random ≥ .5, do despawn provided entity and spawn at (same location) hostile entity

Hostile mob -- when right clicked, if in main hand = biscuit, and if random ≥  0.5, do despawn provided entity and spawn at (same location) passive entity, while spawning particles and remove one biscuit from inventory.

 

The game loads alright, but the passive mob will not become hostile no matter how much I hit it (in survival) and trying to give a biscuit to the hostile mob causes the game to freeze up. I can esc and exit normally, and when reloading the world, there will be a passive and hostile mob there. 

Are there other parameters I should include in the procedure to stop the game from freezing and to have the transformations take place smoothly? Or is this something that cannot be done with mcreator without fiddling with coding? Any input would be greatly appreciated!!