1.15.2 Citizens NPC Damage and Knockback resistance

Discussion in 'Spigot Plugin Development' started by WeedMan420, Feb 7, 2020.

  1. How do i:
    Change the value of my player npc's damage towards me (does 0.2 damage by default, takes 5 hits to do half a heart)

    Change the knockback resistance, i want to make it immune to knockback
  2. You just want us to throw up some code at you? How about post what you have already tried to do, and maybe some code so we can guide you to a solution.
  3. Code (Java):
            NPCRegistry npcRegistry = CitizensAPI.getNPCRegistry();
            NPC npc = npcRegistry.createNPC(EntityType.PLAYER, "Boi");

            Goal goal = TargetNearbyEntityGoal.builder(npc).aggressive(true).radius(100).targets(Sets.newHashSet(EntityType.PLAYER)).build();
            npc.getDefaultGoalController().addGoal(goal, 1);

            Navigator navigator = npc.getNavigator();

            MetadataStore metadataStore = npc.data();
            metadataStore.set(NPC.HURT_SOUND_METADATA, "entity.ghast.hurt");
            metadataStore.set(NPC.DEATH_SOUND_METADATA, "entity.ghast.death");
            metadataStore.set(NPC.AMBIENT_SOUND_METADATA, "entity.ghast.ambient");

            Player boi = (Player) npc.getEntity();
            boi.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, Integer.MAX_VALUE, 5));
    I tried attributes, i tried potion effects, they did not work for me.