命名空间 MyPlot;使用 pocketminelockBlock;使用 pocketminelevelgeneratorGenerator;使用 pocketminelevelChunkManager;使用 pocketminemathVector3;使用 pocketmineutilsRandom;使用 pocketminelevelgeneratoriomeBiome;使用 pocketminelevelLevel;MyPlotGenerator 类发电机{私营 $level;私营 $settings;公共 $roadBlock、 $wallBlock、 $plotFloorBlock、 $plotFillBlock、 $bottomBlock;公共 $roadWidth、 $plotSize、 $groundHeight;const 情节 = 0;const 路 = 1;const 墙 = 2;公共函数 __construct (数组 $settings = []) {如果 (isset($settings["preset"])) {$settings = json_decode ($settings ["预设"] 真实);如果 ($settings = = = false) {$settings = []; }} {其他$settings = []; }$this-> 路障 = $this-> parseBlock ($settings,"路障",新的 Block(5));$this-> wallBlock = $this-> parseBlock ($settings,"WallBlock",新的 Block(44));$this-> plotFloorBlock = $this-> parseBlock ($settings,"PlotFloorBlock",新的 Block(2));$this-> plotFillBlock = $this-> parseBlock ($settings,"PlotFillBlock",新的 Block(3));$this-> bottomBlock = $this-> parseBlock ($settings,"BottomBlock",新的 Block(7));$this-> roadWidth = $this-> parseNumber ($settings,"RoadWidth",7);$this-> plotSize = $this-> parseNumber ($settings,"PlotSize",22);$this-> groundHeight = $this-> parseNumber ($settings,"GroundHeight",64);$this-> 设置 = [];$this-> 设置 ["预设"] = json_encode(["路障"= > $this-> 路障-> getId()。(($meta = $this-> 路障-> getDamage()) = = = 0?': ':'.$meta),"WallBlock"= > $this-> wallBlock-> getId()。(($meta = $this-> wallBlock-> getDamage()) = = = 0?': ':'.$meta),"PlotFloorBlock"= > $this-> plotFloorBlock-> getId()。(($meta = $this-> plotFloorBlock-> getDamage()) = = = 0?': ':'.$meta),"PlotFillBlock"= > $this-> plotFillBlock-> getId()。(($meta = $this-> plotFillBlock-> getDamage()) = = = 0?': ':'.$meta),"BottomBlock"= > $this-> bottomBlock-> getId()。(($meta = $this-> bottomBlock-> getDamage()) = = = 0?': ':'.$meta),"RoadWidth"= > $this-> roadWidth,"PlotSize"= > $this-> plotSize,"GroundHeight"= > $this-> groundHeight, ]); }私有函数 parseBlock (& $array、 $key、 $default) {如果 (isset($array[$key])) {$id = $array [$key];如果 (is_numeric($id)) {$block = 新 Block($id);} {其他$split = 爆炸 (":",$id);如果 (count($split) = = = 2 和 is_numeric($split[0]) 和 is_numeric($split[1])) {$block = 新块 ($split [0],$split[1]);} {其他$block = $default; } }} {其他$block = $default; }返回 $block; }私有函数 parseNumber (& $array、 $key、 $default) {如果 (isset($array[$key]) 和 is_numeric($array[$key])) {返回 $array [$key];} {其他返回 $default; } }公共函数 getName() {返回"myplot"; }公共函数 getSettings() {返回 $this-> 设置; }公共函数 init (ChunkManager $level,随机 $random) {$this-> 水平 = $level; }公共函数 generateChunk ($chunkX,$chunkZ) {$shape = $this-> getShape ($chunkX << 4、 $chunkZ << 4);$chunk = $this-> 水平-> getChunk ($chunkX、 $chunkZ);$chunk-> setGenerated();$c = Biome::getBiome(1)-> getColor();$R = $c >> 16;$G = ($c >> 8) & 0xff;$B = $c & 0xff;$bottomBlockId = $this-> bottomBlock-> getId();$bottomBlockMeta = $this-> bottomBlock-> getDamage();$plotFillBlockId = $this-> plotFillBlock-> getId();$plotFillBlockMeta = $this-> plotFillBlock-> getDamage();$plotFloorBlockId = $this-> plotFloorBlock-> getId();$plotFloorBlockMeta = $this-> plotFloorBlock-> getDamage();$roadBlockId = $this-> 路障-> getId();$roadBlockMeta = $this-> 路障-> getDamage();$wallBlockId = $this-> wallBlock-> getId();$wallBlockMeta = $this-> wallBlock-> getDamage();$groundHeight = $this-> groundHeight;为 ($Z = 0; $Z < 16; + + $Z) {为 ($X = 0; $X < 16; + + $X) {$chunk-> setBiomeId ($X,$Z,1);$chunk-> setBiomeColor ($X、 $Z、 $R、 $G、 $B);$chunk-> setBlock ($X,0,$Z、 $bottomBlockId、 $bottomBlockMeta);为 ($y = 1; $y < $groundHeight; + + $y) {$chunk-> setBlock ($X、 $y、 $Z、 $plotFillBlockId、 $plotFillBlockMeta); }$type = $shape [($Z << 4) | $X];如果 ($type = = = self::PLOT) {$chunk-> setBlock ($X、 $groundHeight、 $Z、 $plotFlo
正在翻譯中..