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: <?phpnamespace 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($entity, 0, 1, 0, 1); $fizz = new BlazeShootSound($player); $player->getLevel()->addSound($fizz); }} public function onDisable(){ $this->getLogger()->info("KnockBack §cdisabled."); return true; }} Thanks in advance
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);}
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
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
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)