Humans can now do emotes (#4610)

added the following API methods:
- Human::emote()
This commit is contained in:
IvanCraft623 2022-03-03 13:19:30 -05:00 committed by GitHub
parent ba05b4f024
commit 90a369f0b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 4 deletions

View File

@ -161,6 +161,12 @@ class Human extends Living implements ProjectileSource, InventoryHolder{
}
}
public function emote(string $emoteId) : void{
foreach($this->getViewers() as $player){
$player->getNetworkSession()->onEmote($this, $emoteId);
}
}
public function getHungerManager() : HungerManager{
return $this->hungerManager;
}

View File

@ -1046,7 +1046,7 @@ class NetworkSession{
$this->sendDataPacket(SetTitlePacket::setAnimationTimes($fadeIn, $stay, $fadeOut));
}
public function onEmote(Player $from, string $emoteId) : void{
public function onEmote(Human $from, string $emoteId) : void{
$this->sendDataPacket(EmotePacket::create($from->getId(), $emoteId, EmotePacket::FLAG_SERVER));
}

View File

@ -1841,9 +1841,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
$event->call();
if(!$event->isCancelled()){
$emoteId = $event->getEmoteId();
foreach($this->getViewers() as $player){
$player->getNetworkSession()->onEmote($this, $emoteId);
}
parent::emote($emoteId);
}
}
}