mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-04 00:59:51 +00:00
Enforced max distance checks
This commit is contained in:
parent
6b1b6711bd
commit
87a779afaf
@ -1685,12 +1685,16 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->inventory->sendHeldItem($this);
|
||||||
|
|
||||||
|
if($blockVector->distanceSquared($this) > 10000){
|
||||||
|
break;
|
||||||
|
}
|
||||||
$target = $this->level->getBlock($blockVector);
|
$target = $this->level->getBlock($blockVector);
|
||||||
$block = $target->getSide($packet->face);
|
$block = $target->getSide($packet->face);
|
||||||
|
|
||||||
$this->level->sendBlocks([$this], [$target, $block], UpdateBlockPacket::FLAG_ALL_PRIORITY);
|
$this->level->sendBlocks([$this], [$target, $block], UpdateBlockPacket::FLAG_ALL_PRIORITY);
|
||||||
|
|
||||||
$this->inventory->sendHeldItem($this);
|
|
||||||
break;
|
break;
|
||||||
}elseif($packet->face === 0xff){
|
}elseif($packet->face === 0xff){
|
||||||
$aimPos = (new Vector3($packet->x / 32768, $packet->y / 32768, $packet->z / 32768))->normalize();
|
$aimPos = (new Vector3($packet->x / 32768, $packet->y / 32768, $packet->z / 32768))->normalize();
|
||||||
@ -1762,10 +1766,14 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
|
|
||||||
$this->craftingType = 0;
|
$this->craftingType = 0;
|
||||||
$packet->eid = $this->id;
|
$packet->eid = $this->id;
|
||||||
|
$pos = new Vector3($packet->x, $packet->y, $packet->z);
|
||||||
|
|
||||||
switch($packet->action){
|
switch($packet->action){
|
||||||
case 0: //Start break
|
case 0: //Start break
|
||||||
$target = $this->level->getBlock(new Vector3($packet->x, $packet->y, $packet->z));
|
if($pos->distanceSquared($this) > 10000){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$target = $this->level->getBlock($pos);
|
||||||
$ev = new PlayerInteractEvent($this, $this->inventory->getItemInHand(), $target, $packet->face, $target->getId() === 0 ? PlayerInteractEvent::LEFT_CLICK_AIR : PlayerInteractEvent::LEFT_CLICK_BLOCK);
|
$ev = new PlayerInteractEvent($this, $this->inventory->getItemInHand(), $target, $packet->face, $target->getId() === 0 ? PlayerInteractEvent::LEFT_CLICK_AIR : PlayerInteractEvent::LEFT_CLICK_BLOCK);
|
||||||
$this->getServer()->getPluginManager()->callEvent($ev);
|
$this->getServer()->getPluginManager()->callEvent($ev);
|
||||||
if($ev->isCancelled()){
|
if($ev->isCancelled()){
|
||||||
@ -2361,7 +2369,12 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
}
|
}
|
||||||
$this->craftingType = 0;
|
$this->craftingType = 0;
|
||||||
|
|
||||||
$t = $this->level->getTile(new Vector3($packet->x, $packet->y, $packet->z));
|
$pos = new Vector3($packet->x, $packet->y, $packet->z);
|
||||||
|
if($pos->distanceSquared($this) > 10000){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$t = $this->level->getTile($pos);
|
||||||
if($t instanceof Sign){
|
if($t instanceof Sign){
|
||||||
$nbt = new NBT(NBT::LITTLE_ENDIAN);
|
$nbt = new NBT(NBT::LITTLE_ENDIAN);
|
||||||
$nbt->read($packet->namedtag);
|
$nbt->read($packet->namedtag);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user