Need help with "Jump" plugin!

Discussion in 'Plugin Development' started by APPLEisROP, Jan 25, 2014.

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

    APPLEisROP

    So this will work fine, but it wont work if it should "jump" you in to north. Other ways it works fine.

    Here's some code:
    Code:java
    1. @EventHandler
    2. public void onPlayerMove(PlayerMoveEvent event)
    3. {
    4. Player player = event.getPlayer();
    5. Location standBlock = player.getWorld()
    6. .getBlockAt(player.getLocation().add(0.0D, -0.01D, 0.0D))
    7. .getLocation();
    8. if (standBlock.getBlock().getTypeId() == 86)
    9. {
    10. int xblock = 0;
    11. double xvel = 0.0D;
    12. int yblock = -1;
    13. double yvel = 0.0D;
    14. int zblock = 0;
    15. double zvel = 0.0D;
    16. while (standBlock.getBlock().getLocation()
    17. .add(xblock - 1, -1.0D, 0.0D).getBlock().getTypeId() == 35)
    18. {
    19. xblock--;
    20. xvel += 1.0D;
    21. }
    22. while (standBlock.getBlock().getLocation().add(0.0D, yblock, 0.0D)
    23. .getBlock().getTypeId() == 35)
    24. {
    25. yblock--;
    26. yvel += 0.7D;
    27. }
    28. while (standBlock.getBlock().getLocation()
    29. .add(0.0D, -1.0D, zblock - 1).getBlock().getTypeId() == 35)
    30. {
    31. zblock--;
    32. zvel += 1.0D;
    33. }
    34. xblock = 0;
    35. zblock = 0;
    36. while (standBlock.getBlock().getLocation()
    37. .add(xblock + 1, -1.0D, 0.0D).getBlock().getTypeId() == 35)
    38. {
    39. xblock++;
    40. xvel -= 1.0D;
    41. }
    42. while (standBlock.getBlock().getLocation()
    43. .add(0.0D, -1.0D, zblock + 1).getBlock().getTypeId() == 86)
    44. {
    45. zblock++;
    46. zvel -= 1.0D;
    47. }
    48. if (((player.hasPermission("jump.launch")) && (
    49. (xvel != 0.0D) || (yvel != 0.0D) || (zvel != 0.0D))))
    50. {
    51. player.setVelocity(new Vector(xvel, yvel, zvel));
    52. if (player.hasPermission("jump.launch")) {
    53. player.playSound(player.getLocation(),
    54. Sound.WITHER_SHOOT, 1.0F, -5.0F);
    55. }
    56. }
    57. }
    58. }
     
Thread Status:
Not open for further replies.

Share This Page