Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Change the player into a Villager and save a players skin as a png?

Comments in 'Plugin Development' started by WrackD, Aug 8, 2015.

  1. WrackD
    Offline

    WrackD New Member

    Joined:
    May 10, 2015
    Posts:
    7
    Minecraft User:
    WrackD
    Hello. I am pretty new to this forum. I am currently working on a minigame plugin where I want all players to look like villagers. I don't mind making the player invisible and spawning a villager which follows him.. But I am not sure how to spawn an entity and make it follow a player....

    My second question is: How can I save a players skin as a png file on the server. You might wonder why I need this. I am making a server application and I need to get the players skin for it. I am not sure if it is easy or even possible but if it is I would like to do it.

    Thanx in advance,
    Aditya.
    Last edited: Aug 8, 2015
  2. Samueljh1H8sLag
    Offline

    Samueljh1H8sLag Active Member

    Joined:
    Jun 20, 2015
    Posts:
    168
    Minecraft User:
    Samueljh1_
    For the villager, use this:

    PHP:
    namespace Samueljh1\Aditya\Is\Newb;

    use 
    pocketmine\plugin\PluginBase;

    use 
    pocketmine\event\Listener;
    use 
    pocketmine\event\player\PlayerMoveEvent;

    use 
    pocketmine\entity\Villager;
    use 
    pocketmine\Player;

    use 
    pocketmine\level\Position;

    use 
    pocketmine\Server;
    use 
    pocketmine\plugin\Plugin;

    class 
    Aditya_IsNewb extends PluginBase implements Listener{

         function 
    spawn($p){

              
    //the villager has been spawned and is saved as $this->villager

              
    foreach($this->getServer()->getOnlinePlayers() as $x){

                   
    $x->hidePlayer($p); //Hides the player from each user online

              
    }

              
    $this->player $p;

         }

         function 
    onMove(PlayerMoveEvent $newb){

              
    $p $newb->getPlayer();

              if(isset(
    $this->villager) && $p === $this->player){

                   
    $this->villager->teleport(new Position($p->getX(), $p->getY(), $p->getZ(), $p->getLevel()));

              }

         }

    }

    And for saving the skin, using
    PHP:
    $player->getSkinData();
    May help :)
    CraftYourBukkit likes this.
  3. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,747
    Minecraft User:
    Legoboy0215
    Is skin data a png?
  4. hoyinm14mc
    Offline

    hoyinm14mc Notable Member Plugin Developer

    Joined:
    Jun 4, 2014
    Posts:
    502
    Plugins:
    9
    Minecraft User:
    hoyinm14mc
    you want to make the Mineplex minigame? xD
    Legoboy0215 and jojoe77777 like this.
  5. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,747
    Minecraft User:
    Legoboy0215
    Off-Topic: It is called Sneaky Assassins...
    hoyinm14mc and jojoe77777 like this.
  6. WrackD
    Offline

    WrackD New Member

    Joined:
    May 10, 2015
    Posts:
    7
    Minecraft User:
    WrackD
    Yes it is Sneaky Assassins.. And Sam, what does get skin data return. And how do I save it as a png.?
  7. Samueljh1H8sLag
    Offline

    Samueljh1H8sLag Active Member

    Joined:
    Jun 20, 2015
    Posts:
    168
    Minecraft User:
    Samueljh1_
  8. Samueljh1H8sLag
    Offline

    Samueljh1H8sLag Active Member

    Joined:
    Jun 20, 2015
    Posts:
    168
    Minecraft User:
    Samueljh1_
    TigerHix likes this.
  9. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,747
    Minecraft User:
    Legoboy0215
    Hope you can do it :).
  10. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
  11. Xenturio
    Offline

    Xenturio Active Member

    Joined:
    Sep 19, 2014
    Posts:
    333
    Minecraft User:
    Xenturio
    u can look at @aliuly
    Grabbag Plugin by github... he code to steal skins... dont know if this helps u...
  12. Samueljh1H8sLag
    Offline

    Samueljh1H8sLag Active Member

    Joined:
    Jun 20, 2015
    Posts:
    168
    Minecraft User:
    Samueljh1_
    TigerHix likes this.
  13. Samueljh1H8sLag
    Offline

    Samueljh1H8sLag Active Member

    Joined:
    Jun 20, 2015
    Posts:
    168
    Minecraft User:
    Samueljh1_
  14. Samueljh1H8sLag
    Offline

    Samueljh1H8sLag Active Member

    Joined:
    Jun 20, 2015
    Posts:
    168
    Minecraft User:
    Samueljh1_
    ok now i will make it a plugin :p
    PEMapModder likes this.
  15. Samueljh1H8sLag
    Offline

    Samueljh1H8sLag Active Member

    Joined:
    Jun 20, 2015
    Posts:
    168
    Minecraft User:
    Samueljh1_
    his does not save as a png, just the raw data that can only be viewed in pocket mine, which looks like this: http://samcraft.samueljh1.net/bin.txt
    PEMapModder likes this.
  16. Samueljh1H8sLag
    Offline

    Samueljh1H8sLag Active Member

    Joined:
    Jun 20, 2015
    Posts:
    168
    Minecraft User:
    Samueljh1_
    @shoghicp i thought you added the GD library?
    Code:
    Fatal error: Call to undefined function Samueljh1\SkinTools\imagecreatetruecolor() in /Users/samuel/PluginDevs/plugins/SkinTools/src/Samueljh1/SkinTools/main.php on line 237
    
  17. Samueljh1H8sLag
    Offline

    Samueljh1H8sLag Active Member

    Joined:
    Jun 20, 2015
    Posts:
    168
    Minecraft User:
    Samueljh1_
    SKIN SAVING PLUGIN COMPLETE:: I WILL PUBLISH SOON BUT U CAN DOWNLOAD HERE:

    API to use in your plugins:

    PHP:
    use Samueljh1\SkinTools\main as SkinToolsAPI;

    $api = new SkinToolsAPI();

    //get a player object e.g.: $player

    //saves skin into plugins/SkinTools/images/name.png
    $api->saveSkinData($player);

    //temporarily sets a player's skin to someone else's (must call save first to the $nameofplayerwithskin.)
    //i recommend saving the skin onJoin. this will be added to the plugin soon.

    $api->setSkinData($playertoset$nameofplayerwithskin);

    //also if you want to use the skin on NPCs, you must use plugins/SkinTools/data/name.dat as the DATA string for the skin. EG:

    $data file_get_contents($this->getServer()->getDataPath() . "plugins/SkinTools/data/samueljh1_.dat");

    $myNPC->setSkin(zlib_decode($data));

    hope this helps :)

    Attached Files:

  18. Xenturio
    Offline

    Xenturio Active Member

    Joined:
    Sep 19, 2014
    Posts:
    333
    Minecraft User:
    Xenturio
    can u give me a short info what its does now? dont set apart yet with player skins and stuff like that
  19. Samueljh1H8sLag
    Offline

    Samueljh1H8sLag Active Member

    Joined:
    Jun 20, 2015
    Posts:
    168
    Minecraft User:
    Samueljh1_
    saves skin data and png and sets skin to other players
  20. WrackD
    Offline

    WrackD New Member

    Joined:
    May 10, 2015
    Posts:
    7
    Minecraft User:
    WrackD
    Thanxx a lot... This will help me a lot with the website and app..

Share This Page

Advertisement