Update, I've seen that I need "TransientAttributeModifiers" to do that, I've managed to change the AI properly, but always something "Pacific" attacks me, the game crashes. The .put to add Attack Damage seems to not work somehow.
public static Multimap<Attribute, AttributeModifier> getAttributeModifiers() {
Multimap<Attribute, AttributeModifier> temp = LinkedHashMultimap.create();
temp.put(Attributes.ATTACK_DAMAGE, new AttributeModifier("ATTACK_DAMAGE", 1, AttributeModifier.Operation.ADDITION));
return temp;
}
@SubscribeEvent
public static void onEntityJoinLevelEvent(EntityJoinLevelEvent event) {
if(!(event.getEntity() instanceof PathfinderMob mob)) return;
if(!mob.getAttributes().hasAttribute(Attributes.ATTACK_DAMAGE)){
mob.setCustomName(Component.literal("Pacific"));
mob.getAttributes().addTransientAttributeModifiers(getAttributeModifiers());
}
if(mob.getAttributes().hasAttribute(Attributes.ATTACK_DAMAGE)) {
mob.setCustomName(Component.literal("Hostile"));
mob.goalSelector.addGoal(1, new MeleeAttackGoal(mob, 1.0, false));
mob.goalSelector.addGoal(2, new LookAtPlayerGoal(mob, Player.class, 8.0F));
mob.targetSelector.addGoal(1, new NearestAttackableTargetGoal<>(mob, Player.class, true));
}
}
Thanks