Push Player Back

Discussion in 'Plugin Development' started by MadeOke, Feb 18, 2013.

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

    MadeOke

    I Want to make the player if player walk on a block like bedrock the player will push back (like in worldguard) I Have search it.. but i couldn't understand how vector works..

    Code:java
    1. if(player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() == Material.BEDROCK) {
    2. //I don't have any idea what to put here
    3. }


    thanks for your help!
     
  2. Offline

    chasechocolate

    Well if you are using this in PlayerMoveEvent, do the check and do:
    Code:java
    1. event.setCancelled(true);
    2. player.teleport(event.getFrom());
     
    MadeOke likes this.
  3. Offline

    MadeOke

    Thanks but it glitch the player
    but i have tweak the code to this and worked!
    Code:java
    1. if(player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() == Material.BEDROCK) {
    2. eventhold.setCancelled(true);
    3. player.teleport(eventhold.getFrom().subtract(eventhold.getTo().subtract(eventhold.getFrom())));
    4. }
    5.  


    but not perfect :(
     
  4. Offline

    tkausl

    Code:java
    1. event.setTo(event.getFrom());

    Works also very nice.
     
  5. Offline

    MadeOke

    tkausl hmm not work for me , glitch the player
     
  6. Offline

    tkausl

    rly?
    i have the glich-problem only if i cancel the Event.
     
  7. Offline

    MadeOke

    tkausl yes, i have tried it with cancel or no but same.. player stuck on it

    still no :(

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
Thread Status:
Not open for further replies.

Share This Page