PlayerMoveEvent and camera shake

Discussion in 'Plugin Development' started by dram, Mar 31, 2015.

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

    dram

    Hello.

    I want block player moving when some variable is true.

    I'm using
    Code:
        @EventHandler
        public void onMove(PlayerMoveEvent e) {
            if(e.getPlayer()!= null  ){
                if(x==true)
                      e.setCancelled(true);
              
              
            }
        }
    This function block all events including camera move.
    2.when i have moved my camera is shaking :0
    How to unlock camera and dont shake it?
     
  2. Offline

    timtower Administrator Administrator Moderator

    @dram You can't, that is client side.
     
  3. You could store the block that the player is in inside a variable then periodically check if they have moved out of that block, if they have then teleport the player back. That would give them full range of movement but without letting them leave the current block
     
  4. Offline

    WeeSkilz

    You can teleport the player to the x, y, z they can from with the yaw and pitch they are going to. It's a bit juddery but you can still look around.
     
  5. Offline

    Evaluations

    Why would the player ever be null? You don't need to check that.
     
    dram likes this.
  6. Offline

    redside100

    Why don't you just check if the getFrom x y and z is not equal to the getTo x y and z?

    Code:
                if (!e.getTo().equals(e.getFrom())){
                    e.setCancelled(true);
                }
     
  7. Offline

    Protophite

    Code:
    player.setWalkSpeed(0); //prevent player from walking.
    player.setWalkSpeed((float) 0.2); //restore normal walk speed.
    player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 10000, 128)); //this will prevent player from jumping.
    
    @dram
     
  8. Offline

    redside100

    I think that method is a lot smoother :p
     
  9. Code:java
    1. if (e.getFrom().getPitch() == e.getTo().getPitch() && e.getFrom().getYaw() == e.getTo().getYaw()) {
    2. p.teleport(e.getFrom());
    3. //or this: (could by buggy)
    4. e.setCancelled(true);
    5. }
     
Thread Status:
Not open for further replies.

Share This Page