I have the following code in my plugin and for some reason it's not working, I'm not receiving any errors but here it is. PHP: $x = $event->getPlayer()->getX(); $z = $event->getPlayer()->getZ(); $minZ = 1516; $maxZ = 1512; $minX = 48; $maxX = 52; if($minX <= $x and $x <= $maxX and $minZ <= $z and $z <= $maxZ){ $event->getPlayer()->knockBack($event->getPlayer(), 0, 50, 1505, 3); } Am I doing something wrong, or can someone give me an example of how to use it properly?
The parameters of knockback are damager, damage, x, z and base. Damager and damage are currently unused. (It may be used by some entities to amplify the knockback) X and Z are the strengths of the knockback, as a 2D vector. Base is another amplifier for the knockback, but also contributes vertically. According to @shoghicp, the client ignores the knockback if it gets too strong. For reasonable parameters, see how the source code uses it: https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/entity/Living.php#L169
@SOFe I'm trying to change the direction where the knockback pushes to. I tried changing the x and z for the parameters but there's no difference.