PageRenderTime 49ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://github.com/domanicYL/PocketMine-MP
PHP | 89 lines | 31 code | 10 blank | 48 comment | 1 complexity | 8d9772aefa5f82888906a502a12217dc 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. require_once("misc/world/generator/object/tree/TreeObject.php");
  23. class BigTreeObject extends TreeObject{
  24. private $trunkHeightMultiplier = 0.618;
  25. private $trunkHeight;
  26. private $leafAmount = 1;
  27. private $leafDistanceLimit = 5;
  28. private $widthScale = 1;
  29. private $branchSlope = 0.381;
  30. private $totalHeight = 6;
  31. private $leavesHeight = 3;
  32. protected $radiusIncrease = 0;
  33. private $addLeavesVines = false;
  34. private $addLogVines = false;
  35. private $addCocoaPlants = false;
  36. public function canPlaceObject(LevelAPI $level, $x, $y, $z){
  37. return false;
  38. }
  39. public function placeObject(LevelAPI $level, $x, $y, $z, $type){
  40. $this->trunkHeight = (int) ($this->totalHeight * $this->trunkHeightMultiplier);
  41. $leaves = $this->getLeafGroupPoints($level, $x, $y, $z);
  42. foreach($leaves as $leafGroup){
  43. $groupX = $leafGroup->getBlockX();
  44. $groupY = $leafGrou->getBlockY();
  45. $groupZ = $leafGroup->getBlockZ();
  46. for ($yy = $groupY; $yy < $groupY + $this->leafDistanceLimit; ++$yy) {
  47. $this->generateGroupLayer($level, $groupX, $yy, $groupZ, $this->getLeafGroupLayerSize($yy - $groupY));
  48. }
  49. }
  50. /*final BlockIterator trunk = new BlockIterator(new Point(w, x, y - 1, z), new Point(w, x, y + trunkHeight, z));
  51. while (trunk.hasNext()) {
  52. trunk.next().setMaterial(VanillaMaterials.LOG, logMetadata);
  53. }
  54. generateBranches(w, x, y, z, leaves);
  55. $level->setBlock($x, $y - 1, $z, 3, 0);
  56. $this->totalHeight += mt_rand(-1, 3);
  57. $this->leavesHeight += mt_rand(0, 1);
  58. for($yy = ($this->totalHeight - $this->leavesHeight); $yy < ($this->totalHeight + 1); ++$yy){
  59. $yRadius = ($yy - $this->totalHeight);
  60. $xzRadius = (int) (($this->radiusIncrease + 1) - $yRadius / 2);
  61. for($xx = -$xzRadius; $xx < ($xzRadius + 1); ++$xx){
  62. for($zz = -$xzRadius; $zz < ($xzRadius + 1); ++$zz){
  63. if((abs($xx) != $xzRadius or abs($zz) != $xzRadius) and $yRadius != 0){
  64. $level->setBlock($x + $xx, $y + $yy, $z + $zz, 18, $type);
  65. }
  66. }
  67. }
  68. }
  69. for($yy = 0; $yy < ($this->totalHeight - 1); ++$yy){
  70. $level->setBlock($x, $y + $yy, $z, 17, $type);
  71. }
  72. */
  73. }
  74. }