From c38779f1fdfca4e191231689263609ea659ebd8e Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 27 May 2019 18:04:12 +0100 Subject: [PATCH] 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 --- src/pocketmine/block/Carpet.php | 2 +- src/pocketmine/block/Concrete.php | 2 +- src/pocketmine/block/ConcretePowder.php | 2 +- src/pocketmine/block/DoublePlant.php | 6 +++--- src/pocketmine/block/Flower.php | 2 +- src/pocketmine/block/Leaves.php | 2 +- src/pocketmine/block/Leaves2.php | 2 +- src/pocketmine/block/Quartz.php | 2 +- src/pocketmine/block/Sand.php | 2 +- src/pocketmine/block/Slab.php | 2 +- src/pocketmine/block/StainedClay.php | 2 +- src/pocketmine/block/StainedGlass.php | 2 +- src/pocketmine/block/StainedGlassPane.php | 2 +- src/pocketmine/block/Wool.php | 2 +- 14 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/pocketmine/block/Carpet.php b/src/pocketmine/block/Carpet.php index 3631248f3..225f9db09 100644 --- a/src/pocketmine/block/Carpet.php +++ b/src/pocketmine/block/Carpet.php @@ -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{ diff --git a/src/pocketmine/block/Concrete.php b/src/pocketmine/block/Concrete.php index 9148d9f50..e00f0d68a 100644 --- a/src/pocketmine/block/Concrete.php +++ b/src/pocketmine/block/Concrete.php @@ -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{ diff --git a/src/pocketmine/block/ConcretePowder.php b/src/pocketmine/block/ConcretePowder.php index 2ce84145d..6035af840 100644 --- a/src/pocketmine/block/ConcretePowder.php +++ b/src/pocketmine/block/ConcretePowder.php @@ -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{ diff --git a/src/pocketmine/block/DoublePlant.php b/src/pocketmine/block/DoublePlant.php index 9b15f7219..4da0815a8 100644 --- a/src/pocketmine/block/DoublePlant.php +++ b/src/pocketmine/block/DoublePlant.php @@ -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{ diff --git a/src/pocketmine/block/Flower.php b/src/pocketmine/block/Flower.php index 2946b3cbe..4bb3ee7ce 100644 --- a/src/pocketmine/block/Flower.php +++ b/src/pocketmine/block/Flower.php @@ -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{ diff --git a/src/pocketmine/block/Leaves.php b/src/pocketmine/block/Leaves.php index bc3a055e4..55985964e 100644 --- a/src/pocketmine/block/Leaves.php +++ b/src/pocketmine/block/Leaves.php @@ -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{ diff --git a/src/pocketmine/block/Leaves2.php b/src/pocketmine/block/Leaves2.php index bd18ec7c2..bb62ac2de 100644 --- a/src/pocketmine/block/Leaves2.php +++ b/src/pocketmine/block/Leaves2.php @@ -44,6 +44,6 @@ class Leaves2 extends Leaves{ } public function canDropApples() : bool{ - return $this->meta === self::DARK_OAK; + return $this->getVariant() === self::DARK_OAK; } } diff --git a/src/pocketmine/block/Quartz.php b/src/pocketmine/block/Quartz.php index e0813022c..d21c62ecf 100644 --- a/src/pocketmine/block/Quartz.php +++ b/src/pocketmine/block/Quartz.php @@ -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); diff --git a/src/pocketmine/block/Sand.php b/src/pocketmine/block/Sand.php index bd98b47b1..b77f409d5 100644 --- a/src/pocketmine/block/Sand.php +++ b/src/pocketmine/block/Sand.php @@ -40,7 +40,7 @@ class Sand extends Fallable{ } public function getName() : string{ - if($this->meta === 0x01){ + if($this->getVariant() === 0x01){ return "Red Sand"; } diff --git a/src/pocketmine/block/Slab.php b/src/pocketmine/block/Slab.php index 8444479b6..dcfa75923 100644 --- a/src/pocketmine/block/Slab.php +++ b/src/pocketmine/block/Slab.php @@ -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; diff --git a/src/pocketmine/block/StainedClay.php b/src/pocketmine/block/StainedClay.php index 3807dab66..365c8790c 100644 --- a/src/pocketmine/block/StainedClay.php +++ b/src/pocketmine/block/StainedClay.php @@ -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"; } } diff --git a/src/pocketmine/block/StainedGlass.php b/src/pocketmine/block/StainedGlass.php index 76aa65d2d..5011ad444 100644 --- a/src/pocketmine/block/StainedGlass.php +++ b/src/pocketmine/block/StainedGlass.php @@ -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"; } } diff --git a/src/pocketmine/block/StainedGlassPane.php b/src/pocketmine/block/StainedGlassPane.php index 01a9d35df..f9f45a4c1 100644 --- a/src/pocketmine/block/StainedGlassPane.php +++ b/src/pocketmine/block/StainedGlassPane.php @@ -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"; } } diff --git a/src/pocketmine/block/Wool.php b/src/pocketmine/block/Wool.php index 3c6fa7d78..446395716 100644 --- a/src/pocketmine/block/Wool.php +++ b/src/pocketmine/block/Wool.php @@ -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{