PocketMine-MP /src/misc/world/generator/object/tree/TreeObject.php

Language PHP Lines 62
MD5 Hash ea3f2357c38243e66079e3368388b8c6
Repository https://github.com/domanicYL/PocketMine-MP.git View Raw File
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php

/*

           -
         /   \
      /         \
   /   PocketMine  \
/          MP         \
|\     @shoghicp     /|
|.   \           /   .|
| ..     \   /     .. |
|    ..    |    ..    |
|       .. | ..       |
\          |          /
   \       |       /
      \    |    /
         \ | /

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.


*/


class TreeObject{
	var $overridable = array(
		0 => true,
		6 => true,
		17 => true,
		18 => true,	
	);
	public static function growTree(LevelAPI $level, $block, $type){
		switch($type){
			case Sapling::SPRUCE:
				if(mt_rand(0,1) == 2){
					$tree = new SpruceTreeObject();
				}else{
					$tree = new PineTreeObject();
				}
				break;
			case Sapling::BIRCH:
				$tree = new SmallTreeObject();
				$tree->type = Sapling::BIRCH;
				break;
			default:
			case Sapling::OAK:
				if(mt_rand(0,9) === 0){
					$tree = new BigTreeObject();
				}else{
					$tree = new SmallTreeObject();
				}
				break;
		}
		if($tree->canPlaceObject($level, $block[2][0], $block[2][1], $block[2][2])){
			$tree->placeObject($level, $block[2][0], $block[2][1], $block[2][2]);
		}
	}
}
Back to Top