<commit_before><?php
error_reporting(E_ALL);

require_once 'mcpi/vec3.php';
require_once 'mcpi/block.php';
require_once 'mcpi/connection.php';
require_once 'mcpi/event.php';

function intFloor($data){
    $dataToSend=array();
    if (is_array($data)){
        foreach ($data as $el){
            if (is_object($el) && is_a($el, 'Block')){
                $dataToSend = array_merge($dataToSend, $el->to_array());
            }else{
                 $dataToSend[] = $el;
            }
        }
    }else{
        if (is_object($data) && is_a($data, 'Block')){
            $dataToSend = array_merge($dataToSend, $el->to_array());
        }else{
             $dataToSend[] = $el;
        }
    }
    $dataToSend = array_map('floor', $dataToSend);
    return $dataToSend;
}

function getNumFromStatusBool($boolean){
    if ($boolean === 1 || strtolower($boolean) === 'true' || $boolean === true){
        return 1;
    }else{
        return 0;
    }
}

class CmdPositioner{

    private $conn, $pkg;
    
    function __construct($conn, $pkg='Unknown'){
        $this->conn = $conn;
        $this->pkg  = $pkg;
    }

    //Methods for setting and getting positions
    function getPos(){
        $args = func_get_args();
        $id = array_shift($args);
        //Get entity position (entityId:int) => Vec3
        $s = $this->conn->send_and_receive($this->pkg. ".getPos", $id);
        return new Vec3(array_map('floatval', explode(",",$s)));
    }

    function setPos(){
        $args = func_get_args();
        $id = array_shift($args);
        $data = flatten($args);
        //Set entity position (entityId:int, x,y,z)
        $this->conn->send($this->pkg.".setPos", $id, $data);
    }

    function getTilePos(){
        $args = func_get_args();
        $id = array_shift($args);
        $response = $this->conn->send_and_receive($this->pkg.".getTile", $id);
        $coords =  explode(",", $response);
        $intversion = array_map("intval", $coords);
        $result = new Vec3($intversion);
        return $result;
    }

    function setTilePos(){
        $args = func_get_args();
        $id = array_shift($args);
        $data = flatten($args);
        //Set entity tile position (entityId:int) => Vec3
        $this->conn->send($this->pkg.".setTile", $id, intFloor($data));
    }

    function setting($setting, $status){
        //Set a player setting (setting, status). keys: autojump
        $status = getNumFromStatusBool($status);
        $this->conn->send($this->pkg. ".setting", $setting, $status);  
    }
}


class CmdEntity extends CmdPositioner{

    //Methods for entities
    function __construct($conn){
        parent::__construct($conn, "entity");
    }
} 

class CmdPlayer extends CmdPositioner{


   //Methods for the host (Raspberry Pi) player
    function __construct($conn){
        parent::__construct($conn, "player");

    }
    
    function getPos(){
        return parent::getPos(array());
    }
    function setPos(){
        $data = func_get_args();
        return parent::setPos(array(), $data);
    }
    function getTilePos(){

        return parent::getTilePos(array());
    }

    function setTilePos(){
        echo"insetTilePos\n";
        $data = func_get_args();
        return parent::setTilePos(array(), $data);
    }
}

class CmdCamera{

    private $conn;
    
    function __construct($conn){
        $this->conn = $conn;
    }

    function setNormal(){
        $data = func_get_args();
        // Set camera mode to normal Minecraft view ([entityId])
        $this->conn->send("camera.mode.setNormal", $data);
    }

    function setFixed(){
        //  Set camera mode to fixed view
        $this->conn->send("camera.mode.setFixed");
    }<commit_msg>Remove debug print out message<commit_after><?php
error_reporting(E_ALL);

require_once 'mcpi/vec3.php';
require_once 'mcpi/block.php';
require_once 'mcpi/connection.php';
require_once 'mcpi/event.php';

function intFloor($data){
    $dataToSend=array();
    if (is_array($data)){
        foreach ($data as $el){
            if (is_object($el) && is_a($el, 'Block')){
                $dataToSend = array_merge($dataToSend, $el->to_array());
            }else{
                 $dataToSend[] = $el;
            }
        }
    }else{
        if (is_object($data) && is_a($data, 'Block')){
            $dataToSend = array_merge($dataToSend, $el->to_array());
        }else{
             $dataToSend[] = $el;
        }
    }
    $dataToSend = array_map('floor', $dataToSend);
    return $dataToSend;
}

function getNumFromStatusBool($boolean){
    if ($boolean === 1 || strtolower($boolean) === 'true' || $boolean === true){
        return 1;
    }else{
        return 0;
    }
}

class CmdPositioner{

    private $conn, $pkg;
    
    function __construct($conn, $pkg='Unknown'){
        $this->conn = $conn;
        $this->pkg  = $pkg;
    }

    //Methods for setting and getting positions
    function getPos(){
        $args = func_get_args();
        $id = array_shift($args);
        //Get entity position (entityId:int) => Vec3
        $s = $this->conn->send_and_receive($this->pkg. ".getPos", $id);
        return new Vec3(array_map('floatval', explode(",",$s)));
    }

    function setPos(){
        $args = func_get_args();
        $id = array_shift($args);
        $data = flatten($args);
        //Set entity position (entityId:int, x,y,z)
        $this->conn->send($this->pkg.".setPos", $id, $data);
    }

    function getTilePos(){
        $args = func_get_args();
        $id = array_shift($args);
        $response = $this->conn->send_and_receive($this->pkg.".getTile", $id);
        $coords =  explode(",", $response);
        $intversion = array_map("intval", $coords);
        $result = new Vec3($intversion);
        return $result;
    }

    function setTilePos(){
        $args = func_get_args();
        $id = array_shift($args);
        $data = flatten($args);
        //Set entity tile position (entityId:int) => Vec3
        $this->conn->send($this->pkg.".setTile", $id, intFloor($data));
    }

    function setting($setting, $status){
        //Set a player setting (setting, status). keys: autojump
        $status = getNumFromStatusBool($status);
        $this->conn->send($this->pkg. ".setting", $setting, $status);  
    }
}


class CmdEntity extends CmdPositioner{

    //Methods for entities
    function __construct($conn){
        parent::__construct($conn, "entity");
    }
} 

class CmdPlayer extends CmdPositioner{


   //Methods for the host (Raspberry Pi) player
    function __construct($conn){
        parent::__construct($conn, "player");

    }
    
    function getPos(){
        return parent::getPos(array());
    }
    function setPos(){
        $data = func_get_args();
        return parent::setPos(array(), $data);
    }
    function getTilePos(){

        return parent::getTilePos(array());
    }

    function setTilePos(){
        $data = func_get_args();
        return parent::setTilePos(array(), $data);
    }
}

class CmdCamera{

    private $conn;
    
    function __construct($conn){
        $this->conn = $conn;
    }

    function setNormal(){
        $data = func_get_args();
        // Set camera mode to normal Minecraft view ([entityId])
        $this->conn->send("camera.mode.setNormal", $data);
    }

    function setFixed(){
        //  Set camera mode to fixed view
        $this->conn->send("camera.mode.setFixed");
    }
{'fraction_non_alphanumeric': 0.16439465514914292, 'fraction_numerical': 0.002159535699824538, 'mean_word_length': 2.4417092429168603, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6229680', 'n_tokens_mistral': 2370, 'n_tokens_neox': 2319, 'n_words': 495}