diff --git a/src/material/block/solid/LeavesBlock.php b/src/material/block/solid/LeavesBlock.php index 35391300..8a8c5dc3 100644 --- a/src/material/block/solid/LeavesBlock.php +++ b/src/material/block/solid/LeavesBlock.php @@ -22,28 +22,30 @@ class LeavesBlock extends TransparentBlock{ } public static function createIndex($x, $y, $z){ - return $x.".".$y.".".$z; + return "$x.$y.$z"; } - public static function findLog(Level $level, $x, $y, $z, array $visited, $distance){ //port from newest pocketmine + public static function findLog(Level $level, $x, $y, $z, array &$visited, $distance){ //port from newest pocketmine $index = self::createIndex($x, $y, $z); if(isset($visited[$index])){ - return false; + return $visited[$index]; } - $visited[$index] = true; + $block = $level->level->getBlockID($x, $y, $z); if($block === WOOD){ //type doesn't matter - return true; + return ($visited[$index] = true); } if($block === LEAVES && $distance <= 4){ - if(self::findLog($level, $x - 1, $y, $z, $visited, $distance + 1)) return true; - if(self::findLog($level, $x + 1, $y, $z, $visited, $distance + 1)) return true; - if(self::findLog($level, $x, $y, $z - 1, $visited, $distance + 1)) return true; - if(self::findLog($level, $x, $y, $z + 1, $visited, $distance + 1)) return true; + if(self::findLog($level, $x - 1, $y, $z, $visited, $distance + 1)) return ($visited[$index] = true); + if(self::findLog($level, $x + 1, $y, $z, $visited, $distance + 1)) return ($visited[$index] = true); + if(self::findLog($level, $x, $y, $z - 1, $visited, $distance + 1)) return ($visited[$index] = true); + if(self::findLog($level, $x, $y, $z + 1, $visited, $distance + 1)) return ($visited[$index] = true); } - return false; + + return ($visited[$index] = false); } + public static function onRandomTick(Level $level, $x, $y, $z){ $b = $level->level->getBlock($x, $y, $z); $id = $b[0]; diff --git a/src/material/item/generic/DyeItem.php b/src/material/item/generic/DyeItem.php index 08e7c3c6..a85a3dce 100755 --- a/src/material/item/generic/DyeItem.php +++ b/src/material/item/generic/DyeItem.php @@ -1,26 +1,29 @@ "Ink Sac", + 1 => "Rose Red", + 2 => "Cactus Green", + 3 => "Cocoa Beans", + 4 => "Lapis Lazuli", + 5 => "Purple Dye", + 6 => "Cyan Dye", + 7 => "Light Gray Dye", + 8 => "Gray Dye", + 9 => "Pink Dye", + 10 => "Lime Dye", + 11 => "Dandelion Yellow", + 12 => "Light Blue Dye", + 13 => "Magenta Dye", + 14 => "Orange Dye", + 15 => "Bone Meal", + ); + public function __construct($meta = 0, $count = 1){ - parent::__construct(DYE, $meta, $count, "Dye"); - $names = array( - 0 => "Ink Sac", - 1 => "Rose Red", - 2 => "Cactus Green", - 3 => "Cocoa Beans", - 4 => "Lapis Lazuli", - 5 => "Purple Dye", - 6 => "Cyan Dye", - 7 => "Light Gray Dye", - 8 => "Gray Dye", - 9 => "Pink Dye", - 10 => "Lime Dye", - 11 => "Dandelion Yellow", - 12 => "Light Blue Dye", - 13 => "Magenta Dye", - 14 => "Orange Dye", - 15 => "Bone Meal", - ); - $this->name = $names[$this->meta]; + parent::__construct(DYE, $meta & 0xf, $count, "Dye"); + + $this->name = self::$names[$this->meta]; } }