Jumppads won't work!

Discussion in 'Plugin Development' started by ThrustLP, Jun 1, 2016.

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

    ThrustLP

    Hey guys! I am trying to do jumppads using:

    Code:
    @EventHandler
        public void onInteract(PlayerInteractEvent event) {
           
            if(event.getAction() == Action.PHYSICAL) {
               
        
                if(event.getClickedBlock().getType() == Material.STONE_PLATE) {
                    
                    Vector v = event.getPlayer().getLocation().getDirection().multiply(10D).setY(10D);
                    event.getPlayer().setVelocity(v);
                   
               event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.ENTITY_ENDERDRAGON_HURT, 4, 4);
                   
        
                   
                }
            }
        }
    But I only get pushed like 8 blocks forward. I want to get pushed away like on hive etc.

    Why doesn't it do that?

    Thanks you!
     
  2. Offline

    Zombie_Striker

    @ThrustLP
    Have you tried changing the multiplier? Changing the multiplier increases or decreases how far you go. Change 10D to something like 20D.
     
  3. Offline

    Xerox262

    @ThrustLP As @Zombie_Striker said, change the multiplier, however ensure you don't set it too high, it'll make the server think the player is moving too fast and glitch them (Mostly caused by the Y which it looks like you've ensured won't bother you)
     
  4. Offline

    flash110

    Instead of testing for the interact event try to test for the player move event and get the block either in/under them. Than get the velocity and stuff, but set the multiplier to 2D and the y to 1.7D, it worked for me.
     
  5. Offline

    bennie3211

    It's better to check the player interact event with a if statement like he is doing now.
     
  6. Offline

    flash110

    @bennie3211 That way would also include an if statement
    Code:
    if (p.getLocation().subract(0,1,0).getBlock().getType() == Material.MATERIAL) {
    //do stuff
    }
    
    I'm not in a location where I can test this right now, so I think it should work.
     
  7. Offline

    bennie3211

    But he has an if statement
    Code:
    if(event.getAction() == Action.PHYSICAL) {}
    Inside a playerinteractevent is better then checking it in the playermoveevent. Besides, the problem is that it doesn't push far enough, not that his methode isn't working
     
  8. @ThrustLP i guess physics could be dicking you over. moving x and z is not going against gravity but moving y does. So multiplying with 20 and manipulating x or z will go faster than manipulating y since gravity is slowing you down and pulling you back. So my guess would be, that you have to increate the multiplier to get a higher boost. If you want it to boost you in the direction you are walking, too you have to check the direction the player entered the field and also manipulate x/z depending on that.
     
  9. Offline

    bennie3211

    If you want to push a player in the direction they are looking, just get the player direction and normalize it, then multiply X, Y and Z individual and the set the new velocity to the player. Maybe it will fix the problem
     
Thread Status:
Not open for further replies.

Share This Page