Use Block->getVariant() more, get rid of hardcoded bitmasks

This commit is contained in:
Dylan K. Taylor
2017-10-18 17:46:24 +01:00
parent 91d84aaff4
commit f148c366f9
17 changed files with 36 additions and 38 deletions

View File

@ -54,7 +54,7 @@ class Sapling extends Flowable{
4 => "Acacia Sapling",
5 => "Dark Oak Sapling"
];
return $names[$this->meta & 0x07] ?? "Unknown";
return $names[$this->getVariant()] ?? "Unknown";
}
public function ticksRandomly() : bool{
@ -75,7 +75,7 @@ class Sapling extends Flowable{
public function onActivate(Item $item, Player $player = null) : bool{
if($item->getId() === Item::DYE and $item->getDamage() === 0x0F){ //Bonemeal
//TODO: change log type
Tree::growTree($this->getLevel(), $this->x, $this->y, $this->z, new Random(mt_rand()), $this->meta & 0x07);
Tree::growTree($this->getLevel(), $this->x, $this->y, $this->z, new Random(mt_rand()), $this->getVariant());
$item->count--;
@ -95,7 +95,7 @@ class Sapling extends Flowable{
}elseif($type === Level::BLOCK_UPDATE_RANDOM){ //Growth
if(mt_rand(1, 7) === 1){
if(($this->meta & 0x08) === 0x08){
Tree::growTree($this->getLevel(), $this->x, $this->y, $this->z, new Random(mt_rand()), $this->meta & 0x07);
Tree::growTree($this->getLevel(), $this->x, $this->y, $this->z, new Random(mt_rand()), $this->getVariant());
}else{
$this->meta |= 0x08;
$this->getLevel()->setBlock($this, $this, true);
@ -110,10 +110,8 @@ class Sapling extends Flowable{
return false;
}
public function getDrops(Item $item) : array{
return [
ItemFactory::get($this->getItemId(), $this->getDamage() & 0x07, 1)
];
public function getVariantBitmask() : int{
return 0x07;
}
public function getFuelTime() : int{