Fully fixed metadata sending

This commit is contained in:
Shoghi Cervantes 2014-06-14 21:44:02 +02:00
parent f3e6c726b0
commit 4354d76cae
2 changed files with 19 additions and 7 deletions

View File

@ -149,7 +149,7 @@ class ChunkSection implements \pocketmine\level\format\ChunkSection{
$i = ($z << 3) + ($x >> 1);
$column = "";
for($y = 0; $y < 16; $y += 2){
$column .= ($this->data{($y << 7) + $i} & "\x0f") | ($this->data{(($y + 1) << 7) + $i} & "\xf0");
$column .= chr((ord($this->data{($y << 7) + $i}) & 0x0f) | ((ord($this->data{(($y + 1) << 7) + $i}) & 0x0f) << 4));
}
return $column;
@ -159,7 +159,7 @@ class ChunkSection implements \pocketmine\level\format\ChunkSection{
$i = ($z << 3) + ($x >> 1);
$column = "";
for($y = 0; $y < 16; $y += 2){
$column .= ($this->skyLight{($y << 7) + $i} & "\x0f") | ($this->skyLight{(($y + 1) << 7) + $i} & "\xf0");
$column .= chr((ord($this->skyLight{($y << 7) + $i}) & 0x0f) | ((ord($this->skyLight{(($y + 1) << 7) + $i}) & 0x0f) << 4));
}
return $column;
@ -169,7 +169,7 @@ class ChunkSection implements \pocketmine\level\format\ChunkSection{
$i = ($z << 3) + ($x >> 1);
$column = "";
for($y = 0; $y < 16; $y += 2){
$column .= ($this->blockLight{($y << 7) + $i} & "\x0f") | ($this->blockLight{(($y + 1) << 7) + $i} & "\xf0");
$column .= chr((ord($this->blockLight{($y << 7) + $i}) & 0x0f) | ((ord($this->blockLight{(($y + 1) << 7) + $i}) & 0x0f) << 4));
}
return $column;

View File

@ -41,7 +41,10 @@ class BlockMetadataStore extends MetadataStore{
return $block->x . ":" . $block->y . ":" . $block->z . ":" . $metadataKey;
}
public function getMetadata(Block $block, $metadataKey){
public function getMetadata($block, $metadataKey){
if($block instanceof Block){
throw new \Exception("Object must be a Block");
}
if($block->getLevel() === $this->owningLevel){
return parent::getMetadata($block, $metadataKey);
}else{
@ -49,7 +52,10 @@ class BlockMetadataStore extends MetadataStore{
}
}
public function hasMetadata(Block $block, $metadataKey){
public function hasMetadata($block, $metadataKey){
if($block instanceof Block){
throw new \Exception("Object must be a Block");
}
if($block->getLevel() === $this->owningLevel){
return parent::hasMetadata($block, $metadataKey);
}else{
@ -57,7 +63,10 @@ class BlockMetadataStore extends MetadataStore{
}
}
public function removeMetadata(Block $block, $metadataKey, Plugin $owningPlugin){
public function removeMetadata($block, $metadataKey, Plugin $owningPlugin){
if($block instanceof Block){
throw new \Exception("Object must be a Block");
}
if($block->getLevel() === $this->owningLevel){
parent::hasMetadata($block, $metadataKey, $owningPlugin);
}else{
@ -65,7 +74,10 @@ class BlockMetadataStore extends MetadataStore{
}
}
public function setMetadata(Block $block, $metadataKey, MetadataValue $newMetadatavalue){
public function setMetadata($block, $metadataKey, MetadataValue $newMetadatavalue){
if($block instanceof Block){
throw new \Exception("Object must be a Block");
}
if($block->getLevel() === $this->owningLevel){
parent::setMetadata($block, $metadataKey, $newMetadatavalue);
}else{