-
-
Save jasonw4331/3700076f48c89f6f9c54d4a2632a2a36 to your computer and use it in GitHub Desktop.
Set a player's skin in PMMP
This file contains 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
👍