Player: Fixed so-called 'pot lag'

this occurred because of transactions arriving before MobEquipmentPacket updating the player's own held item slot. This was only a problem while rapidly changing hotbar slots and simultaneously using items, like projectiles.
closes #4168
This commit is contained in:
Dylan K. Taylor 2021-06-26 18:56:11 +01:00
parent 8b1a84f2bf
commit 0cdc04f9b5
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -2529,6 +2529,10 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
$blockVector = $packet->trData->getBlockPos();
$face = $packet->trData->getFace();
if($this->inventory->getHeldItemIndex() !== $packet->trData->getHotbarSlot()){
$this->inventory->equipItem($packet->trData->getHotbarSlot());
}
switch($packet->trData->getActionType()){
case UseItemTransactionData::ACTION_CLICK_BLOCK:
//TODO: start hack for client spam bug
@ -2687,6 +2691,10 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
return false;
}
if($this->inventory->getHeldItemIndex() !== $packet->trData->getHotbarSlot()){
$this->inventory->equipItem($packet->trData->getHotbarSlot());
}
switch($packet->trData->getActionType()){
case UseItemOnEntityTransactionData::ACTION_INTERACT:
break; //TODO
@ -2778,6 +2786,10 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
$this->inventory->sendContents($this);
return false;
}elseif($packet->trData instanceof ReleaseItemTransactionData){
if($this->inventory->getHeldItemIndex() !== $packet->trData->getHotbarSlot()){
$this->inventory->equipItem($packet->trData->getHotbarSlot());
}
try{
switch($packet->trData->getActionType()){
case ReleaseItemTransactionData::ACTION_RELEASE: