Solved Problem with setting Velocities

Discussion in 'Plugin Development' started by Samthelord1, Dec 6, 2014.

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

    Samthelord1

    I've come back after about a year without properly using the bukkit forums to update my plugin, as I thought everything had died but it appears it has not. I've just looked at the comments and tested my plugin and noticed a very big problem. When I am setting the velocities, the players are not launching as they should be. If the player jumps up onto the pressure pad they get launched as usual, if they walk on a flat surface to the pressure pad they get pushed forward a few blocks, but their y axis does not change. Here is the lines of code I am using for this part of the plugin;
    Code:java
    1. Player p = e.getPlayer();
    2. if(e.getClickedBlock().getType().equals(Material.STONE_PLATE)) {
    3. Block b = e.getClickedBlock().getLocation().subtract(0, 1, 0).getBlock();
    4. FileConfiguration config = getConfig();
    5. if((config.getString("launchpads").equals("true")) || (config.getString("launchpads").equals("true") && config.getString("permissions").equals("true") && p.hasPermission("launch.pads"))) {
    6. if(!(b == null)) {
    7. if(b.getType().equals(Material.REDSTONE_BLOCK)) {
    8.  
    9. p.setVelocity(p.getVelocity().add(p.getLocation().getDirection().multiply(config.getInt("multiply"))).setY(config.getInt("yaxis")));
    10. launchTimes.put(p.getName(), System.currentTimeMillis());
    11. if(!config.getString("sound").equalsIgnoreCase("false")) {
    12. p.playSound(p.getLocation(), Sound.PORTAL_TRIGGER, LIMIT, LIMIT);
    13. }


    fixed it, needed to teleport the player up when they interacted as they were getting stuck in the block, works perfectly now!

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

Share This Page