Hey, today I wanted to see if this is a way that I can actually make this function work. Would actually doing this work? I dont have a server to test this on so thats why I am asking i want to get it done by the time I get a test server. Thanks also what does the “z” do? I just set it the same to the x cause I heard they are the same thanks heres my code: PHP: class Main extends PluginBase implements Listener{ public function onEnable() { $this->getServer()->getPluginManager()->registerEvents($this,$this); } $mot = new Vector3($this->motionX, $this->motionY, $this->motionZ); $mot->x = 0.3; $mot->y = 0.5; $mot->z = 0.3;//UNSURE OF THIS HELP? public function onDamage(EntityDamageEvent $daddy) { if($daddy instanceof EntityDamagebyEntityEvent){ $event-setMotion($mot); } }}
Naming the event daddy and then using event anyways won’t work. Also setMotion isn’t what you want, you want setKnockback (setMotion is only availible for Entities anyways. Also your $mot variable declaration is out of scope. PHP: class Main extends PluginBase implements Listener{ public function onEnable() { $this->getServer()->getPluginManager()->registerEvents($this,$this); } public function onDamage(EntityDamageByEntitiyEvent $daddy) { $daddy->setKnockback(0.5); }}
I made that exact plugin a couple weeks ago but I want to use setMotion so that I can change the x and y values diffrently. Can you help me find a way?
If you want to use setMotion it has to look like this: PHP: class Main extends PluginBase implements Listener{ public function onEnable() { $this->getServer()->getPluginManager()->registerEvents($this,$this); } public function onDamage(EntityDamageByEntitiyEvent $daddy) { $daddy->getEntitiy()->setMotion(new Vector3(0.3,0.5,0.3)); }}
Code: Server thread/CRITICAL ReflectionException: "Class Knockback\EntityDamageEvent does not exist" (EXCEPTION) in "src/pocketmine/plugin/PluginManager" at line 769 27.10 01:41:02 [Server] Server thread/DEBUG #0 src/pocketmine/plugin/PluginManager(769): ReflectionParameter->getClass() 27.10 01:41:02 [Server] Server thread/DEBUG #1 Knockback/src/Knockback/Main(16): pocketmine\plugin\PluginManager->registerEvents(Knockback\Main object, Knockback\Main object) 27.10 01:41:02 [Server] Server thread/DEBUG #2 src/pocketmine/plugin/PluginBase(90): Knockback\Main->onEnable() 27.10 01:41:02 [Server] Server thread/DEBUG #3 PocketMine-DevTools_dev-63.phar/src/FolderPluginLoader/FolderPluginLoader(125): pocketmine\plugin\PluginBase->setEnabled(boolean 1) 27.10 01:41:02 [Server] Server thread/DEBUG #4 src/pocketmine/plugin/PluginManager(610): FolderPluginLoader\FolderPluginLoader->enablePlugin(Knockback\Main object) 27.10 01:41:02 [Server] Server thread/DEBUG #5 src/pocketmine/Server(1940): pocketmine\plugin\PluginManager->enablePlugin(Knockback\Main object) 27.10 01:41:02 [Server] Server thread/DEBUG #6 src/pocketmine/Server(1926): pocketmine\Server->enablePlugin(Knockback\Main object) 27.10 01:41:02 [Server] Server thread/DEBUG #7 src/pocketmine/Server(1712): pocketmine\Server->enablePlugins(integer 1) 27.10 01:41:02 [Server] Server thread/DEBUG #8 src/pocketmine/PocketMine(558): pocketmine\Server->__construct(BaseClassLoader object, pocketmine\utils\MainLogger object, string phar:///custom-php7.2.phar/, string /, string /plugins/) 27.10 01:41:02 [Server] Server thread/DEBUG #9 /custom-php7.2.phar(1): require(string phar:///custom-php7.2.phar/src/pocketmine/PocketMine.php) 27.10 01:41:02 [Server] Server thread/INFO Disabling Knockback v1.0.2
I got this error when I treied the function I tried reading the error a couple times but cant find out what it actually means can you help? @robske_110 (Tim)