-
Notifications
You must be signed in to change notification settings - Fork 15
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
Comments
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 Айайай, плахой!! |
it`s progress |
public function __construct(){
private $settings = array();
} |
да я знаю |
это есть |
@Ivanzar Fixed. Исправил коммент |
@Ivanzar попробуй моё. вдруг поможет |
это ты про это } |
@Ivanzar угу, замени мое на твоё и попробуй. |
может вместо приват |
@Ivanzar попробуй. |
нет |
сразу на 0 |
@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 On Thursday, April 16, 2015, PEMapModder [email protected] wrote:
|
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
The text was updated successfully, but these errors were encountered: