Open Ivanzar opened 9 years ago
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
What if I am not sure? :P
Just to explain the principle of generation. I honestly didn't quite understand what i write xD
i forgot load: STARTUP )
@Ivanzar Айайай, плахой!! :D
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
@Ivanzar
public function __construct(){
private $settings = array();
}
да я знаю
это есть
@Ivanzar Fixed. Исправил коммент
@Ivanzar попробуй моё. вдруг поможет
это ты про это public function __construct(array $settings=array()){
}
@Ivanzar угу, замени мое на твоё и попробуй.
может вместо приват php private $settings = array();
поставить php return
@Ivanzar попробуй.
нет 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
сразу на 0 <php ему не нравиться )
@Ivanzar <?php или <? сделай
<php
@Ivanzar <?php надо, лал
ой у меня <?php
@Ivanzar скинь весь код
вот
<?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){
}
}
сейчас жалуется на __construct
@Ivanzar мля.. сделай так:
public function __construct(){
private $settings = array();
}
private не может быть в функции
@Ivanzar тогда сделай ее не в конструкте. А выше, где другие переменные. В конструкте ничего тогда не пиши. И можно её удалить
нет, то же самое
@Ivanzar что теперь?
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 как ты сделал, скинь код
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){
}
}
ура
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);
}
Use English please.
And avoid doing PocketMine API-related things (like setting blocks) in other threads (including worker threads like AsyncTask), otherwise it will be dangerous.
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 notifications@github.com 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 https://github.com/PEMapModder/PocketMine-Plugin-Tutorials/issues/16#issuecomment-93756176 .
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.
thanks
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