Merge branch 'master' into mcpe-1.1

This commit is contained in:
Dylan K. Taylor
2017-05-04 21:15:49 +01:00
15 changed files with 201 additions and 39 deletions

View File

@ -177,11 +177,19 @@ class BinaryStream extends \stdClass{
}
public function getUUID(){
return UUID::fromBinary($this->get(16));
//This is actually two little-endian longs: UUID Most followed by UUID Least
$part1 = $this->getLInt();
$part0 = $this->getLInt();
$part3 = $this->getLInt();
$part2 = $this->getLInt();
return new UUID($part0, $part1, $part2, $part3);
}
public function putUUID(UUID $uuid){
$this->put($uuid->toBinary());
$this->putLInt($uuid->getPart(1));
$this->putLInt($uuid->getPart(0));
$this->putLInt($uuid->getPart(3));
$this->putLInt($uuid->getPart(2));
}
public function getSlot(){

View File

@ -102,4 +102,15 @@ class UUID{
public function __toString(){
return $this->toString();
}
public function getPart(int $partNumber){
if($partNumber < 0 or $partNumber > 3){
throw new \InvalidArgumentException("Invalid UUID part index $partNumber");
}
return $this->parts[$partNumber];
}
public function getParts() : array{
return $this->parts;
}
}