Jump higher / Shoot Player in the Air

Discussion in 'Plugin Development' started by Zero9195, Jun 17, 2011.

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

    Zero9195

    Hi Guys,
    Is there any way to shoot a player in the air? Maybe it does work with Vectors, but I'm not familiar with it. Would be nice if someone could help me there. Thanks for helping me in advance ;)
    Zero
     
  2. Offline

    Shamebot

    Code:java
    1. player.setVelocity(new Vector(0,3,0));

    This should shoot the player straight upwards, but it might be to fast.
     
  3. Offline

    Zero9195

    Thank you ;) And how can I adjust the Speed? I want to somehow, climb up the wall, so I need the right speed for that.
    @Shamebot
     
  4. Offline

    Shamebot

    The middle coordinate(y) is the vertical, just play around with it.
     
  5. Offline

    DreadKyller

    change the 3 to a number, if you want to have a custom speed for example in a command parse a double of a string, then that would be the speed you put in place of the 3.

    @Shamebot good solution but let me just change it a bit to add one thing:

    Code:
    Vector vel = player.getVelocity();
    vel.setY(3);
    player.setVelocity(vel)
    this way if you are moving forward you don't abruptly come to a halt sideways. it would make much difference unless you are going to be repeating the script every few milliseconds or so, like Zero9195 would need if he wants to make it climb he'll need to set a constant velocity, meaning he would not be able to move sideways
     
  6. Offline

    Zero9195

    @Shamebot @DreadKyller
    Thank you both, and DreadKyller's sollution is better, but Shames helped me understanding what I'm doing :D
    I will play arround with the Numbers a bit and try to get a "formula" to set the Y-Velocity so that the player lands on the top. Thanks again!
     
  7. Offline

    Shamebot

    @DreadKyller
    Yes your's is smooth while mine is like a rocket :D. Speaking of rockets, with the particle effect of TNT someone could make quite a funny plugin, shooting a player in space with a nice tail of smoke. Would need to cancel the PlayerKickEvent to achieve heigh speed.
     
  8. Offline

    DreadKyller

    @Shamebot : now that would actually be a cool plugin, make like a command /launch playername and you send them like a rocket right in to the air, it would be somewhat simple, just need to get the particles working
     
  9. Offline

    Zero9195

    @Shamebot @DreadKyller
    Awesome Idea xD And of course cancel the FallDamage ;) Would be a loads of fun :D
    Who reaches the Moon first? :D
     
  10. Offline

    DreadKyller

    lol, unfortunately you can't, I've used the tp command to teleport myself to 25,000,000 and it still looks the same distance because it's not a physical object just an image, it would be REALLY cool however if notch made it a real object. or were you being sarcastic?
     
  11. Offline

    Zero9195

    @DreadKyller
    A little bit sarcasm, but still it would be awesome to reach the moon xD
     
  12. Offline

    DreadKyller

    do you know how long it takes to fall 25,000,000 blocks? Answer = over 2 hours!!!!! and I couldn't even see the ground, checking my hight with the F3 button I was still at 4,000,000 so I conclude about 2.5 hours to fall 25 milling, meaning terminal velocity = 10,000,000 meter an hour(because 1 block is scaled compared to 1 meter)
     
  13. Offline

    Shamebot

    Looks like you can't shoot players above 128, whatever I put in there I get just to the clouds, not further -.-

    [​IMG]
    I've figured out how to make the smoke, but the player on the image is faked with flymod.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 16, 2016
  14. Offline

    DreadKyller

    do you mind telling me how to get the smoke? cause I've been looking to doing something, but never wanted to take the time, because it's fairly small project. and to get more distance just use a scheduler to set the velocity to the max every few seconds.

    setting my velocity to a constant 5 I soar WAY over the clouds, I looked at the clouds turned it on and the clouds were gone in like 5 seconds I look down and I can't even see the world, so idk

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 16, 2016
  15. Offline

    Shamebot

    Maybe because it's 1.5? I tested 5, 10, 1000 and just flew to the clouds.
    For the smoke I'm just sending the Packet60Explosion which takes 5 arguments:
    1. double x, double y, double z : the coordinates of the origin of the explosion, determines in which direction the particles fly and where they're white/black. In the image it's at the player's feet.
    2. a float: some constant I don't really know what it does, it's something like the speed of the particles. If it's great they spread more widely. In the picture I used 0.1F to keep the tail small.
    3. A Set<ChunkPosition> to destroy the blocks and spawn particles at.
    To get a static column of smoke I used the scheduler to send the packet each tick.
     
  16. Offline

    Mak

    hy,
    can you please give an code snipped for that Shamebot?
     
  17. Offline

    Shamebot

    very snippy:
    Code:java
    1. public outerclass extends JavaPlugin
    2. {
    3. ...
    4. class R implements Runnable
    5. {
    6. public void run()
    7. {
    8. ePlayer.netServerHandler.sendPacket(packet);
    9. }
    10. }
    11. Block block;
    12. EntityPlayer ePlayer;
    13. Packet60Explosion packet;
    14. ...
    15. else if(args[0].equalsIgnoreCase("rocket"))
    16. {
    17. if(sender instanceof Player)
    18. {
    19. sender.sendMessage("rocket");
    20. Player player = (Player) sender;
    21. block = (block == null?player.getTargetBlock(null, 50):block);
    22. ePlayer = ((CraftPlayer)player).getHandle();
    23. int x = block.getX();
    24. int y = block.getY()+15;
    25. int z = block.getZ();
    26. HashSet<ChunkPosition> set = new HashSet<ChunkPosition>();
    27. for(int i = 0;i<10;i++)
    28. {
    29. set.add(new ChunkPosition(x,y-i,z));
    30. }
    31. packet = new Packet60Explosion(x,y+1,z,.1F,set);
    32. getServer().getScheduler().scheduleSyncRepeatingTask(this, new R(), 0, 1);
    33. return true;
    34. }
    35. return false;
    36. }
    37. ...
    38. }
     
  18. Offline

    DreadKyller

    @Shamebot I'm running most recent minecraft and most recent cb so I'm not running 1.5

    @Mak

    PHP:
    int x player.getLocation().getX();
    int y player.getLocation().getY();
    int z player.getLocation().getZ();
    Packet60Explosion packet = new Packet60Explosion(xyz0.2null);
    ((
    CraftPlayer)player).getHandler().netServerHandler.sendPacket(packet);
    you have to build against craftbukkit though, so add craftbukkit as an external jar instead of the normal bukkit.

    @Shamebot how do you get the java code? all I can use is php and code tags

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 16, 2016
  19. Offline

    Shamebot

    But I'm still on 1.5 on one of my devservers, as you can see in the image.

    Did you test your code?
    Packet60Explosion is calling "new HashSet(thePassedSet)", if you pass null the new HashSet will either be empty or you'll get an error (I don't know for sure) and it doesn't work with a empty set.

    It's [ syntax = java ][ /syntax ]
     
  20. Offline

    DreadKyller

    Oo, well still, the plugin I'm refering to I've used since minecraft was in 1.3 :) (supprisingly only needed to update it once, I never used any features that got changed except the commands.)

    if you do NOT put a new empty set then the packet will destroy some blocks, so it needs to be empty or something will happen, I am actually fammiliar with the Packet60Explosion, just did not know it created the smoke effect, I've seen it be suggested in several posts, like someone wants to stop creeper damage but canceling the even didn't make the sound, and the person still wanted the sound, so someone suggested make a new packer and send it to make the sound.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 16, 2016
  21. Offline

    Shamebot

    They'll just get destroyed on clientside so it wouldn't matter for a rocket mod.
    There's no way you can get around this, either some destroyed blocks or no smoke.
     
  22. Offline

    DreadKyller

    hmm, maybe destroy a block that's air?
     
  23. Offline

    Shamebot

    Yeah that works, I did the picture this way.
     
  24. Offline

    DreadKyller

    ok, well then that's not a big problem at all, I love fooling around with packets, it's like the best way to do stuff. still haven't figured out the CustomPacket yet...
     
  25. Offline

    Shamebot

    Are you referring to an actual packet or do you want to make your own?
     
  26. Offline

    DreadKyller

    there is a packet called "PackerSomenumberCustom"
     
  27. Offline

    Zero9195

    NICE xD Looks great^^ And 2,5 hours is a long time, will try it out myself xD
     
  28. Offline

    Shamebot

Thread Status:
Not open for further replies.

Share This Page