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

Get a Player Skin's Head?

Discussion in 'Development' started by CaptainDuck, May 28, 2017.

  1. CaptainDuck

    CaptainDuck Spider

    Messages:
    8
    GitHub:
    captainduck
    Hi! I'm trying to create this DropHeads plugin..
    I want to ask, I know the SkinData things, but I'm having trouble getting some properties of it, is there like a code or API to get the Head, Hand, or Leg, of a Skin Data??
     
    Levi likes this.
  2. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    I dont think in MCPE it's possible to have custom head items
    but you can store the head skin in NBT and spawn an entity with only visible head by sticking it in ground for ex
     
    gistrec and corytortoise like this.
  3. CaptainDuck

    CaptainDuck Spider

    Messages:
    8
    GitHub:
    captainduck
    Oh okay :/. Thanks!
     
    Last edited: May 28, 2017
  4. LucGamesDE

    LucGamesDE Baby Zombie

    Messages:
    170
    Im also interested in this. Can u give me an example?
     
  5. FairSYS

    FairSYS Spider

    Messages:
    6
    GitHub:
    Nada
    You already tested this ?

    PHP:
    private $messages;
        private 
    $player;
        private 
    $skindata;

        public function 
    __construct(string $playerstring $skindata, array $messages)
        {
            
    $this->messages = (array) $messages;
            
    $this->player $player;
            
    $this->skindata $skindata;
        }

        private function 
    rgbToTextFormat($r$g$b)
        {
            
    $differenceList = [];
            foreach(
    self::TEXTFORMAT_RGB as $value){
                
    $difference sqrt(pow($r $value[0],2) + pow($g $value[1],2) + pow($b $value[2],2));
                
    $differenceList[] = $difference;
            }
            
    $smallest min($differenceList);
            
    $key array_search($smallest$differenceList);
            return 
    self::TEXTFORMAT_LIST[$key];
        }

        public function 
    onRun()
        {
            
    $symbol hex2bin(self::HEX_SYMBOL);
            
    $strArray = [];
            
    $skin substr($this->skindata, ($pos = (64 4)) - 4$pos);
            for(
    $y 0$y 8; ++$y){
                for(
    $x 1$x 9; ++$x){
                    if(!isset(
    $strArray[$y])){
                        
    $strArray[$y] = "";
                    }
                    
    $key = ((64 $y) + $x) * 4;
                    
    $r ord($skin{$key});
                    
    $g ord($skin{$key 1});
                    
    $b ord($skin{$key 2});
                    
    $format $this->rgbToTextFormat($r$g$b);
                    
    $strArray[$y] .= $format.$symbol;
                }
            }
            foreach(
    $this->messages as $k => $v){
                
    $strArray[$k 1] = $strArray[$k 1]." ".str_replace("{NAME}"$this->player$v);
            }
            
    $this->setResult(implode("\n"$strArray));
        }

        public function 
    onCompletion(Server $server)
        {
            if((
    $player $server->getPlayerExact($this->player)) !== null){
                
    $player->sendMessage($this->getResult());
            }
        }
    }
     
    Last edited by a moderator: Jun 10, 2017
  6. Legoboy0215

    Legoboy0215 Witch

    Messages:
    64
    GitHub:
    legoboy0215
    Can you please put that in a code block? Or even better, link the code: https://github.com/Muqsit/FaceLogin/blob/master/src/Muqsit/SendPlayerFaceTask.php
     
  7. FairSYS

    FairSYS Spider

    Messages:
    6
    GitHub:
    Nada
  8. Legoboy0215

    Legoboy0215 Witch

    Messages:
    64
    GitHub:
    legoboy0215
    ? It doesn't matter, as long as you remember next time ;)
     
  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.