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

Started by Scootied on

Topic category: Help with Minecraft modding (Java Edition)

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!

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?

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

Joined Sep 2019
Points:

User statistics:

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

👍 Thanks lol

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?