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?
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.
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.
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->x = $p->getX();$packet->y = $p->getY();$packet->z = $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->x = $p->getX();$zPacket->y = $p->getY();$zPacket->z = $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 '.';}}}}}}}
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?
Good news! Disquised player successfully, but how can i color the zombie model red when it gets hurt.
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.