Summary: I attempted to change the skin using Player->setSkin(), Player->sendSkin(), but the skin size does not become either 8KiB or 16KiB. I wrote the following code, but it does not work. PHP: // On PlayerJoinEvent$data = base64_encode(file_get_contents($this->getDataFolder()."Steve.png"));$skin = new Skin("Standard_Custom", $data);$p = $e->getPlayer();$p->setSkin($skin);$p->sendSkin($this->getServer()->getOnlinePlayers());
That is not the correct way to read the skin's data. The right way would be: PHP: $image = imagecreatefrompng($this->getDataFolder() . "Steve.png");$data = '';for ($y = 0, $height = imagesy($image); $y < $height; $y++) { for ($x = 0, $width = imagesx($image); $x < $width; $x++) { $color = imagecolorat($image, $x, $y); $data .= pack("c", ($color >> 16) & 0xFF) //red . pack("c", ($color >> 8) & 0xFF) //green . pack("c", $color & 0xFF) //blue . pack("c", 0xFF); //alpha }} But you need the GD extension for that. For windows, you'll only need to enable it in php.ini, but for linux I still don't know, was trying to figure out myself.
for linux you just need to recompile php using php-build-scripts with the -g flag. https://github.com/pmmp/php-build-scripts
The skin was changed, but the skins were not loaded properly, and a part or all was discolored black.
Can you please send a screenshot and your "Steve.png" file? I do suspect what may be the problem here, but I want to be sure.
As I thought, the problem here is the alpha channel. The second layer gets completely opaque, but without color. So the correct code will be: PHP: $image = imagecreatefrompng($this->getDataFolder() . "Steve.png");$data = '';for ($y = 0, $height = imagesy($image); $y < $height; $y++) { for ($x = 0, $width = imagesx($image); $x < $width; $x++) { $color = imagecolorat($image, $x, $y); $data .= pack("c", ($color >> 16) & 0xFF) //red . pack("c", ($color >> 8) & 0xFF) //green . pack("c", $color & 0xFF) //blue . pack("c", 255 - (($color & 0x7F000000) >> 23)); //alpha }}
PHP: $skin = imagecreatefrompng(Core::getDataFolder() . "Steve.png"); $data = ''; for($y = 0, $height = imagesy($skin); $y < $height; $y++){ $color = imagecolorat($skin, $x, $y); $data .= pack("c", ($color >> 16) & 0xFF) . pack("c", ($color >> 8) & 0xFF) . pack("c", $color & 0xFF) . pack("c", 255 - (($color & 0x7F000000) >> 23)); } $player->setSkin($skin); [/php] Could not pass event 'pocketmine\event\player\PlayerJoinEvent' to 'ExonCore v1.0.0': Call to undefined function ExonCore\events\imagecreatefrompng() on ExonCore\events\JoinSystemEvent [16:50:36] [Server thread/CRITICAL]: Error: "Call to undefined function ExonCore\events\imagecreatefrompng()" (EXCEPTION) in "ExonPECore-master/src/ExonCore/events/JoinSystemEvent" at line 43
This: Moreover, that code that you've pasted here won't work, since you've left out the X loop for some reason.
Code: ;Custom PocketMine-MP php.ini file display_errors=1 display_startup_errors=1 error_reporting=-1 zend.assertions=-1 phar.readonly=0 extension_dir=ext extension=php_pthreads.dll extension=php_openssl.dll extension=php_pocketmine_chunkutils.dll extension=php_igbinary.dll extension=php_ds.dll igbinary.compact_strings=0 ;zend_extension=php_opcache.dll ;The following extensions are included as shared extensions (DLLs) but disabled by default as they are optional. Uncomment the ones you want to enable. ;extension=php_gd2.dll ;extension=php_mysqli.dll extension=php_sqlite3.dll