Help with teleport of player

Discussion in 'Plugin Development' started by BPOtacon, Sep 25, 2013.

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


    I would like to be able to have a player teleport two blockes behind the attacker, but im not sure how to do that. This is what i have so far.
    2. @EventHandler(priority=EventPriority.MONITOR)
    3. public void onEntityDamageByEntity(EntityDamageByEntityEvent event){
    4. if(event.getEntity() instanceof Player){
    5. Player player = (Player) event.getEntity();
    6. Location playerLoc = player.getLocation();
    7. double currentHealth = player.getHealth();
    8. if(currentHealth < event.getDamage()){
    9. event.setDamage(0);
    10. Player attacker = (Player) event.getDamager();
    11. Location attackerLoc = attacker.getLocation();
    12. player.teleport(attackerLoc);
    13. }
    14. }
    15. }
    16. }
  2. Offline


    All you have to do is get the player eye location, add 2blocks in the opposite direction, and to the person there.
  3. Offline


    how would i do that so that my player will be looking at there attacker
  4. Offline


    You will need to get the attacking player's yaw and use it to decide which way to teleport the other player in order to get him behind the attacker.
Thread Status:
Not open for further replies.

Share This Page