an annoying problem

Discussion in 'Plugin Development' started by Funergy, Oct 25, 2014.

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

    Funergy

    So I've been talking about the spectator arrow block. that still hasn't been fixed
    but now if you stand in front of a player and he tries to place the block it doesn't works because I'm at the place he wants to place the block. is there any way to hide a player fully from everything
    so no arrow block, no block glitch thing.
    because you can hide an entity with packets but its still there you can still hit it, etc etc.
     
  2. Offline

    JordyPwner

    Check if someone places a block
    Check if a spectator is in that block
    Cancel event
    Place the block
    (i guess)
     
    ChipDev likes this.
  3. Offline

    Funergy

    JordyPwner You can't check it with the place block event because the event doesn't even fire because you actually rightclick the player
     
  4. Offline

    ChipDev

    Listen to entity interact - if get item in hand is a block? - place block at looking point
     
  5. Offline

    CraftCreeper6

    PlayerInteractEntityEvent
     
  6. Offline

    Funergy

    ChipDev Okay and the problem with the arrow?
     
  7. Offline

    ChipDev

    Cancel arrowHitEvent?
     
  8. Offline

    Funergy

    ChipDev And how could I get the block where hes looking at because the get target block is a block but its actually air we are editing
    and theres no arrowHitEvent
     
  9. Offline

    CraftCreeper6

    Funergy
    EntityDamageByEntityEvent
     
  10. Offline

    Funergy

    CraftCreeper6 It still isn't working I've done the arrow thing and it doesn't work
     
  11. Offline

    CraftCreeper6

    Funergy
    EntityDamageByEntityEvent
    Check if the damager is an arrow. Check if the damaged is a player. If they are both true then cancel then get the velocity of the arrow. Store it, when the arrow hits the player cancel the event to prevent them from taking damage, re-spawn the arrow with the same velocity (Use Arrow a = (Arrow) player.launchProjectile(Arrow.class); then use a.setVelocity(myArrowVelocity))

    Done :)
     
  12. Offline

    Funergy

  13. Offline

    Funergy

    codename_B ? You know how to fix these 2 problems?
     
  14. Offline

    Funergy

    CraftCreeper6
    That didn't work for me. So what I need to fix now is the Arrow blocking
    but fireblast709 helped me with answering someone that had the same problem (BlockCanBuildEvent)
     
  15. Funergy Show the code that didn't work
     
  16. Offline

    Funergy

    AdamQpzm
    Code:
    if(e.getEntity() instanceof Player && e.getDamager() instanceof Arrow){
                    Arrow r = (Arrow) e.getDamager();
                    Player d = (Player) r.getShooter();
                    Player p = (Player) e.getEntity();
                    String ps = InGameHandler.getTeam(p);
                    String ds = InGameHandler.getTeam(d);
                    if(ps.equalsIgnoreCase(ds)){
                        e.setCancelled(true);
                        return;
                    }
                    if(SpectatorHandler.spectators.contains(p)){
                        Vector v = r.getVelocity();
                        e.setCancelled(true);
                        Arrow a = (Arrow) p.launchProjectile(Arrow.class);
                        a.setVelocity(v);
                    }
                }
     
  17. Funergy You never check the shooter is a player. Also, you don't move the spectator out of the way or anything, so surely it'll just keep on flying towards them and hitting them until one of the two move out of the way? Try teleporting the spector away somewhere, for example in the air a few blocks.
     
  18. Offline

    xMrPoi

    A better way to do this would be to move the arrow like half a block more back
     
  19. xMrPoi I've found that that approach can lead to problems - for example, a spectator's hitbox may overlap with a player's enough that you completely miss someone by misfortune. It can happen more often than you'd think, especially since (in my experience) spectators have an annoying habit of trying to stand on top of players for some reason. It'll also open up to abuse if players work out they can make arrows miss in that fashion.
     
  20. Offline

    Funergy

    AdamQpzm But as you see on the hive network you can't spec block
    and they don't teleport you

    AdamQpzm Is there any way I get the location of the back of that player. so I can spawn the arrow at the back of him

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 14, 2016
  21. Funergy No, you'll have to add some to the location yourself.
     
  22. Offline

    fireblast709

    Funergy they might just be overriding the arrows with their own custom class.
     
  23. Offline

    Funergy

    fireblast709 AdamQpzm Should I do if a player is in the radius of an arrow then we teleport them to another place?
    I know I can use something like Location.distanceSquared() but how should I do that because theres no projectile move event. and If I do a bukkit runnable when the arrow gets shot and we check every 1 ticks if hes in that radius en then we teleport them, should lagg horribly because like someone is bow spamming.
     
  24. Funergy Why do you need to do that? Just recreate the projectile if it hits a spectator.
     
  25. Offline

    Funergy

    AdamQpzm Should this work?
    Code:
    p.teleport(p.getLocation().add(0,5,0));
                        Vector v = r.getVelocity();
                        e.setCancelled(true);
                        Arrow a = (Arrow) p.getWorld().spawn(r.getLocation(),Arrow.class);
                        a.setShooter(d);
                        a.setVelocity(v);
     
  26. Funergy I don't see why not, although you might want to set the spectators to flying (if they're allowed to fly) just because it looks better that way and keeps them out of the way for longer.
     
  27. Offline

    Konato_K

    fireblast709 I don't think so, it's possible to make arrows go through players using NMS without overriding anything, you just need to set a boolean value in the EntityPlayer class
     
  28. Offline

    fireblast709

    Konato_K for unknown reasons I completely read past that one. It's the 'isInvulnerable' field in PlayerAbilities btw.
     
  29. Offline

    xMrPoi

    You could always restrict the spectators from getting too close to other players.
     
  30. Offline

    Konato_K

    fireblast709 Also the collidesWithEntities field, both work to make players not being hit by projectiles.
     
Thread Status:
Not open for further replies.

Share This Page