mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-21 12:09:43 +00:00
fixed broken findLog cache, fixed dyes with meta > 15
This commit is contained in:
parent
82b188168b
commit
69d3321e16
2 changed files with 35 additions and 30 deletions
|
|
@ -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];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue