Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Knockback? How to use it?

Comments in 'Plugin Development' started by deot, Nov 11, 2015.

  1. deot
    Offline

    deot Active Member Plugin Developer

    Joined:
    Apr 22, 2015
    Posts:
    219
    Plugins:
    1
    Minecraft User:
    deot
    Hi, I wanted to achieve that:
    When player was being hit, no damage will deal on him but it will knockback that player

    So, I canceled EntityDamageEvent, now, the knockback part....
    PHP:
    $player->knockBack($player,$damage,$x,$z,$base);
    I have searched through forum "PLEASE DON'T GIVE ME ANSWER: Use search bar...."
    And, don't ever tell me to learn trigonometry, because I have learnt that... :)
    So, now, I know about trigonometry, problem is I dont know how to use that knockback API.... I need somebody to explain to me what are actually $x, $z and $base is in that knockback API? =_=....
    Also, I already knew that first 2 parameters are useless :)
    Is $base is something like "power"? I mean is it like this:
    larger $base, larger knockback produced...

    :p Im totally new to Knockback API, but not trigonometry... xD
    Legoboy0215 likes this.
  2. Bluplayz
    Offline

    Bluplayz Active Member

    Joined:
    Aug 20, 2015
    Posts:
    74
    Minecraft User:
    Bluplayz
    I dont know because i think that $damage is the power of the knockback and $x and $z is the coord there he "teleport" with knockback , dont know i test it today :D
  3. Bluplayz
    Offline

    Bluplayz Active Member

    Joined:
    Aug 20, 2015
    Posts:
    74
    Minecraft User:
    Bluplayz
    I have a quick question , how i can Get the "Plugin Developer" "rank" in forum?
    cake23 likes this.
  4. deot
    Offline

    deot Active Member Plugin Developer

    Joined:
    Apr 22, 2015
    Posts:
    219
    Plugins:
    1
    Minecraft User:
    deot
    Just make a plugin and wait for it to be approved...
    Hmm, so $x, and $z is the final coordinates of the "hitted" entity? Hm... so how can I find it's fallback coordinates??
    PHP:
    $x $player->getX() - 2;
    $y $player->getY() - 2;
    $player->knockBack($player,$damage,$x,$z,$base);
    ?? Anyone help? pls... :p
  5. Bluplayz
    Offline

    Bluplayz Active Member

    Joined:
    Aug 20, 2015
    Posts:
    74
    Minecraft User:
    Bluplayz
    Try to test , i think its right
  6. deot
    Offline

    deot Active Member Plugin Developer

    Joined:
    Apr 22, 2015
    Posts:
    219
    Plugins:
    1
    Minecraft User:
    deot
    Nope, this is wrong.... I confirmed
  7. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    cake23, Gamecrafter and deot like this.
  8. deot
    Offline

    deot Active Member Plugin Developer

    Joined:
    Apr 22, 2015
    Posts:
    219
    Plugins:
    1
    Minecraft User:
    deot
    Hahaha, because I searched and I saw lot of @PEMapModder 's answer:
    Learn trigonometry....

    I was like what!? Tangent, cosine and sinus... OMG! Math.. @@
    Anyway, i replied you on twitter, @Legoboy0215 , have a look on it :)
    Okay, I'm trying to look into that LauchPads code now
    Legoboy0215 likes this.
  9. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    LaunchPad is a VERY good example of knockbacking.
    cake23 likes this.
  10. deot
    Offline

    deot Active Member Plugin Developer

    Joined:
    Apr 22, 2015
    Posts:
    219
    Plugins:
    1
    Minecraft User:
    deot
    Hmmm.. I looked through that :)
    But.... I still have bit of confusion... It's $x and $y is just -1, 1 & 0....It will always take the player to the front of where player facing... right? :p
    So.... arghhhhh super confused now...!!
    Can I just left the coordinates to default? And let Pocketmine calculate the direction?? zzz :p
    All I wanted is just to set the power of knockback xD

    Is something like this possible?: xD
    $p->knockback(x);
    where x is constant, the larger the x the larger the knockback of power xD
    LOL, pocketmine should do a API like this if it doesnt has xD
  11. deot
    Offline

    deot Active Member Plugin Developer

    Joined:
    Apr 22, 2015
    Posts:
    219
    Plugins:
    1
    Minecraft User:
    deot
    Okay, so now does anyone know how to set a greater power on knockback?... Pls help.... xD lol
  12. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Gamecrafter and deot like this.
  13. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    NO! Don't read that! Look at this instead: https://github.com/Gamecrafter/PocketMine-Script-Plugins/blob/master/RocketPads.php
    Just look through the code and try to understand it...
  14. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    Vaivez66 likes this.

Share This Page

Advertisement