Last active
May 28, 2022 12:23
-
-
Save dadodasyra/5394a94c876d355f0ce74cb85fedb6ad to your computer and use it in GitHub Desktop.
Add this code where you want to steal the skin of $sender, change the path at the imagepng method to your target
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 | |
$height = 64; | |
$width = 64; | |
switch (strlen($sender->getSkin()->getSkinData())) { | |
case 64 * 32 * 4: | |
$height = 32; | |
break; | |
case 64 * 64 * 4: | |
break; | |
case 128 * 64 * 4: | |
$width = 128; | |
break; | |
case 128 * 128 * 4: | |
$height = 128; | |
$width = 128; | |
break; | |
} | |
$img = imagecreatetruecolor($width, $height); | |
imagealphablending($img, false); | |
imagesavealpha($img, true); | |
$index = 0; | |
for ($y = 0; $y < $height; ++$y) { | |
for ($x = 0; $x < $width; ++$x) { | |
$list = substr($sender->getSkin()->getSkinData(), $index, 4); | |
$r = ord($list[0]); | |
$g = ord($list[1]); | |
$b = ord($list[2]); | |
$a = 127 - (ord($list[3]) >> 1); | |
$index += 4; | |
$color = imagecolorallocatealpha($img, $r, $g, $b, $a); | |
imagesetpixel($img, $x, $y, $color); | |
} | |
} | |
imagepng($img, "/root/custom.png"); | |
imagedestroy($img); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment