Hidden players blocking arrows

Discussion in 'Plugin Development' started by ftbastler, Jan 21, 2013.

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

    ftbastler

    Ok, so I got some code that makes a certain player invisible to everyone else (e.g. that player is a spectator). Now the problem is, that spectators can still block arrows, which is really annoying.

    Code:java
    1.  
    2. @EventHandler(priority = EventPriority.HIGHEST)
    3. public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
    4. Entity damager = event.getDamager();
    5. if(damager instanceof Player) {
    6. if(damager instanceof Arrow && BGMain.isSpectator((Player) event.getEntity())) {
    7. event.getEntity().teleport(BGMain.getSpawn());
    8. ((Player) event.getEntity()).sendMessage("Sorry, you were in the way!");
    9.  
    10. Arrow arrow = (Arrow) damager;
    11. //Now here, we should spawn an arrow, that has the same properties as the one that hit the spectator
    12.  
    13. event.setCancelled(true);
    14. return;
    15. }
    16.  
    17. }
    18. }
    19.  



    I know there is a method for spawning arrows, but how would I get the vector and make it actually work?
     
  2. Offline

    hockeygoalie5

    Is the player in Creative mode or invulnerable? If so, this listener wont work, because they won't take damage. Use a ProjectileHitEvent to get this. From there, the Arrow class should have everything you need to get and set its velocity and location. You might also want to disable the arrow bouncing, which is a method of ProjectileHitEvent.
     
  3. Offline

    ZachBora

    I do believe VanishNoPacket handles this, so perhaps look how he did it.
     
  4. Offline

    Muffin89

    Nope, it makes it look like you shoot it throu, but it doesnt go trough its only client side. The the invis person it bounces off.
     
  5. Offline

    tommycake50

    i believe there is not any real way to solve this.
    maybe you could derp around with packets and nms code but idk...
     
  6. Offline

    ftbastler

    No, I'm hiding them by doing player.hidePlayer(anotherplayer);
    I also looked into VNP and I couldn't find anything useful...
     
  7. Offline

    ZachBora

    Player shoots, move any hidden player in the direction of the arrow. Move them back after it lands.

    Congrats, you just became a super saiyan.
     
  8. Offline

    skipperguy12

    If you move them after a launch event, spectators will be derping around the place, and there would be no use of spectators.

    If you move them after a hit event, thats just plain old retarded, it already hit them...

    I need a solution to this problem!
     
    lcpvp likes this.
  9. Offline

    ZachBora

    Ask MonsieurApple he must have done something for it in his pvp server.
     
  10. Offline

    skipperguy12

    I know...I want SportBukkit soo bad from Ares, https://github.com/ProjectAres/SportBukkit/blob/master/CraftBukkit/PlayerCollision-API.patch
    ,
    but it's soo hard to compile on Windows!

    @MonsieurApple You need to release a link for SportBukkit! Many servers need it!

    Or atleast have a good tutorial on how to compile it (ON WINDOWS!).

    I know you need MingW, and MSys, and Git, but it's confusing!
     
  11. Offline

    ftbastler

    I'm also still searching for an answer!
     
  12. Offline

    teunie75

    Maybe when the arrow hits them, you teleport that 2 blocks behind them with the same speed.
    I don't know how to do it though, but you could try it.
     
  13. Offline

    ZachBora

    skipperguy12 I had some thoughts, but it's touchy.

    What you can do is move the player but don't send the packet that he moved, then move him back to where he was, also without sending a packet.
     
  14. Offline

    skipperguy12

    teunie75
    You didn't read what I wrote, did you :l

    It already hit them, that means there is no way of doing anything...if you move them, it's useless, the arrow hit the player already...
     
  15. Offline

    Kazzababe

    Code:
    @EventHandler
    public void onPlayerHurtPlayer(EntityDamageByEntityEvent event) {
        Entity entityDamager = event.getDamager();
        Entity entityDamaged = event.getEntity();
       
        if(entityDamager instanceof Arrow) {
            if(entityDamaged instanceof Player && ((Arrow) entityDamager).getShooter() instanceof Player) {
                Arrow arrow = (Arrow) entityDamager;
     
                Vector velocity = arrow.getVelocity();
     
                Player shooter = (Player) arrow.getShooter();
                Player damaged = (Player) entityDamaged;
     
                if(BGMain.isSpectator(damaged)) {
                    damaged.teleport(entityDamaged.getLocation().add(0, 5, 0));
                    damaged.setFlying(true);
                   
                    Arrow newArrow = shooter.launchProjectile(Arrow.class);
                    newArrow.setShooter(shooter);
                    newArrow.setVelocity(velocity);
                    newArrow.setBounce(false);
                   
                    event.setCancelled(true);
                    arrow.remove();
                }
            }
        }
    }
    This is the code I made for this situtation. It teleports the player getting hit by the arrow up 5 blocks and then re-creates the arrow with the same velocity.
    Modified to fit your needs.
     
    Pr07o7yp3 and legostarwarszach like this.
  16. Offline

    MonsieurApple

    skipperguy12 We don't have a public build system yet, but it's a priority! Once I finish converting everything to rake, it should compile without issues on windows.
     
  17. Offline

    skipperguy12

    MonsieurApple
    :) Thanks apple.

    Sorry to bother, but do you think you will ever finish the Client in your git hub?

    I'm bored of plugin development, so i'm learning how to make client mods, and my first mod is updating guru_frasers unofficial Project Ares mod! :)
     
  18. Offline

    MonsieurApple

    Sorry for the late reply, I don't visit these forums often. We do plan on finishing those repos, they just aren't of highest priority right now.
     
Thread Status:
Not open for further replies.

Share This Page