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. Samueljh1H8sLag
    Offline

    Samueljh1H8sLag Active Member

    Joined:
    Jun 20, 2015
    Posts:
    168
    Minecraft User:
    Samueljh1_
    No prob ;)
  2. TigerHix
    Offline

    TigerHix Active Member

    Joined:
    May 11, 2015
    Posts:
    61
    Minecraft User:
    TigerHix
    Taha_The_Hacker likes this.
  3. Asidert
    Offline

    Asidert Active Member Plugin Developer

    Joined:
    Oct 21, 2014
    Posts:
    123
    Plugins:
    1
    Minecraft User:
    Asidert
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Samueljh1H8sLag likes this.
  5. TigerHix
    Offline

    TigerHix Active Member

    Joined:
    May 11, 2015
    Posts:
    61
    Minecraft User:
    TigerHix
    I am referring to the implementation, not telling you to use that plugin :eek:

    Considering the packets used (RemovePlayerPacket, AddMobPacket, EntitySetMotionPacket) are so commonly used and haven't changed since 0.9.0 (please correct me if I am mistaken :p), there is a small possibility of the class properties changing every update. It still depends on your personal preferences, after all it did took some cost to use packets, but you gain better performance than handling PlayerMoveEvent.
    PEMapModder likes this.
  6. Samueljh1H8sLag
    Offline

    Samueljh1H8sLag Active Member

    Joined:
    Jun 20, 2015
    Posts:
    168
    Minecraft User:
    Samueljh1_
    well how much better is using packets? a big performance improvement or a bit? if it is faster, i would prefer using packets to make my server perform better as a lot of events are being checked.
  7. TigerHix
    Offline

    TigerHix Active Member

    Joined:
    May 11, 2015
    Posts:
    61
    Minecraft User:
    TigerHix
    At least 2x faster? As the server will have to handle twice amount of entities assuming all players are disguised, if using the method of spawning an "real" entity for every disguise. But if using the packet way, the server is not going to spawn anything; it just have to change some values of the packets.

    Simply explained, the original packet is: "Player shoghicp moved with a vector of (2, 3.5, 1.0009)". This packet is originally sent to every player except shoghi, to broadcast his movement to other player clients. Now we intercept that packet, and change the content to "An entity villager moved with a vector of (2, 3.5, 1.0009)". And then the MCPE that received the packet would think the villager really exist, and render it in the game world.

    Besides the improvement in performance, since the spawn & teleport method requires a teleportation for every player movement, and all teleportations are only truly executed on next tick, I am sure the outcome would not be as smooth as the packet method. Of course, the former one is easier to implement and independent to version changes, but if you are looking for performance, give the packets a shot.
  8. Samueljh1H8sLag
    Offline

    Samueljh1H8sLag Active Member

    Joined:
    Jun 20, 2015
    Posts:
    168
    Minecraft User:
    Samueljh1_
    great explanation :D
    TigerHix likes this.
  9. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    Just downloaded it, tried it, works. (By the way, there is already a plugin with that name)
    But one bug: Transparent parts are not transparent but black, and the jacket is not there
  10. aliuly
    Offline

    aliuly Notable Member Plugin Developer

    Joined:
    Feb 8, 2014
    Posts:
    1,086
    Plugins:
    17
    He wrote this before that other plugin...
    Samueljh1H8sLag likes this.
  11. Samueljh1H8sLag
    Offline

    Samueljh1H8sLag Active Member

    Joined:
    Jun 20, 2015
    Posts:
    168
    Minecraft User:
    Samueljh1_
    That's an issue with the pocketmine api. Also most image viewers show black for transparency
  12. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    Would be nice. Skin saving as png is most important for me.

    For this plugin, you cant do $api->saveSkinData($player), its $api->saveSkinData($player, $player), then it gives me a folder not found exception.
    Its not the image viewer (Photoshop does also show transparency as black!)
    It really is black. But i made a web application which shows the head, if you want to it shows it also with hat. But its weird if the hat is not transparent but black.
    Legoboy0215 likes this.
  13. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Be careful of copyright infringement.
  14. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Thanks for the advice. :p
  15. Timmpann
    Offline

    Timmpann New Member

    Joined:
    Feb 5, 2015
    Posts:
    24
    Minecraft User:
    Timmpann
    I'm borrowing this thread because i need help with changing a player into a mob/entity. If the username is "Chicken" i want that player to be disguised as a chicken.

    I have managed to disguise all players as chickens by modifying code from DisguiseMe. But when I try to make it that only "Chicken" is being disguised I don't get it right. The current code makes the player "Chicken" see everyone else as chickens.

    PHP:
            public function onPacketSend(DataPacketSendEvent $event){
                if(
    $event->getPlayer()->getDisplayName() === "Chicken"){
                      if(
    $event->getPacket() instanceof AddPlayerPacket){
                              
    $pk = new AddEntityPacket;
                              
    $pk->eid $event->getPacket()->eid;
                              
    $pk->type 10;
                              
    $pk->$event->getPacket()->x;
                              
    $pk->$event->getPacket()->y;
                              
    $pk->$event->getPacket()->z;
                              
    $pk->pitch $event->getPacket()->pitch;
                              
    $pk->yaw $event->getPacket()->yaw;
                              
    $pk->metadata = [];
                              
    $event->getPlayer()->dataPacket($pk);
                              
    $event->setCancelled();
                      }
                      if(
    $event->getPacket() instanceof MovePlayerPacket){
                              
    $pk = new MoveEntityPacket;
                              
    $pk->entities = [[$event->getPacket()->eid$event->getPacket()->x$event->getPacket()->y$event->getPacket()->z$event->getPacket()->yaw$event->getPacket()->pitch]];
                              
    $event->getPlayer()->dataPacket($pk);
                              
    $event->setCancelled();
                      }
                      if(
    $event->getPacket() instanceof RemovePlayerPacket){
                              
    $pk = new RemoveEntityPacket;
                              
    $pk->eid $event->getPacket()->eid;
                              
    $event->getPlayer()->dataPacket($pk);
                              
    $event->setCancelled();
                      }
                 }
            }
  16. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    Currently you check if your name is "Chicken". ($event->getPlayer()->getDisplayName() === "Chicken")
    But you have to change the entities..
    I guess you somehow have to change $pk->entities..
    Maybe a foreach loop?
    $entities=array();
    foreach($pk->entities as $entity){
    if($entity->getName()==="Chicken")
    array_push($entities, $entity);
    }

    And then $entities = [[$event->getPacket()->eid, $event->getPacket()->x, $event->getPacket()->y, $event->getPacket()->z, $event->getPacket()->yaw, $event->getPacket()->pitch]];
  17. Timmpann
    Offline

    Timmpann New Member

    Joined:
    Feb 5, 2015
    Posts:
    24
    Minecraft User:
    Timmpann
    That didn't fix it. I have tried things for hours now without the result i want. I'm about to give up.

    Is there anyone who can fix it and post the code? I give a lot of internethugs in return! <3
  18. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    $event->getPlayer() returns the player who RECEIVES the packet, who is actually the viewer, not the one who you want to disguise.
    thebigsmileXD and jojoe77777 like this.
  19. Timmpann
    Offline

    Timmpann New Member

    Joined:
    Feb 5, 2015
    Posts:
    24
    Minecraft User:
    Timmpann
    How can i get the player who the packet is sent from?
  20. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    The packet is sent from the server, not from a player.
    I suppose searching player by entity ID works.
    Timmpann likes this.

Share This Page

Advertisement