Anti mob ''glitch''?

Discussion in 'Plugin Development' started by wydgabriel, Jul 3, 2016.

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

    wydgabriel

    Hello guys, I have a mmorpg server and I was wondering if you guys have some idea to prevent mobs being attacked without attacking his targets.
    Some players are getting the mobs to some spots that the mobs cant attack them, like getting some blocks up or just entering in water.

    Do you guys have an ideia to stop this? Like, a way to detect that the mob is being attacked without a chance to attack the player and then teleport to their target?

    Thank you :)
     
  2. Offline

    SuperSniper

    Im confused on what you mean... can you try to explain a little more/simpler?
     
  3. Offline

    Zombie_Striker

    @SuperSniper
    He wants to make sure a player cannot damage a mob if that mob cannot damage the player.

    @wydgabriel
    What you would need to do is check if a mob can walk to a player. To do this, create a method to check all of the directions for a mob. If all of them are blocks and yet the player is damaging the mob, then cancel the event, If there is a block (i.e water) between the mob and the player, then cancel the event.
     
  4. Offline

    wydgabriel

    Thats a good suggestion, Zombie.. I'll try this.. But one question before I try it: how do I check if the directions of the mob are only blocks? Because a mob in a lower block can damage the player.. That seems a little bit complex .. If you dont mind, I would like to know a way to do that kind of thing..
     
  5. @wydgabriel the problem with this will be, that all 4 directions being blocks wont prevent all mobs from getting to the player. for example enderman, spider or ghast. there is no common way to check if the mob can attack the player, but you can use nms to generate a path-object from the mob to the player. if the path is not null, you know the mob can walk to the player
     
  6. Offline

    wydgabriel

    Could you please give me a light to how can I check all 4 directions being blocks?
    Would it be like e.getEntity().getLocation().getDirection().equals(block)?
    Ty
     
Thread Status:
Not open for further replies.

Share This Page