Started by
Scootied
on
Topic category: Help with Minecraft modding (Java Edition)
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!
Is it wearable, holdable, or just in the inventory?
Currently this is not possible without coding, but i made a forum topic about the same thing, except only with undead.
https://mcreator.net/forum/62569/how-make-mobs-be-pet-another-mob
see the comments
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
👍 Thanks lol
Hi, coding newbie here. Where do I put this bit of code and how do I implement it?