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

Knockback

Discussion in 'Development' started by Remarkabless, Oct 26, 2017.

  1. Remarkabless

    Remarkabless Slime

    Messages:
    83
    GitHub:
    Remakem
    PHP:
    public function knockBack(Entity $attackerfloat $damagefloat $xfloat $zfloat $base 0.4){
            
    $f sqrt($x $x $z $z);
            if(
    $f <= 0){
                return;
            }

            
    $f $f;

            
    $motion = new Vector3($this->motionX$this->motionY$this->motionZ);

            
    $motion->/= 2;
            
    $motion->/= 2;
            
    $motion->/= 2;
            
    $motion->+= $x $f $base;
            
    $motion->+= $base;
            
    $motion->+= $z $f $base;

            if(
    $motion->$base){
                
    $motion->$base;
            }

            
    $this->setMotion($motion);
        }
    yes, yes, I checked the forum to see how this function is used but I simply dont understand it. I literally started making simple plugins 2 weeks ago.
    Could someone here explain it to me how I can use this to set the knockback of x and y when you pvp. $attacker instanceof entitydamage etc.
    Thanks this is what im trying to use.
     
  2. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    Could you have been lazier, calling the thread title "kb"...
     
  3. Remarkabless

    Remarkabless Slime

    Messages:
    83
    GitHub:
    Remakem
    This is my first time working with Vector3 and x y and z and its confusing you act like im saying “GIVE ME THE CODE FOR DOING THIS KNOCKBACK”

    Reas instead.

    “Can someone here explain it to me”
    Those are my words not
    “Give me code”
     
  4. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    I was referring to your thread title. You call it "kb", which nobody can understand without clicking into the thread to know it actually refers to "knockback". Now stop talking about this. I never said you just ask for code.
     
  5. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Doesn't that event already have a method for handling knockback?
     
  6. Remarkabless

    Remarkabless Slime

    Messages:
    83
    GitHub:
    Remakem
    I got that frok the src of pmmp. I want to know how I can use it to set a specific x and y knockback and what z is for? :/ pls help
     
  7. Remarkabless

    Remarkabless Slime

    Messages:
    83
    GitHub:
    Remakem
    Thanks for helping me people. You just look at it and dont help great.
     
  8. QuiverlyRivalry

    QuiverlyRivalry Zombie Pigman

    Messages:
    491
    GitHub:
    quiverlyrivalry
    You really need to change your attitude
     
    jasonwynn10 likes this.
  9. Jack Noordhuis

    Jack Noordhuis Zombie Pigman Poggit Reviewer

    Messages:
    618
    GitHub:
    JackNoordhuis
    You've shown no evidence of an attempt. This section of the forum is for helping developers with their code, not explaining how to code or use certain functions from the core. Maybe if you put in a little effort people would be more inclined to help you because giving you code to copy won't help anyone in the long run; providing feedback about why your code/attempt/approach won't work will.
     
    jasonwynn10, EdwardHamHam and Vaxrp like this.
  10. Vaxrp

    Vaxrp Witch

    Messages:
    73
    GitHub:
    Vaxrp
    You cant force someone to help you. Atleast try and see if you can think of way or concept of how the function could work make the code if it doesnt work, THEN come on the forums for help from the devs on how you can fix your original code.
     
    jasonwynn10 likes this.
  11. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    Stop trying to pretend to be two different people...
     
    jasonwynn10 likes this.
  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.