mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
prevent useitem if heldItem on client doesnt match server
This commit is contained in:
parent
16324d32f2
commit
38ee5daed2
2 changed files with 18 additions and 3 deletions
|
|
@ -686,6 +686,7 @@ class Player{
|
|||
$pk->hotbar = $hotbar;
|
||||
$this->dataPacket($pk);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $type
|
||||
* @param $damage
|
||||
|
|
@ -1948,6 +1949,20 @@ class Player{
|
|||
$data["posY"] = $packet->posY;
|
||||
$data["posZ"] = $packet->posZ;
|
||||
|
||||
//nc: check item desync
|
||||
$heldItem = $this->getHeldItem();
|
||||
if($heldItem->getID() != $packet->item || $heldItem->getMetadata() != $packet->meta){
|
||||
ConsoleAPI::warn("{$this->username}'s heldItem doesnt match on clientside and serverside when using item. Resending inventory.");
|
||||
$this->sendInventory();
|
||||
if($packet->face >= 0 && $packet->face <= 5){
|
||||
$target = $this->level->getBlock($blockVector);
|
||||
$block = $target->getSide($packet->face);
|
||||
$this->addBlockUpdateIntoQueue($target->x, $target->y, $target->z, $target->getID(), $target->getMetadata());
|
||||
$this->addBlockUpdateIntoQueue($block->x, $block->y, $block->z, $block->getID(), $block->getMetadata());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if($packet->face >= 0 and $packet->face <= 5){ //Use Block, place
|
||||
if($this->entity->inAction === true){
|
||||
$this->entity->inAction = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue