1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Modifying sent packets/Sending packets

Discussion in 'Development' started by BaleineSanguine, Apr 23, 2020.

  1. BaleineSanguine

    BaleineSanguine Spider

    Messages:
    10
    GitHub:
    baleinesanguine
    Ok so I need to have a server only nbt tag. My current idea is to modify the packets send by pocketmine to the client and remove the nbt tag. How do I do this ?

    Here is my current code (I'm cancelling the packet to send a new one):
    PHP:
        public function onPacketSend(DataPacketSendEvent $event) {
            
    $packet $event->getPacket();
            
    $player $packet->getPlayer();
            
    $class get_class($packet);
            echo 
    $class "\n";
            if (
    $class == "pocketmine\\network\\mcpe\\protocol\\InventorySlotPacket") {
                
    $event->setCancelled(true);
                
    $newPacket = new InventorySlotPacket();
            } else if (
    $class "pocketmine\\network\\mcpe\\protocol\\InventoryContentPacket") {
                
    //$event->setCancelled(true);
            
    } else if ($class "pocketmine\\network\\mcpe\\protocol\\") {
                
    $event->setCancelled(true);
            }
        }
     
  2. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    598
    GitHub:
    GamakCZ
    Why you want to do that?
     
  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.