Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Bug with Teleportation or Vector3/Position.

Comments in 'Plugin Development' started by RumDaDuMCPE, Oct 25, 2016.

  1. RumDaDuMCPE
    Offline

    RumDaDuMCPE New Member

    Joined:
    Oct 18, 2016
    Posts:
    12
    Minecraft User:
    RumDaDuMCPE
    neither does the code below doesn't give out any console error nor does the Teleportation work. The JoinEvent works though.
    PHP:
    <?php
    namespace RumDaDuMCPE;

    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\event\server\DataPacketReceiveEvent;
    use 
    pocketmine\event\player\PlayerJoinEvent;
    use 
    pocketmine\item\Item;
    use 
    pocketmine\Player;
    use 
    pocketmine\Server;


    class 
    Main extends PluginBase implements Listener {
        public function 
    onEnable() {
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
          }
        public function 
    onTap(DataPacketReceiveEvent $e) {
            
    $p $e->getPlayer();
            
    $pk $e->getPacket();
            
    $level $this->getServer()->getLevelByName("world");
            if (
    $pk instanceof UseItemPacket and $pk->face === 0xff) {
                        if (
    $p->getInventory()->getItemInHand()->getId() == 264 and $p->getInventory()->getItemInHand()->hasCustomName()) {
                            
    $p->Teleport(new Vector3(-4418263));
                            }
                 }
           }
        public function 
    onJoin(PlayerJoinEvent $e) {
            
    $p $e->getPlayer();
            
    $item Item::get(26401);
            
    $item->setCustomName("test");
            
    $test $item;
            
    $p->getInventory()->addItem($test);

     }
    }
    Aye! Thanks for your help <3
  2. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    $p->teleport() not $p->Teleport()
    ****↑****************↑********
  3. Vaivez66
    Offline

    Vaivez66 Notable Member Plugin Developer

    Joined:
    Jun 10, 2015
    Posts:
    402
    Plugins:
    2
    Pretty sure function name is case insensitive...
  4. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    Nope.
  5. Vaivez66
    Offline

    Vaivez66 Notable Member Plugin Developer

    Joined:
    Jun 10, 2015
    Posts:
    402
    Plugins:
    2
  6. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
  7. Vaivez66
    Offline

    Vaivez66 Notable Member Plugin Developer

    Joined:
    Jun 10, 2015
    Posts:
    402
    Plugins:
    2
  8. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    Wow, this is cool, I didn't know it was possible ;)

    Does the custom name actually show up? If not that might be the problem.
    HimbeersaftLP likes this.
  9. Mat
    Offline

    Mat Active Member Plugin Developer

    Joined:
    Jun 15, 2014
    Posts:
    179
    Plugins:
    1
    Minecraft User:
    matcracker
    I think UseItemPacket is never received.

    Try PlayerInteractEvent :)
  10. Thunder33345
    Offline

    Thunder33345 Notable Member

    Joined:
    Apr 3, 2014
    Posts:
    755
    Minecraft User:
    Thunder33345
    well it would be a good idea to log when an event is called like
    ontap
    //log it to console ontap have been called
  11. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    When you dont receive errors, it mostly means that the thing you wanted didnt get called. To check whether something was called do
    PHP:
    var_dump("Called: ".__LINE__);
    __LINE__ is a Magic consant, so dont wonder why it's not a variable nor a function.

    Paste it after every every if() check in your code.
    Last edited: Oct 25, 2016
    HimbeersaftLP and xBeastMode like this.

Share This Page

Advertisement