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

KnockBack v2.0

Comments in 'Plugin Development' started by Skullex, Feb 13, 2016.

  1. Skullex
    Offline

    Skullex Active Member

    Joined:
    Nov 14, 2015
    Posts:
    212
    Minecraft User:
    Skullex
    This goes back to a previous thread that I posted here. It was on knockback, the plug in worked perfectly until I slapped a slapper and started up the server with xp still floating around so I created this. Apon doing so it never worked :(. I need attention, please help. What have I done wrong?

    PHP:
    <?php

    namespace KB;

    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\level\sound\BlazeShootSound;
    use 
    pocketmine\event\player\PlayerDamageEvent;
    use 
    pocketmine\event\player\PlayerInteractEvent;

    class 
    KnockBack extends PluginBase implements Listener{

        public function 
    onEnable(){
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
        }

        public function 
    onLoad(){
            
    $this->getLogger()->info("KnockBack ┬žaenabled");
        }

        public function 
    onInteract(PlayerDamageEvent $event){
         
    $player $event->getPlayer();
       if(
    $event instanceof PlayerInteractEvent){
       
    $player->knockBack($entity0101);
       
    $fizz = new BlazeShootSound($player);
       
    $player->getLevel()->addSound($fizz);
        }
    }

        public function 
    onDisable(){
            
    $this->getLogger()->info("KnockBack ┬žcdisabled.");
            return 
    true;
          }
    }
    Thanks in advance :)
  2. Nawaf_Craft1b
    Offline

    Nawaf_Craft1b Active Member Plugin Developer

    Joined:
    May 8, 2015
    Posts:
    232
    Plugins:
    1
    Minecraft User:
    Nawaf_Craft1b
    not PlayerDamageEvent
    use pocketmine\event\Entity\EntityDamageEvent;
    PHP:
    public function onInteract(EntityDamageEvent $event){

    $player $event->getEntity();

    if(
    $event instanceof EntityDamageByEntityEvent){

    $damager $event->getDamager();

    $event->setKnockBack(1,0,1);

    $fizz = new BlazeShootSound($player);

    $player->getLevel()->addSound($fizz);
    }
    Last edited: Feb 13, 2016
    Skullex likes this.
  3. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    Its a bit lack of api. there are only 4 directions you can knockback to, also the knockback function is pure.. shit. Lack of documentation
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    set knockback only accepts one parameter. Others are redundant.
    We are all aware that PocketMine is not perfect. Instead of complaining about it with foul language, why not sending pull requests in to get things improved?

    And to reply you before you ask:
    Yes, I added the setKnockBack function 14 months ago. When I was creating that function, I was only thinking about changing the magnitude of the knockback rather than changing the direction. Once again, you are welcome to create pull requests to add features.

    And no, the pull requests shouldn't be pending and unattended forever. I don't care whether the old pull requests were ignored/postponed forever, but if I find a pull request okay and is not a major change that requires more peer review, I would merge it myself now that I have write access.



    And finally, if you find this necessary, I apologize for creating an API function with poor documentation and functionality. Although I really never expected you to try to change the knockback direction :p
    Last edited: Feb 13, 2016
    Vaivez66, Skullex, Svile and 2 others like this.
  5. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    So you added it? Okay. When you hit a mob the new position won't be sendt to the player. Maybe you can have a look at it why it happens.

    The direction:
    I coded a part for my launch pads that in theory should launch you in the direction you are facing. I learned triangular calculation etc., but somehow they still don't go where i want.
    Thats why i haven't made a pr yet. I wanted to add a function in pm called knockbackTo(Position $position)

Share This Page

Advertisement