mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 18:32:55 +00:00
Nuke Block->meta, split into variant and state properties, lots of cleanup
This is a major change to the way block metadata is handled within the PM core. This separates variant metadata (which really ought to be part of the ID) from state metadata, and in a couple of cases flattens separate states of blocks together. The result of this is that invalid variants can be much more easily detected, and additionally state handling is much cleaner since meta is only needed at the serialize layer instead of throughout the code.
This commit is contained in:
@ -28,19 +28,33 @@ use pocketmine\item\ItemFactory;
|
||||
use pocketmine\item\TieredTool;
|
||||
|
||||
class NetherReactor extends Solid{
|
||||
protected const STATE_INACTIVE = 0;
|
||||
protected const STATE_ACTIVE = 1;
|
||||
protected const STATE_USED = 2;
|
||||
|
||||
protected $id = Block::NETHER_REACTOR;
|
||||
|
||||
public function __construct(int $meta = 0){
|
||||
$this->setDamage($meta);
|
||||
/** @var int */
|
||||
protected $state = self::STATE_INACTIVE;
|
||||
|
||||
public function __construct(){
|
||||
|
||||
}
|
||||
|
||||
protected function writeStateToMeta() : int{
|
||||
return $this->state;
|
||||
}
|
||||
|
||||
public function readStateFromMeta(int $meta) : void{
|
||||
$this->state = $meta;
|
||||
}
|
||||
|
||||
public function getStateBitmask() : int{
|
||||
return 0b11;
|
||||
}
|
||||
|
||||
public function getName() : string{
|
||||
static $prefixes = [
|
||||
"",
|
||||
"Active ",
|
||||
"Used "
|
||||
];
|
||||
return ($prefixes[$this->meta] ?? "") . "Nether Reactor Core";
|
||||
return "Nether Reactor Core";
|
||||
}
|
||||
|
||||
public function getToolType() : int{
|
||||
|
Reference in New Issue
Block a user