mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-12 06:25:32 +00:00
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:
parent
8b1a84f2bf
commit
0cdc04f9b5
@ -2529,6 +2529,10 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
|||||||
$blockVector = $packet->trData->getBlockPos();
|
$blockVector = $packet->trData->getBlockPos();
|
||||||
$face = $packet->trData->getFace();
|
$face = $packet->trData->getFace();
|
||||||
|
|
||||||
|
if($this->inventory->getHeldItemIndex() !== $packet->trData->getHotbarSlot()){
|
||||||
|
$this->inventory->equipItem($packet->trData->getHotbarSlot());
|
||||||
|
}
|
||||||
|
|
||||||
switch($packet->trData->getActionType()){
|
switch($packet->trData->getActionType()){
|
||||||
case UseItemTransactionData::ACTION_CLICK_BLOCK:
|
case UseItemTransactionData::ACTION_CLICK_BLOCK:
|
||||||
//TODO: start hack for client spam bug
|
//TODO: start hack for client spam bug
|
||||||
@ -2687,6 +2691,10 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($this->inventory->getHeldItemIndex() !== $packet->trData->getHotbarSlot()){
|
||||||
|
$this->inventory->equipItem($packet->trData->getHotbarSlot());
|
||||||
|
}
|
||||||
|
|
||||||
switch($packet->trData->getActionType()){
|
switch($packet->trData->getActionType()){
|
||||||
case UseItemOnEntityTransactionData::ACTION_INTERACT:
|
case UseItemOnEntityTransactionData::ACTION_INTERACT:
|
||||||
break; //TODO
|
break; //TODO
|
||||||
@ -2778,6 +2786,10 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
|||||||
$this->inventory->sendContents($this);
|
$this->inventory->sendContents($this);
|
||||||
return false;
|
return false;
|
||||||
}elseif($packet->trData instanceof ReleaseItemTransactionData){
|
}elseif($packet->trData instanceof ReleaseItemTransactionData){
|
||||||
|
if($this->inventory->getHeldItemIndex() !== $packet->trData->getHotbarSlot()){
|
||||||
|
$this->inventory->equipItem($packet->trData->getHotbarSlot());
|
||||||
|
}
|
||||||
|
|
||||||
try{
|
try{
|
||||||
switch($packet->trData->getActionType()){
|
switch($packet->trData->getActionType()){
|
||||||
case ReleaseItemTransactionData::ACTION_RELEASE:
|
case ReleaseItemTransactionData::ACTION_RELEASE:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user