1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Antihack for antiknockback?

Discussion in 'Development' started by Kyd, Mar 22, 2017.

  1. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    Is it possible to create antihack for antiknockback?
     
  2. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    getKnockBack in entitydamageevent does not help. Lots of hack clients knockback player fast and then teleport to the previsious position
     
  3. Ragnok123

    Ragnok123 Silverfish

    Messages:
    22
    GitHub:
    Ragnok123
    Yes, but it is not too easy
     
  4. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    I know xD
     
  5. PocketKiller

    PocketKiller Slime

    Messages:
    83
    GitHub:
    iPocket
    Nope.
    as if you "can" do it, how about if a player lags? will you force knockback him?
    That's the reason of how hard to block hacks.
     
  6. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    What about this code? :D
    PHP:
    public function idk(PlayerMoveEvent $e)
        {
            
    $p $e->getPlayer();
            
    $from $e->getFrom();
            
    $to $e->getTo();
            
    $knockdistance $from->distance($to);
            if (
    $knockdistance 2.5) {
                
    $this->teleport[$p->getName()] = $p->getName();
            } elseif (
    $knockdistance 1.1) {
                if (isset(
    $this->knockback[$p->getName()])) {
                    if (isset(
    $this->teleport[$p->getName()])) {
                        
    $p->kick("AntiKnockback:D"false);
                    }
                }
            }
        }

        public
        function 
    onDamage(EntityDamageEvent $e)
        {
            
    $p $e->getEntity();
            if (
    $e instanceof EntityDamageByEntityEvent) {
                if (
    $e->getKnockBack() > 2.5) {
                    if (isset(
    $this->teleport[$p->getName()])) {
                        
    $this->knockback[$p->getName()] = $p->getName();
                    }
                }

            }
        }
    }
    I do not have time to test now.. Can it be usable?
     
  7. EdwardHamHam

    EdwardHamHam Skeleton

    Messages:
    962
    GitHub:
    edwardhamham
    It would depend on what the rest of your code is.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.