I need help making an item that makes the player not targeted by hostile mobs

Started by Scootied on

Topic category: Help with modding (Java Edition)

Last seen on 05:23, 31. Jul 2023
Joined Mar 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I need help making an item that makes the player not targeted by hostile mobs

Titles says it all. I want some kind of item, preferably a helmet, that makes hostile mobs that target the player, not target them. Or simply just not attack them. I don't really see any way of doing this so if it is at all possible please let me know!

Last seen on 15:24, 16. Mar 2022
Joined Jun 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Is it wearable, holdable, or…
Fri, 07/03/2020 - 02:15

Is it wearable, holdable, or just in the inventory?

Last seen on 05:52, 18. Oct 2021
Joined Feb 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
something like this should…
Fri, 07/03/2020 - 06:25

something like this should work:

public void livingAttackTarget(LivingSetAttackTargetEvent event) { if (event.getTarget().inventory.getItemStackInSlot(EquipmentSlot.CHEST) == new ItemStack(YOURHELMET) && event.getEntity() instanceof MobEntity) { ((MobEntity)event.getEntity()).setAttackTarget(null); ((MobEntity)event.getEntity()).setAggroed(false); } }

this was tbroski's code, do not think i made this myself

Last seen on 04:35, 17. Jan 2021
Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
👍 Thanks lol
Fri, 07/03/2020 - 22:58

👍 Thanks lol

Last seen on 05:16, 19. Jan 2021
Joined May 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Hi, coding newbie here…
Tue, 01/12/2021 - 22:55

Hi, coding newbie here. Where do I put this bit of code and how do I implement it?