move forced overflow of SetTimePacket to SetTimePacket::create()

This commit is contained in:
Dylan K. Taylor 2019-08-20 16:24:47 +01:00
parent 794c7b2469
commit 3a41a798ad
2 changed files with 2 additions and 2 deletions

View File

@ -35,7 +35,7 @@ class SetTimePacket extends DataPacket implements ClientboundPacket{
public static function create(int $time) : self{ public static function create(int $time) : self{
$result = new self; $result = new self;
$result->time = $time; $result->time = $time & 0xffffffff; //avoid overflowing the field, since the packet uses an int32
return $result; return $result;
} }

View File

@ -691,7 +691,7 @@ class World implements ChunkManager{
* @param Player ...$targets If empty, will send to all players in the world. * @param Player ...$targets If empty, will send to all players in the world.
*/ */
public function sendTime(Player ...$targets){ public function sendTime(Player ...$targets){
$pk = SetTimePacket::create($this->time & 0xffffffff); //avoid overflowing the field, since the packet uses an int32 $pk = SetTimePacket::create($this->time);
if(empty($targets)){ if(empty($targets)){
$this->broadcastGlobalPacket($pk); $this->broadcastGlobalPacket($pk);