Block: fixed use of full meta as variant in several cases

fixes #2940

now I need to go to the bathroom and wash this off my hands ... I'd forgotten how nasty this code is
This commit is contained in:
Dylan K. Taylor 2019-05-27 18:04:12 +01:00
parent 14bae72dd5
commit c38779f1fd
14 changed files with 16 additions and 16 deletions

View File

@ -46,7 +46,7 @@ class Carpet extends Flowable{
}
public function getName() : string{
return ColorBlockMetaHelper::getColorFromMeta($this->meta) . " Carpet";
return ColorBlockMetaHelper::getColorFromMeta($this->getVariant()) . " Carpet";
}
protected function recalculateBoundingBox() : ?AxisAlignedBB{

View File

@ -35,7 +35,7 @@ class Concrete extends Solid{
}
public function getName() : string{
return ColorBlockMetaHelper::getColorFromMeta($this->meta) . " Concrete";
return ColorBlockMetaHelper::getColorFromMeta($this->getVariant()) . " Concrete";
}
public function getHardness() : float{

View File

@ -34,7 +34,7 @@ class ConcretePowder extends Fallable{
}
public function getName() : string{
return ColorBlockMetaHelper::getColorFromMeta($this->meta) . " Concrete Powder";
return ColorBlockMetaHelper::getColorFromMeta($this->getVariant()) . " Concrete Powder";
}
public function getHardness() : float{

View File

@ -39,7 +39,7 @@ class DoublePlant extends Flowable{
}
public function canBeReplaced() : bool{
return $this->meta === 2 or $this->meta === 3; //grass or fern
return $this->getVariant() === 2 or $this->getVariant() === 3; //grass or fern
}
public function getName() : string{
@ -95,11 +95,11 @@ class DoublePlant extends Flowable{
}
public function getToolType() : int{
return ($this->meta === 2 or $this->meta === 3) ? BlockToolType::TYPE_SHEARS : BlockToolType::TYPE_NONE;
return ($this->getVariant() === 2 or $this->getVariant() === 3) ? BlockToolType::TYPE_SHEARS : BlockToolType::TYPE_NONE;
}
public function getToolHarvestLevel() : int{
return ($this->meta === 2 or $this->meta === 3) ? 1 : 0; //only grass or fern require shears
return ($this->getVariant() === 2 or $this->getVariant() === 3) ? 1 : 0; //only grass or fern require shears
}
public function getDrops(Item $item) : array{

View File

@ -56,7 +56,7 @@ class Flower extends Flowable{
self::TYPE_PINK_TULIP => "Pink Tulip",
self::TYPE_OXEYE_DAISY => "Oxeye Daisy"
];
return $names[$this->meta] ?? "Unknown";
return $names[$this->getVariant()] ?? "Unknown";
}
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{

View File

@ -188,7 +188,7 @@ class Leaves extends Transparent{
}
public function canDropApples() : bool{
return $this->meta === self::OAK;
return $this->getVariant() === self::OAK;
}
public function getFlameEncouragement() : int{

View File

@ -44,6 +44,6 @@ class Leaves2 extends Leaves{
}
public function canDropApples() : bool{
return $this->meta === self::DARK_OAK;
return $this->getVariant() === self::DARK_OAK;
}
}

View File

@ -55,7 +55,7 @@ class Quartz extends Solid{
}
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
if($this->meta !== self::NORMAL){
if($this->getVariant() !== self::NORMAL){
$this->meta = PillarRotationHelper::getMetaFromFace($this->meta, $face);
}
return $this->getLevel()->setBlock($blockReplace, $this, true, true);

View File

@ -40,7 +40,7 @@ class Sand extends Fallable{
}
public function getName() : string{
if($this->meta === 0x01){
if($this->getVariant() === 0x01){
return "Red Sand";
}

View File

@ -78,7 +78,7 @@ abstract class Slab extends Transparent{
}
}else{ //TODO: collision
if($blockReplace->getId() === $this->id){
if($blockReplace->getVariant() === $this->meta){
if($blockReplace->getVariant() === $this->getVariant()){
$this->getLevel()->setBlock($blockReplace, BlockFactory::get($this->getDoubleSlabId(), $this->getVariant()), true);
return true;

View File

@ -30,6 +30,6 @@ class StainedClay extends HardenedClay{
protected $id = self::STAINED_CLAY;
public function getName() : string{
return ColorBlockMetaHelper::getColorFromMeta($this->meta) . " Stained Clay";
return ColorBlockMetaHelper::getColorFromMeta($this->getVariant()) . " Stained Clay";
}
}

View File

@ -30,6 +30,6 @@ class StainedGlass extends Glass{
protected $id = self::STAINED_GLASS;
public function getName() : string{
return ColorBlockMetaHelper::getColorFromMeta($this->meta) . " Stained Glass";
return ColorBlockMetaHelper::getColorFromMeta($this->getVariant()) . " Stained Glass";
}
}

View File

@ -30,6 +30,6 @@ class StainedGlassPane extends GlassPane{
protected $id = self::STAINED_GLASS_PANE;
public function getName() : string{
return ColorBlockMetaHelper::getColorFromMeta($this->meta) . " Stained Glass Pane";
return ColorBlockMetaHelper::getColorFromMeta($this->getVariant()) . " Stained Glass Pane";
}
}

View File

@ -43,7 +43,7 @@ class Wool extends Solid{
}
public function getName() : string{
return ColorBlockMetaHelper::getColorFromMeta($this->meta) . " Wool";
return ColorBlockMetaHelper::getColorFromMeta($this->getVariant()) . " Wool";
}
public function getBreakTime(Item $item) : float{