-
-
Save robske110/5f93a00b2dee86b83497c437edfe4451 to your computer and use it in GitHub Desktop.
Set a player's skin in PMMP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$path = 'your/path/to/skin.png'; | |
$img = @imagecreatefrompng($path); | |
$bytes = ''; | |
$l = (int) @getimagesize($path)[1]; | |
for ($y = 0; $y < $l; $y++) { | |
for ($x = 0; $x < 64; $x++) { | |
$rgba = @imagecolorat($img, $x, $y); | |
$a = ((~((int)($rgba >> 24))) << 1) & 0xff; | |
$r = ($rgba >> 16) & 0xff; | |
$g = ($rgba >> 8) & 0xff; | |
$b = $rgba & 0xff; | |
$bytes .= chr($r) . chr($g) . chr($b) . chr($a); | |
} | |
} | |
@imagedestroy($img); | |
/** @var pocketmine\Player $player */ | |
$player->setSkin(new pocketmine\entity\Skin("Standard_CustomSlim", $bytes)); //Standard_CustomSlim for alex | |
$player->sendSkin(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment