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

Disquising player's entity

Comments in 'Plugin Development' started by Primus, Oct 26, 2015.

  1. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    I tried to spawn zombie entity and synhronise it's motion on PlayerMoveEvent, but the entity were pushing me so that idea did'nt work. Then i tried to send Packets but when i moves it just spawnes a bunch of zombies cloning my last position, actually not a good idea due to i dont know how to handle EntityDamageEvent on Packet. So any ideas how can i disquise a player?
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    The principle of disguise is to despawn the player and spawn another entity with the same entity ID (or different? Not sure), so moving the entity is only sent to other users.
  3. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Despawning Player's entity will prevent pushing each other (Zombie entity and Owner entity) ?
  4. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    They still can collide :(
    PHP:
    $p->despawnFromAll();
    $p->getLevel()->removeEntity($p);
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    No...
    You send a packet to despawn the player from ANOTHER player. Then you send a packet to show a mob at that player's position to ANOTHER player. Then server sends packets about entity movement instead of player movement for the disguising player to ANOTHER player.
  6. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    RemoveEntityPacket right? And the $eid will be Player::getId()?
  7. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    AddEntityPacket will spawn alot of Zombie 'entities'.
  8. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    and if you despawn zombie from player and despawn player from all so it doesn't work?
  9. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Hint: construct a packet and send it to all instead of constructing multiple times.
  10. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Hint: construct a packet and send it to all instead of constructing multiple times.
  11. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    PHP:
    public function spawnNormalZombie(IPlayer $p)
    {
    if(
    $this->plugin->isInfected($p)) return; # Is player already infected?

    $packet $this->plugin->zombies[$p->getName()] = new AddEntityPacket(); // Save zombie packet
    $packet $this->zPacket;
    $packet->eid 32;
    $packet->type 1;
    $packet->$p->getX();
    $packet->$p->getY();
    $packet->$p->getZ();
    $packet->yaw $p->yaw;
    $packet->pitch $p->pitch;
    return 
    false;
    }
    And ZombieTimer.php (interval 1 tick)
    PHP:
    class ZombieTimer extends PluginTask{

    private 
    $zPacket$remPlayerPacket;

    public function 
    __construct($plugin){
    $this->plugin $plugin;
    parent::__construct($plugin);
    }

    public function 
    onRun($tick){
    foreach(
    $this->plugin->getServer()->getOnlinePlayers() as $p){
    if(
    $this->plugin->isInfected($p)){
    $zombie $this->plugin->zombies[$p->getName()];
    if(
    $zombie instanceof Entity){
    $remPlayerPacket $this->remPlayerPacket;
    $remPlayerPacket->eid $p->getId();
    $zPacket $this->plugin->getZombie($p); // Returns AddEntityPacket
    $zPacket->eid 32;
    $zPacket->type 1;
    $zPacket->$p->getX();
    $zPacket->$p->getY();
    $zPacket->$p->getZ();
    $zPacket->yaw $p->yaw;
    $zPacket->pitch $p->pitch;
    foreach(
    $this->plugin->getServer()->getOnlinePlayers() as $player){
    if(
    $p !== $player){ # Send it to all other players except current
    $player->dataPacket($remPlayerPacket);
    $player->dataPacket($zPacket);
    echo 
    '.';
    }
    }
    }
    }
    }
    }
    }

  12. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    maybe better is
    PHP:
    $server->broadcastPacket($pk$players);
  13. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    I guess it will do the exact same thing.
  14. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
  15. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Hmm, using AddEntityPacket every tick is like restarting zombie model, all movements are so jerky, and that zombie cant even turn around, is it even possible to make smooth disquise? Like DisquiseMe plugin did?
  16. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Good news! Disquised player successfully, but how can i color the zombie model red when it gets hurt.
  17. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Thats got solved too, but now how can i remove that packet?
  18. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Why did you send AddEntityPacket every tick :facepalm: "remove the player and add the entity" = "replace player with entity", and then simply change the packets that move player into packets that move the entity.
  19. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    I got it solved :)
    I just needet to set
    $pk->eid = $player->getId()
  20. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    MoveEntityPacket and MovePlayerPacket have different packet IDs...

Share This Page

Advertisement