Solved Can't change Y vector?

Discussion in 'Plugin Development' started by CoderMusgrove, Apr 2, 2014.

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

    CoderMusgrove

    I'm trying to create a LaunchPad plugin, and I have it working fine, but when the player steps on the pressure plate, his Y vector won't change. Here's the code I'm using:
    Code:java
    1. @EventHandler
    2. public void onPlayerInteract(PlayerInteractEvent e) {
    3. Player p = e.getPlayer();
    4. Action act = e.getAction();
    5. Block b = e.getClickedBlock();
    6. if (b != null) {
    7. if (act == Action.PHYSICAL) {
    8. if (b.getType() == Material.STONE_PLATE) {
    9. if (b.getRelative(0, -1, 0).getType() == Material.REDSTONE_BLOCK) {
    10. World w = p.getWorld();
    11. Location loc = p.getLocation();
    12. Vector v = new Vector(05, 50, 10);
    13. p.setVelocity(v);
    14. w.playSound(loc, Sound.BAT_TAKEOFF, 2f, 2f);
    15. }
    16. }
    17. }
    18. }
    19. }


    I get the influence of change on my x and on my z, but the y will not do a thing. I cranked it up to 50, I've had it as low as 2, and just nothing.
     
  2. Offline

    Windy Day

    If I recall correctly 1y in vectors equal about 26 blocks in game. So try something like 1 or less.
     
  3. Offline

    CoderMusgrove

    It doesn't matter what I set the value to, the y will remain unchanged. The most I ever notice is when I jump on the plate it gives me the tiniest little jump boost. I am now running on this code:
    Code:java
    1. @EventHandler
    2. public void onPlayerInteract(PlayerInteractEvent e) {
    3. final Player p = e.getPlayer();
    4. Action act = e.getAction();
    5. Block b = e.getClickedBlock();
    6. if (b != null) {
    7. if (act == Action.PHYSICAL) {
    8. if (b.getType() == Material.STONE_PLATE) {
    9. if (b.getRelative(0, -1, 0).getType() == Material.REDSTONE_BLOCK) {
    10. p.setVelocity(new Vector(0, 2, 0));
    11. }
    12. }
    13. }
    14. }
    15. }

    It's just really annoying, because I need to be able to just plainly walk onto the plate and have it change my y velocity, and it doesn't do a thing.

    Okay, I have figured it out, it turns out that I have to use the PlayerMoveEvent to get it to function with the launchpad.

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

Share This Page