TNT Launcher spam

Discussion in 'Development' started by MalakasPlayzMCPE, Aug 9, 2018.

  1. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    603
    Code:
    PHP:
            $nbt = new CompoundTag"", [
                
    "Pos" => new ListTag("Pos", [
                        new 
    DoubleTag(""$player->x),
                        new 
    DoubleTag(""$player->y+$player->getEyeHeight()),
                        new 
    DoubleTag(""$player->z)
                ]),
                
    "Motion" => new ListTag("Motion", [
                        new 
    DoubleTag("", -\sin ($player->yaw 180 M_PI) *\cos ($player->pitch 180 M_PI)),
                        new 
    DoubleTag ("", -\sin ($player->pitch 180 M_PI)),
                        new 
    DoubleTag("",\cos ($player->yaw 180 M_PI) *\cos $player->pitch 180 M_PI))
                ]),
                
    "Rotation" => new ListTag("Rotation", [
                        new 
    FloatTag(""$player->yaw),
                        new 
    FloatTag(""$player->pitch)
                ])
            ]);
            
    $f 3.0;
            
    $tntentity Entity::createEntity("PrimedTNT"$player->getlevel(), $nbt$player);
            
    $tntentity->setMotion($tntentity->getMotion()->multiply($f));
            
    $tntentity->spawnToAll();
    Error:
    Code:
    2018-08-08 [18:52:24] [Server thread/CRITICAL]: Could not tick level "Lobby": Argument 1 passed to pocketmine\network\mcpe\NetworkBinaryStream::putByteRotation() must be of the type float, null given, called in phar:///home/gs/gs/data/servers/7069490/PocketMine-MP.phar/src/pocketmine/network/mcpe/protocol/MoveEntityAbsolutePacket.php on line 64
    2018-08-08 [18:52:24] [Server thread/CRITICAL]: TypeError: "Argument 1 passed to pocketmine\network\mcpe\NetworkBinaryStream::putByteRotation() must be of the type float, null given, called in phar:///home/gs/gs/data/servers/7069490/PocketMine-MP.phar/src/pocketmine/network/mcpe/protocol/MoveEntityAbsolutePacket.php on line 64" (EXCEPTION) in "src/pocketmine/network/mcpe/NetworkBinaryStream" at line 407
    2018-08-08 [18:52:24] [Server thread/DEBUG]: #0 src/pocketmine/network/mcpe/protocol/MoveEntityAbsolutePacket(64): pocketmine\network\mcpe\NetworkBinaryStream->putByteRotation(NULL )
    2018-08-08 [18:52:24] [Server thread/DEBUG]: #1 src/pocketmine/network/mcpe/protocol/DataPacket(89): pocketmine\network\mcpe\protocol\MoveEntityAbsolutePacket->encodePayload()
    2018-08-08 [18:52:24] [Server thread/DEBUG]: #2 src/pocketmine/network/mcpe/PacketStream(33): pocketmine\network\mcpe\protocol\DataPacket->encode()
    2018-08-08 [18:52:24] [Server thread/DEBUG]: #3 src/pocketmine/Server(1899): pocketmine\network\mcpe\PacketStream->putPacket(pocketmine\network\mcpe\protocol\MoveEntityAbsolutePacket object)
    2018-08-08 [18:52:24] [Server thread/DEBUG]: #4 src/pocketmine/level/Level(804): pocketmine\Server->broadcastPackets(array Array(), array Array())
    2018-08-08 [18:52:24] [Server thread/DEBUG]: #5 src/pocketmine/Server(2398): pocketmine\level\Level->doTick(integer 6709)
    2018-08-08 [18:52:24] [Server thread/DEBUG]: #6 src/pocketmine/Server(2555): pocketmine\Server->checkTickUpdates(integer 6709)
    2018-08-08 [18:52:24] [Server thread/DEBUG]: #7 src/pocketmine/Server(2297): pocketmine\Server->tick()
    2018-08-08 [18:52:24] [Server thread/DEBUG]: #8 src/pocketmine/Server(2175): pocketmine\Server->tickProcessor()
    2018-08-08 [18:52:24] [Server thread/DEBUG]: #9 src/pocketmine/Server(1728): pocketmine\Server->start()
    2018-08-08 [18:52:24] [Server thread/DEBUG]: #10 src/pocketmine/PocketMine(245): pocketmine\Server->__construct(BaseClassLoader object, pocketmine\utils\MainLogger object, string /home/gs/gs/data/servers/7069490/, string /home/gs/gs/data/servers/7069490/plugins/)
    2018-08-08 [18:52:24] [Server thread/DEBUG]: #11 /home/gs/gs/data/servers/7069490/PocketMine-MP.phar(1): require(string phar:///home/gs/gs/data/servers/7069490/PocketMine-MP.phar/src/pocketmine/PocketMine.php)
    
    Before the 1.5 update the code worked without this console spam (yes, it spams multiple times till all players leave).
     
  2. Muqsit

    Muqsit Wither Skeleton Verified

    Messages:
    1,441
    GitHub:
    muqsit
    More like, there was a bug in your code which has finally been exposed since you updated pocketmine ;)
     
    HimbeersaftLP likes this.
  3. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    603
    Well, I updated my code.
    PHP:
                $nbt Entity::createBaseNBT($player->add(0$player->getEyeHeight(), 0), $player->getDirectionVector(), $player->yaw$player->pitch);
                
    $projectile Entity::createEntity("PrimedTNT"$player->getLevel(), $nbt$player);
                
    $projectile->setMotion($projectile->getMotion()->multiply(3.0));
                
    $projectile->spawnToAll();
    Same error. Anything related with Slapper or SlapperRotation?
     
  4. Muqsit

    Muqsit Wither Skeleton Verified

    Messages:
    1,441
    GitHub:
    muqsit
    SlapperRotation hasn't officially been updated to 1.5. Anyway, if that's all the code you're executing, then something else is causing the error.
     
  5. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    603
    I know it hasn't. I updated it manually using the renamed packet (and the xRot stuff). Everything works fine if I do not launch TNTs. It is the only plugin I have installed using that packet though. I am sure it has to do with Slapper or SlapperRotation. I use the API 4.0.0, which is technically "unstable", but what makes it stable is only that: https://github.com/pmmp/PocketMine-...065abe0#diff-8635f5206bab8ecea0bd8b675fd07c89
     
  6. Muqsit

    Muqsit Wither Skeleton Verified

    Messages:
    1,441
    GitHub:
    muqsit
    Pretty sure it's SlapperRotation, can you send the code where you create and send that packet?
     
  7. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    603
    PHP:
    <?php
    namespace SlapperRotation;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\event\player\PlayerMoveEvent;
    use 
    pocketmine\math\Vector2;
    use 
    pocketmine\network\mcpe\protocol\MoveEntityAbsolutePacket;
    use 
    pocketmine\network\mcpe\protocol\MovePlayerPacket;
    use 
    pocketmine\Player;
    use 
    pocketmine\plugin\PluginBase;
    class 
    Main extends PluginBase implements Listener {
        public function 
    onEnable() {
            
    $this->saveDefaultConfig();
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
        }
        public function 
    onPlayerMove(PlayerMoveEvent $ev) {
            
    $player $ev->getPlayer();
            
    $from $ev->getFrom();
            
    $to $ev->getTo();
            if(
    $from->distance($to) < 0.1) {
                return;
            }
            
    $maxDistance $this->getConfig()->get("max-distance");
            foreach (
    $player->getLevel()->getNearbyEntities($player->getBoundingBox()->expandedCopy($maxDistance$maxDistance$maxDistance), $player) as $e) {
                if(
    $e instanceof Player) {
                    continue;
                }
                if(
    substr($e->getSaveId(), 07) !== "Slapper") {
                    continue;
                }
                switch (
    $e->getSaveId()) {
                    case 
    "SlapperFallingSand":
                    case 
    "SlapperMinecart":
                    case 
    "SlapperBoat":
                    case 
    "SlapperPrimedTNT":
                    case 
    "SlapperShulker":
                        continue 
    2;
                }
                
    $xdiff $player->$e->x;
                
    $zdiff $player->$e->z;
                
    $angle atan2($zdiff$xdiff);
                
    $yaw = (($angle 180) / M_PI) - 90;
                
    $ydiff $player->$e->y;
                
    $v = new Vector2($e->x$e->z);
                
    $dist $v->distance($player->x$player->z);
                
    $angle atan2($dist$ydiff);
                
    $pitch = (($angle 180) / M_PI) - 90;
                if(
    $e->getSaveId() === "SlapperHuman") {
                    
    $pk = new MovePlayerPacket();
                    
    $pk->entityRuntimeId $e->getId();
                    
    $pk->position $e->asVector3()->add(0$e->getEyeHeight(), 0);
                    
    $pk->yaw $yaw;
                    
    $pk->pitch $pitch;
                    
    $pk->headYaw $yaw;
                    
    $pk->onGround $e->onGround;
                } else {
                    
    $pk = new MoveEntityAbsolutePacket();
                    
    $pk->entityRuntimeId $e->getId();
                    
    $pk->position $e->asVector3();
                    
    $pk->xRot $pitch;
                    
    $pk->yRot $yaw;
                    
    $pk->zRot $yaw;
                }
                
    $player->dataPacket($pk);
            }
        }
    }
    Giving whole code just in case.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.