mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 12:18:46 +00:00
Added BlockDataValidator::read5MinusHorizontalFacing()
This commit is contained in:
parent
b11d3b0401
commit
d44ec702b0
@ -54,7 +54,7 @@ class ItemFrame extends Flowable{
|
||||
}
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->facing = BlockDataValidator::readHorizontalFacing(5 - ($stateMeta & 0x03));
|
||||
$this->facing = BlockDataValidator::read5MinusHorizontalFacing($stateMeta);
|
||||
$this->hasMap = ($stateMeta & BlockLegacyMetadata::ITEM_FRAME_FLAG_HAS_MAP) !== 0;
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ abstract class Stair extends Transparent{
|
||||
}
|
||||
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
$this->facing = BlockDataValidator::readHorizontalFacing(5 - ($stateMeta & 0x03));
|
||||
$this->facing = BlockDataValidator::read5MinusHorizontalFacing($stateMeta);
|
||||
$this->upsideDown = ($stateMeta & BlockLegacyMetadata::STAIR_FLAG_UPSIDE_DOWN) !== 0;
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ abstract class Trapdoor extends Transparent{
|
||||
public function readStateFromData(int $id, int $stateMeta) : void{
|
||||
//TODO: in PC the values are reversed (facing - 2)
|
||||
|
||||
$this->facing = BlockDataValidator::readHorizontalFacing(5 - ($stateMeta & 0x03));
|
||||
$this->facing = BlockDataValidator::read5MinusHorizontalFacing($stateMeta);
|
||||
$this->top = ($stateMeta & BlockLegacyMetadata::TRAPDOOR_FLAG_UPPER) !== 0;
|
||||
$this->open = ($stateMeta & BlockLegacyMetadata::TRAPDOOR_FLAG_OPEN) !== 0;
|
||||
}
|
||||
|
@ -76,6 +76,16 @@ final class BlockDataValidator{
|
||||
return self::readHorizontalFacing($facing);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $value
|
||||
*
|
||||
* @return int
|
||||
* @throws InvalidBlockStateException
|
||||
*/
|
||||
public static function read5MinusHorizontalFacing(int $value) : int{
|
||||
return self::readHorizontalFacing(5 - ($value & 0x03));
|
||||
}
|
||||
|
||||
public static function readBoundedInt(string $name, int $v, int $min, int $max) : int{
|
||||
if($v < $min or $v > $max){
|
||||
throw new InvalidBlockStateException("$name should be in range $min - $max, got $v");
|
||||
|
Loading…
x
Reference in New Issue
Block a user