Added some missing block properties

This commit is contained in:
Dylan K. Taylor 2019-03-09 16:49:37 +00:00
parent 8f1bc5d497
commit 6fe366e1ac
2 changed files with 42 additions and 0 deletions

View File

@ -27,6 +27,21 @@ use pocketmine\item\Item;
class Bedrock extends Solid{
/** @var bool */
private $burnsForever = false;
public function readStateFromData(int $id, int $stateMeta) : void{
$this->burnsForever = $stateMeta !== 0;
}
protected function writeStateToMeta() : int{
return $this->burnsForever ? 1 : 0;
}
public function getStateBitmask() : int{
return 0b1;
}
public function getHardness() : float{
return -1;
}
@ -38,4 +53,8 @@ class Bedrock extends Solid{
public function isBreakable(Item $item) : bool{
return false;
}
public function burnsForever() : bool{
return $this->burnsForever;
}
}

View File

@ -40,10 +40,33 @@ use const M_PI;
class TNT extends Solid{
/** @var bool */
protected $unstable = false; //TODO: Usage unclear, seems to be a weird hack in vanilla
public function readStateFromData(int $id, int $stateMeta) : void{
$this->unstable = $stateMeta !== 0;
}
protected function writeStateToMeta() : int{
return $this->unstable ? 1 : 0;
}
public function getStateBitmask() : int{
return 0b1;
}
public function getHardness() : float{
return 0;
}
public function onBreak(Item $item, ?Player $player = null) : bool{
if($this->unstable){
$this->ignite();
return true;
}
return parent::onBreak($item, $player);
}
public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
if($item instanceof FlintSteel or $item->hasEnchantment(Enchantment::FIRE_ASPECT())){
if($item instanceof Durable){