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

Solved how do i fix with setting cape to player?

Discussion in 'Development' started by korado531m7, Jul 25, 2018.

  1. korado531m7

    korado531m7 Slime

    Messages:
    77
    GitHub:
    korado531m7
    I'm writing set cape but error occurred.
    here's the error
    InvalidStateException: "Specified skin is not valid, must be 8KiB or 16KiB" (EXCEPTION) in "src/pocketmine/entity/Human" at line 148

    and code
    PHP:
            $player $event->getPlayer();
            
    $path $this->getDataFolder().'test.png'//image path
            
    $oldSkin $player->getSkin();
           
            
    $im imagecreatefrompng($path);
            
    $rgba "";
           
            for(
    $y 0$y imagesy($im); $y++) {
                for(
    $x 0$x imagesx($im); $x++) {
                    
    $rgb imagecolorat($im$x$y);
                    
    $r = ($rgb >> 16) & 0xFF;
                    
    $g = ($rgb >> 8) & 0xFF;
                    
    $b $rgb 0xFF;
                    
    $rgba .= chr($r).chr($g).chr($b).chr(255);
                }
            }
           
            
    $skin = new Skin($oldSkin->getSkinId(), $oldSkin->getSkinData(), $rgba$oldSkin->getGeometryName(), $oldSkin->getGeometryData());
            
    $player->setSkin($skin);
            
    $player->sendSkin();
     
  2. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    Check out this thread, and in the future, try searching for your question first.
     
    Muqsit and korado531m7 like this.
  3. korado531m7

    korado531m7 Slime

    Messages:
    77
    GitHub:
    korado531m7
    sorry. but it solved thank you
     
  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.