Pig wont make damage?

Discussion in 'Spigot Plugin Development' started by xXCalleManXx, May 3, 2017.

  1. Hi

    I'm trying to make a pig hurt a player instead of running away. So far i have made it go attack the player, but the player do not take any damage. It works very well with a zombie, with the same pathfindergoals.

    This is my code so far:
    Code (Text):
            EntityInsentient goals = mob;
            goals.goalSelector.a(1, new PathfinderGoalRandomStroll(mob,walkSpeed));
            if (panicSpeed <= 0) {
                if (attackType.equalsIgnoreCase("shoot")) {
                    IRangedEntity iRangedEntity = (IRangedEntity) mob;
                    goals.goalSelector.a(3, new PathfinderGoalArrowAttack(iRangedEntity, attackSpeed, shootDelay, range));
                }else if(attackType.equalsIgnoreCase("weapon")) {
                    goals.goalSelector.a(3, new PathfinderGoalMeleeAttack(mob, attackSpeed, true));
                }


                if (aggressive) {
                    goals.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget<>(mob, EntityPlayer.class, true));
                }
            }else{
                goals.goalSelector.a(4, new PathfinderGoalPanic(mob, panicSpeed));
            }
    Do i need a Pathfindergoal or something?

    Thanks for any help :)
     
  2. I am not sure how to make a pig attack a player, i don't want to be unassuming but i am not sure if this can be happen. Correct me if i am wrong. I think you can set a target of course like you said but a pig attack a player? i am not sure if this can be happen.
     
  3. @Nosma_Stew thanks for the respone :) I've seen this before so i know that this is possible, i only need to know how...
     
  4. Again, not sure if its possible for a pig to attack a player, but you can simulate damage, play the hit sound, reduce the players health, and knock them back a bit.
     
  5. @pvprealm thank you for the response :) Do you know how i can check when the pig tries to hit the player? Currently the pig tries to attack the player as a normal mob, but with no damage.
     
  6. I apologise but I have no idea. Never messed around with path finders and such before


    Sent from my iPhone using Tapatalk
     
  7. Maybe look at a mob that does melee damage like a zombie and see if there's a damage method. If so see how the zombie class does it and try to duplicate that. Or you can give them super speed when they see a player and catch on fire then explode when near a player ;)


    Sent from my iPhone using Tapatalk
     
  8. There is a plugin making passive entities neutral. Search spigot
     
  9. He wants aggressive pigs that attack and do damage not neutral ones.


    Sent from my iPhone using Tapatalk
     
  10. Get entitities in a 0.5 block radius around the pig, damage any player who is in that radius and set the players velocity to the pig's getDirection(). Hope this helps. Do the check like every 10 ticks asyncronously.
     
  11. He wants pigs that defend themselves , instead of running away
     
  12. Where does he say that? Don't assume, ask.


    Sent from my iPhone using Tapatalk
     
  13. Pigs run when hit. He wants them to fight instead of running.Combine the statements and get mobs that defend themselves
     
  14.  
  15. Try exploring the Spigot forums, someone else could have had this issue too. I doubt it though because a fair bit of people don't even know what pathfinders are, but it's worth a try.
     
  16. Have you tried this?
     
  17. look into wildboars plugin, you might find hints