Y + 1

Discussion in 'Plugin Development' started by iKrazy, Aug 17, 2011.

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

    iKrazy

    SOLVED Thank you bergerkiller! :3


    Okay so what I need is a bit of help with a little tidbit of my plugin :s

    I need to know how to basically make sure the player has enough room to go up X amount, then freeze him, and make him go Y+1, Y+1, Y+1, etc. until he reaches X amount. Could anyone point me in the right direction or explain it out to me rather than just giving me the whole thing? I need to learn :l

    I can figure out the whole freezing thing and if the player has enough room, but I REALLY need help on the moving the player up one block at a time so it seems like he's flying up rather than being teleported X amount.

    I'm a beginner so please go easy on me :(

    Where it should be, thanks in advance! :)

    Code:
        public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args){
    
            if (commandLabel.equalsIgnoreCase("launch")){
                //TODO Commands
            }
            return false;
        }
     
  2. Offline

    thehutch

    Could you use a for loop so it counts up by one until you hit a certain height?
     
  3. Offline

    iKrazy

    Yeah you could, I'm mainly wanting to do location.getY(), then that, not looping the getY part, +1 until Height= Y + X

    If you looped the location.getY() then you would just +1 to infinity I think.
     
  4. Offline

    bergerkiller

    I'll give a push in the right direction: DON'T use player.teleport(loc).
    It is glitchy, prone to failure and simply not nice.

    Instead, run a scheduled task to set the player velocity to x up:
    Code:
    double yvel = 10;
    player.setVelocity(new Vector(0, yvel, 0);
    You do this until the player can no longer move (you could read the velocity for this, physics handle the rest).
     
  5. Offline

    bleachisback

    What you could do is set their velocity with
    Code:
    player.setVelocity(new Vector(0, 1, 0);
    and then add them to an Arraylist
    Code:
    arrayList.add(player);
    then, in a PlayerVelocityEvent,
    Code:
    if(plugin.arrayList.contains(player))e.setCancelled(true);
    then when you want it to stop
    Code:
    arrayList.remove(player)
     
  6. Offline

    iKrazy

    Whoops, I forgot to put solved at the top :p.

    Thank you Mr. Bergerkiller for solving it :) I've set the launch successfully. :)
     
Thread Status:
Not open for further replies.

Share This Page