Solved No mob knockback, only for a few mobs?

Discussion in 'Plugin Development' started by IkBenHarm, Feb 4, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    IkBenHarm

    Is there any way to prevent knockback on mobs? (also knockback from fireballs, not-enchanted weapons etc.)

    Or, as an alternative, just make it impossible for them to move in any way?

    What I've done now is spawn a skeleton and give it slowness 15.
    But what i want is that it will not be able to move at all. And it does move right now when hit by any kind of weapon...

    Would it work to use an EntityDamageByEnittyEvent, check if it's at the location it was before (saved in config) and then cancel the event, then damage the mob manually?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  2. Offline

    ThePlayerPaul

    You can set the Velocity.
     
  3. Offline

    IkBenHarm

    ThePlayerPaul
    How would I do that excatly? Because from the experience i have with velocity, it would knock it back at the place it was before

    ThePlayerPaul
    and the mob deffinetly can't move, since that would mess up the rest of my code xD (all the extra stuff the mob can do will be bound to the mobs location)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  4. Offline

    ThePlayerPaul

    Code:java
    1. ent.setVelocity(new Vector(2, 0, 0));
     
  5. Offline

    user_90854156

    What I did for cancelling mob knockback:
    Code:java
    1. @EventHandler
    2. public void onHit(EntityDamageByEntityEvent e) {
    3. if (e.getEntity() instanceof Monster) { //Checks if the damaged entity is a monster (zombie, skeleton etc.)
    4. final Monster m = (Monster) e.getEntity(); //monster variable
    5. this.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
    6. public void run() {
    7. m.setVelocity(new Vector()); //Sets the velocity a tick after getting damaged, else it won't work
    8. }
    9. }, 1L);
    10. }
    11. }


    Basically, set the velocity to nothing.
     
  6. Offline

    IkBenHarm

    MrTang
    So lets say i use this, and have the mob not to move naturally, is there any other way to move them then?
     
  7. Offline

    user_90854156

    Eh, it's probably possible to move the mob with water
     
  8. Offline

    IkBenHarm

    MrTang ohyeah.... have to figure thatone out. But thanks for helping!
     
Thread Status:
Not open for further replies.

Share This Page