Jump to content

peuloom

Members
  • Posts

    3
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by peuloom

  1. Did you try if(!(livingentity instanceof Player)){ }
  2. 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
  3. Hello, people, sorry for bothering. I'm trying to change every mob to be aggressive to the player, but I can't change their Attributes to add ATTACK_DAMAGE. Can someone help me? Mob mob = (Mob) event.getEntity(); if(!mob.getAttributes().hasAttribute(Attributes.ATTACK_DAMAGE)){ mob.getAttributes().assignValues(new AttributeMap(AttributeSupplier.builder().add(Attributes.ATTACK_DAMAGE, 1).build())); } if(mob.getAttributes().hasAttribute(Attributes.ATTACK_DAMAGE)) { mob.setCustomName(Component.literal("Aggressive")); mob.goalSelector.addGoal(1, new MeleeAttackGoal((PathfinderMob) 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.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.