Player: don't dump cursor contents on mouseover interaction

this can fire while the player has the inventory window open, because it also gets sent when the player swaps their held itemstack for something new.

We already had a special-case for mouseover with entity ID 0, but since
this isn't just a zero problem, a more general fix suits better
(particularly since we might need to handle the 0 case anyway).

closes #4140
closes #4141
This commit is contained in:
Dylan K. Taylor 2021-04-02 21:34:00 +01:00
parent 609dff1aae
commit 125837324f
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -2834,15 +2834,11 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
if(!$this->spawned or !$this->isAlive()){
return true;
}
if($packet->action === InteractPacket::ACTION_MOUSEOVER and $packet->target === 0){
//TODO HACK: silence useless spam (MCPE 1.8)
//this packet is EXPECTED to only be sent when interacting with an entity, but due to some messy Mojang
//hacks, it also sends it when changing the held item now, which causes us to think the inventory was closed
//when it wasn't.
return true;
}
$this->doCloseInventory();
if($packet->action !== InteractPacket::ACTION_MOUSEOVER){
//mouseover fires when the player swaps their held itemstack in the inventory menu
$this->doCloseInventory();
}
$target = $this->level->getEntity($packet->target);
if($target === null){