Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generator #16

Open
Ivanzar opened this issue Apr 15, 2015 · 38 comments
Open

Generator #16

Ivanzar opened this issue Apr 15, 2015 · 38 comments

Comments

@Ivanzar
Copy link

Ivanzar commented Apr 15, 2015

how to make my generation of the world, so that some part of world hung in the air? I used Generator but not understood it

@Ivanzar
Copy link
Author

Ivanzar commented Apr 15, 2015

use pocketmine\level\generator\Generator;
use pocketmine\level\ChunkManager;
use pocketmine\utils\Random;

use pocketmine\math\Vector3;
use pocketmine\block\Block;

class TWWGenerator extends Generator{

    private $random,$level;

    public function __construct(array $settings=array()){

    }



    public function getName(){
        return "tww";

    }

    public function getSettings(){

    }

    public function getSpawn(){
        return new Vector3(128.5, 64, 128.5);
    }

    public function init(ChunkManager $level,Random $random){
        $this->random = $rnadom;
        $this->level = $level;

    }

    public function generateChunk($chunkX,$chunkZ){

        $chunk = $this->level->getChunk($chunkX, $chunkZ);
        $startX = min($selection[0][0] = 0, $selection[1][0] = 128);
        $endX = max($selection[0][0] = 0, $selection[1][0] = 128);
        $startY = min($selection[0][1] = 0, $selection[1][1] = 128);
        $endY = max($selection[0][1] = 0, $selection[1][1] = 128);
        $startZ = min($selection[0][2] = 0, $selection[1][2] = 128);
        $endZ = max($selection[0][2] = 0, $selection[1][2] = 128);
        for($x = $startX; $x < $endX; ++$x){
                for($y = $startY; $y < $endY; ++$y){
                for($z = $startZ; $z < $endZ; ++$z){
            $chunk->setBlockId($x,$y,$z,1);
        }
        }
        }
    }

    public function populateChunk($chunkX,$chunkZ){

    }

}

I used it as an experiment. Ignore if you did not understand me, give me example a generation

@PEMapModder
Copy link
Owner

What if I am not sure? :P

@Ivanzar
Copy link
Author

Ivanzar commented Apr 16, 2015

Just to explain the principle of generation. I honestly didn't quite understand what i write xD

@Ivanzar
Copy link
Author

Ivanzar commented Apr 16, 2015

i forgot load: STARTUP )

@xpyctum
Copy link

xpyctum commented Apr 16, 2015

@Ivanzar Айайай, плахой!!
:D

@Ivanzar
Copy link
Author

Ivanzar commented Apr 16, 2015

it`s progress
line 15, __construct()
16:47:49 [CRITICAL] Could not execute asynchronous task GenerationTask: Argument 1 passed to Ivanzar\TheTwoTowerns\TWWGenerator::__construct() must be of the type array, null given, called in phar://C:/Users/ivanzar/PocketMine Progect/PocketMine-MP/PocketMine-MP.phar/src/pocketmine/level/generator/GenerationTask.php on line 63 and defined

@xpyctum
Copy link

xpyctum commented Apr 16, 2015

@Ivanzar

public function __construct(){
     private $settings = array();
}

@Ivanzar
Copy link
Author

Ivanzar commented Apr 16, 2015

да я знаю

@Ivanzar
Copy link
Author

Ivanzar commented Apr 16, 2015

это есть

@xpyctum
Copy link

xpyctum commented Apr 16, 2015

@Ivanzar Fixed. Исправил коммент

@xpyctum
Copy link

xpyctum commented Apr 16, 2015

@Ivanzar попробуй моё. вдруг поможет

@Ivanzar
Copy link
Author

Ivanzar commented Apr 16, 2015

это ты про это
public function __construct(array $settings=array()){

}

@xpyctum
Copy link

xpyctum commented Apr 16, 2015

@Ivanzar угу, замени мое на твоё и попробуй.

@Ivanzar
Copy link
Author

Ivanzar commented Apr 16, 2015

может вместо приват php private $settings = array(); поставить php return

@xpyctum
Copy link

xpyctum commented Apr 16, 2015

@Ivanzar попробуй.

@Ivanzar
Copy link
Author

Ivanzar commented Apr 16, 2015

нет
Declaration of Ivanzar\TheTwoTowerns\TWWGenerator::__construct() must be compatible with pocketmine\level\generator\Generator::__construct(array $settings = Array) in C:\Users\ivanzar\PocketMine Progect\PocketMine-MP\plugins\DevTools\src\Ivanzar\TheTwoTowerns\TWWGenerator.php on line 0

@Ivanzar
Copy link
Author

Ivanzar commented Apr 16, 2015

сразу на 0
<php ему не нравиться )

@xpyctum
Copy link

xpyctum commented Apr 16, 2015

@Ivanzar <?php или <? сделай

@Ivanzar
Copy link
Author

Ivanzar commented Apr 16, 2015

<php

@xpyctum
Copy link

xpyctum commented Apr 16, 2015

@Ivanzar <?php надо, лал

@Ivanzar
Copy link
Author

Ivanzar commented Apr 16, 2015

ой у меня <?php

@xpyctum
Copy link

xpyctum commented Apr 16, 2015

@Ivanzar скинь весь код

@Ivanzar
Copy link
Author

Ivanzar commented Apr 16, 2015

вот

<?php
namespace Ivanzar\TheTwoTowerns;

use pocketmine\level\generator\Generator;
use pocketmine\level\ChunkManager;
use pocketmine\utils\Random;

use pocketmine\math\Vector3;
use pocketmine\block\Block;

class TWWGenerator extends Generator{

    private $random,$level;

    public function __construct(array $settings=array()){
        return $settings = array();
}


    public function getName(){
        return "tww";

    }

    public function getSettings(){

    }

    public function getSpawn(){
        return new Vector3(128, 64, 128);
    }

    public function init(ChunkManager $level,Random $random){
        $this->random = $random;
        $this->level = $level;

    }

    public function generateChunk($chunkX,$chunkZ){

        $chunk = $this->level->getChunk($chunkX, $chunkZ);
        $startX = min($selection[0][0] = 0, $selection[1][0] = 128);
        $endX = max($selection[0][0] = 0, $selection[1][0] = 128);
        $startY = min($selection[0][1] = 0, $selection[1][1] = 128);
        $endY = max($selection[0][1] = 0, $selection[1][1] = 128);
        $startZ = min($selection[0][2] = 0, $selection[1][2] = 128);
        $endZ = max($selection[0][2] = 0, $selection[1][2] = 128);
        for($x = $startX; $x < $endX; ++$x){
                for($y = $startY; $y < $endY; ++$y){
                for($z = $startZ; $z < $endZ; ++$z){
            $chunk->setBlockId($x,$y,$z,1);
        }
        }
        }
    }

    public function populateChunk($chunkX,$chunkZ){

    }

}

@Ivanzar
Copy link
Author

Ivanzar commented Apr 16, 2015

сейчас жалуется на __construct

@xpyctum
Copy link

xpyctum commented Apr 16, 2015

@Ivanzar мля..
сделай так:

public function __construct(){
    private $settings = array();
}

@Ivanzar
Copy link
Author

Ivanzar commented Apr 16, 2015

private не может быть в функции

@xpyctum
Copy link

xpyctum commented Apr 16, 2015

@Ivanzar тогда сделай ее не в конструкте.
А выше, где другие переменные.
В конструкте ничего тогда не пиши. И можно её удалить

@Ivanzar
Copy link
Author

Ivanzar commented Apr 16, 2015

нет, то же самое

@xpyctum
Copy link

xpyctum commented Apr 16, 2015

@Ivanzar что теперь?

@Ivanzar
Copy link
Author

Ivanzar commented Apr 16, 2015

Declaration of Ivanzar\TheTwoTowerns\TWWGenerator::__construct() must be compatible with pocketmine\level\generator\Generator::__construct(array $settings = Array) in C:\Users\ivanzar\PocketMine Progect\PocketMine-MP\plugins\DevTools\src\Ivanzar\TheTwoTowerns\TWWGenerator.php on line 0

@xpyctum
Copy link

xpyctum commented Apr 16, 2015

@Ivanzar как ты сделал, скинь код

@Ivanzar
Copy link
Author

Ivanzar commented Apr 16, 2015

use pocketmine\level\generator\Generator;
use pocketmine\level\ChunkManager;
use pocketmine\utils\Random;

use pocketmine\math\Vector3;
use pocketmine\block\Block;

class TWWGenerator extends Generator{

    private $random,$level;

    public function __construct(){
}


    public function getName(){
        return "tww";

    }

    public function getSettings(){

    }

    public function getSpawn(){
        return new Vector3(128, 64, 128);
    }

    public function init(ChunkManager $level,Random $random){
        $this->random = $random;
        $this->level = $level;

    }

    public function generateChunk($chunkX,$chunkZ){

        $chunk = $this->level->getChunk($chunkX, $chunkZ);
        $startX = min($selection[0][0] = 0, $selection[1][0] = 128);
        $endX = max($selection[0][0] = 0, $selection[1][0] = 128);
        $startY = min($selection[0][1] = 0, $selection[1][1] = 128);
        $endY = max($selection[0][1] = 0, $selection[1][1] = 128);
        $startZ = min($selection[0][2] = 0, $selection[1][2] = 128);
        $endZ = max($selection[0][2] = 0, $selection[1][2] = 128);
        for($x = $startX; $x < $endX; ++$x){
                for($y = $startY; $y < $endY; ++$y){
                for($z = $startZ; $z < $endZ; ++$z){
            $chunk->setBlockId($x,$y,$z,1);
        }
        }
        }
    }

    public function populateChunk($chunkX,$chunkZ){

    }

}

@Ivanzar
Copy link
Author

Ivanzar commented Apr 16, 2015

ура

private $random,$level,$options;

    public function getSettings(){
        return $this->options;
    }
    public function getName(){
        return "tww";
    }

    public function __construct(array $options = []){
        $this->options = $options;
    }


    public function getSpawn(){
        return new Vector3(128, 64, 128);
    }

@PEMapModder
Copy link
Owner

Use English please.

@PEMapModder
Copy link
Owner

And avoid doing PocketMine API-related things (like setting blocks) in other threads (including worker threads like AsyncTask), otherwise it will be dangerous.

@alejzeis
Copy link
Collaborator

Set blocks in tasks ran by the main thread or scheduler. Spigot doesn't
allow you to do world related things in async threads.

On Thursday, April 16, 2015, PEMapModder [email protected] wrote:

And avoid doing PocketMine API-related things (like setting blocks) in
other threads (including worker threads like AsyncTask), otherwise it will
be dangerous.


Reply to this email directly or view it on GitHub
#16 (comment)
.

@falkirks
Copy link
Collaborator

If you want to modify chunks asynchronously the best you can get is what MineReset does. It blocks update events to the chunk, serializes it on the main thread, unserializes it on an AsyncTask, calculates chunk updates and then passes it back to the main thread for sending to clients.

@Ivanzar
Copy link
Author

Ivanzar commented Apr 17, 2015

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants