PageRenderTime 53ms CodeModel.GetById 26ms RepoModel.GetById 1ms app.codeStats 0ms

/src/misc/world/generator/object/tree/TreeObject.php

https://github.com/domanicYL/PocketMine-MP
PHP | 62 lines | 35 code | 3 blank | 24 comment | 4 complexity | ea3f2357c38243e66079e3368388b8c6 MD5 | raw file
Possible License(s): LGPL-3.0
  1. <?php
  2. /*
  3. -
  4. / \
  5. / \
  6. / PocketMine \
  7. / MP \
  8. |\ @shoghicp /|
  9. |. \ / .|
  10. | .. \ / .. |
  11. | .. | .. |
  12. | .. | .. |
  13. \ | /
  14. \ | /
  15. \ | /
  16. \ | /
  17. This program is free software: you can redistribute it and/or modify
  18. it under the terms of the GNU Lesser General Public License as published by
  19. the Free Software Foundation, either version 3 of the License, or
  20. (at your option) any later version.
  21. */
  22. class TreeObject{
  23. var $overridable = array(
  24. 0 => true,
  25. 6 => true,
  26. 17 => true,
  27. 18 => true,
  28. );
  29. public static function growTree(LevelAPI $level, $block, $type){
  30. switch($type){
  31. case Sapling::SPRUCE:
  32. if(mt_rand(0,1) == 2){
  33. $tree = new SpruceTreeObject();
  34. }else{
  35. $tree = new PineTreeObject();
  36. }
  37. break;
  38. case Sapling::BIRCH:
  39. $tree = new SmallTreeObject();
  40. $tree->type = Sapling::BIRCH;
  41. break;
  42. default:
  43. case Sapling::OAK:
  44. if(mt_rand(0,9) === 0){
  45. $tree = new BigTreeObject();
  46. }else{
  47. $tree = new SmallTreeObject();
  48. }
  49. break;
  50. }
  51. if($tree->canPlaceObject($level, $block[2][0], $block[2][1], $block[2][2])){
  52. $tree->placeObject($level, $block[2][0], $block[2][1], $block[2][2]);
  53. }
  54. }
  55. }