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

server.schedule for yaw?

Comments in 'Plugin Development' started by PEMapModder, Jun 26, 2014.

  1. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Just now I have made this simple snippet to ensure my knowledge on yaw and pitch.
    So here it is:
    PHP:
    <?php

    /*
    __PocketMine Plugin__
    class=TestThings
    name=TestThings
    author=PEMapModder
    version=0
    apiversion=12
    */

    class TestThings implements Plugin{
        public function 
    __construct(ServerAPI $api$s 0){
            
    $this->api $api;
        }
        public function 
    init(){
            
    $this->api->console->register("y""yaw", array($this"cmd"));
            
    $this->api->console->register("p""pitch", array($this"cmd"));
            
    $this->api->console->register("c""coords", array($this"cmd"));
            
    $this->api->console->register("v""vectors", array($this"cmd"));
        }
        public function 
    __destruct(){
        }
        public function 
    cmd($c$a$i){
            if(!(
    $i instanceof Player)) return "Run in-game.";
            
    $e $i->entity;
            switch(
    $c){
                case 
    "p":
                    return 
    "Your pitch is ".$e->pitch;
                case 
    "y":
                    return 
    "Your yaw is ".($e->yaw 360);
                case 
    "c":
                    return 
    "You are at ".$e->x.", ".$e->y.", ".$e->z;
                case 
    "v":
                    return 
    "Your vector is ".self::getVector($e->yaw);
            }
        }
        public static function 
    getVector($yaw){
            
    $oldRef $yaw;
            
    console("Evaluating $yaw");
            
    $yaw += 45;
            while(
    $yaw 0){
                
    $yaw += 360;
            }
            
    console("Yaw added to $yaw");
            
    $yaw $yaw 360;
            
    console("Modular operator turned to $yaw");
            
    $yaw = (int) ($yaw 90);
            
    console("Divided to $yaw");
            switch(
    $yaw 4){
                case 
    0:
                    return 
    "z+";
                case 
    1:
                    return 
    "x-";
                case 
    2:
                    return 
    "z-";
                case 
    3:
                    return 
    "x+";
                default:
                    
    console("Yaw $oldRef evaluated as $yaw and no response");
            }
        }
    }
    But strangely, when I newly joined the server, I run /sudo pemapmodder v, and then this strange message appears:
    Code:
    07:16:26 [INFO] PEMapModder[/192.168.0.101:56784] logged in with entity id 1 at (world, 157.05, 64, 120.28)
    07:16:38 [DEBUG] PEMapModder issued server command: /v
    07:16:38 Evaluating server.schedule
    07:16:38 Yaw added to 45
    07:16:38 Modular operator turned to 45
    07:16:38 Divided to 0
    07:16:44 [DEBUG] PEMapModder issued server command: /v
    07:16:44 Evaluating 1.4188497066498
    07:16:44 Yaw added to 46.41884970665
    07:16:44 Modular operator turned to 46
    07:16:44 Divided to 0
    07:16:50 [DEBUG] PEMapModder issued server command: /v
    07:16:50 Evaluating 73.648063659668
    07:16:50 Yaw added to 118.64806365967
    07:16:50 Modular operator turned to 118
    07:16:50 Divided to 1
    07:16:57 [DEBUG] PEMapModder issued server command: /v
    07:16:57 Evaluating 168.43960571289
    07:16:57 Yaw added to 213.43960571289
    07:16:57 Modular operator turned to 213
    07:16:57 Divided to 2
    07:17:01 [DEBUG] PEMapModder issued server command: /v
    07:17:01 Evaluating 266.39730834961
    07:17:01 Yaw added to 311.39730834961
    07:17:01 Modular operator turned to 311
    07:17:01 Divided to 3
    
    Why did this happen? server.schedule only appeared for the first time, then once I move, it is no longer server.schedule. Can someone explain this? Is this supposed to be a bug? But if so, how could the functions change it to a number (instead of 0, the supposed cast-to-string of "server.schedule")?

    I think the answer is Herobrine dominated my entity.
  2. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    You are the plugin god how you don't know why
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    If I am, what are people like @wies?
    Darunia18 likes this.
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    I think I just found out a possible reason. Maybe somehow a schedule scheduled a call back array($player, "teleport") and the scheduler added a parameter 2 "server.schedule", so $player->teleport($vectors, "server.schedule is called?

Share This Page

Advertisement