Ad5001 / BetterGen

PocketMine's Tomorrow's World Generator. Mirror of
https://git.ad5001.eu/Ad5001/BetterGen
Other
58 stars 27 forks source link

Notice: Undefined index: generation.level4.generator #27

Closed inxomnyaa closed 7 years ago

inxomnyaa commented 7 years ago

Notice: Undefined index: generation.level4.generator in phar://C:/Users/Administrator/Desktop/Server/MinecraftPE/WolvesFortressCSphp7/ClearSky-PocketMine-MP_1.6.2dev.phar/src/pocketmine/scheduler/AsyncTask.php on line 142 [20:16:46] [Asynchronous Worker #2 thread/CRITICAL]: Error: "Cannot access protected property Ad5001\BetterGen\generator\BetterNormal::$options" (EXCEPTION) in "/BetterGen/src/Ad5001/BetterGen/biome/BetterDesert" at line 46 [20:16:46] [Asynchronous Worker #1 thread/CRITICAL]: Error: "Cannot access protected property Ad5001\BetterGen\generator\BetterNormal::$options" (EXCEPTION) in "/BetterGen/src/Ad5001/BetterGen/biome/BetterDesert" at line 46 [20:16:46] [Asynchronous Worker #1 thread/DEBUG]: #0 /BetterGen/src/Ad5001/BetterGen/generator/BetterNormal(148): Ad5001\BetterGen\biome\BetterDesert->construct(boolean) [20:16:46] [Asynchronous Worker #2 thread/DEBUG]: #0 /BetterGen/src/Ad5001/BetterGen/generator/BetterNormal(148): Ad5001\BetterGen\biome\BetterDesert->construct(boolean) [20:16:46] [Asynchronous Worker #1 thread/DEBUG]: #1 /src/pocketmine/level/generator/GeneratorRegisterTask(53): Ad5001\BetterGen\generator\BetterNormal->init(pocketmine\level\SimpleChunkManager object, pocketmine\utils\Random object) [20:16:46] [Asynchronous Worker #2 thread/DEBUG]: #1 /src/pocketmine/level/generator/GeneratorRegisterTask(53): Ad5001\BetterGen\generator\BetterNormal->init(pocketmine\level\SimpleChunkManager object, pocketmine\utils\Random object) [20:16:46] [Asynchronous Worker #2 thread/DEBUG]: #2 /src/pocketmine/scheduler/AsyncTask(80): pocketmine\level\generator\GeneratorRegisterTask->onRun(boolean) [20:16:46] [Asynchronous Worker #1 thread/DEBUG]: #2 /src/pocketmine/scheduler/AsyncTask(80): pocketmine\level\generator\GeneratorRegisterTask->onRun(boolean)

Notice: Undefined index: generation.level4.generator in phar://C:/Users/Administrator/Desktop/Server/MinecraftPE/WolvesFortressCSphp7/ClearSky-PocketMine-MP_1.6.2dev.phar/src/pocketmine/scheduler/AsyncTask.php on line 142 [20:16:46] [Server thread/CRITICAL]: Could not execute asynchronous task GeneratorRegisterTask: Task crashed [20:16:46] [Server thread/CRITICAL]: Could not execute asynchronous task GeneratorRegisterTask: Task crashed zend_mm_heap corrupted [20:16:46] [Asynchronous Worker #2 thread/CRITICAL]: Error: "Cannot access protected property Ad5001\BetterGen\generator\BetterNormal::$options" (EXCEPTION) in "/BetterGen/src/Ad5001/BetterGen/biome/BetterDesert" at line 46 bin\php\php.exe: Exit 1

inxomnyaa commented 7 years ago

Notice: Undefined index: generation.level4.manager in phar://C:/Users/Administrator/Desktop/Server/MinecraftPE/WolvesFortressCSphp7/ClearSky-PocketMine-MP_1.6.2dev.phar/src/pocketmine/scheduler/AsyncTask.php on line 142

Ad5001 commented 7 years ago

I see... will fix this this evening.

inxomnyaa commented 7 years ago

i have no idea where this comes from ^^

Offtoppic: can you explain me yield/generators? For example, i don't understand why yield is needed here, for me it looks like its not even necessary..

<?php
function fib($n)
{
    $cur = 1;
    $prev = 0;
    for ($i = 0; $i < $n; $i++) {
    yield $cur;
        $temp = $cur;
        $cur = $prev + $cur;
        $prev = $temp;
    }
}

$fibs = fib(9);
foreach ($fibs as $fib) {
    echo " " . $fib;
}

This here is just the same:

<?php
function fib($n)
{
    $res = [];
    $cur = 1;
    $prev = 0;
    for ($i = 0; $i < $n; $i++) {
        $res[] = $cur;
        $temp = $cur;
        $cur = $prev + $cur;
        $prev = $temp;
    }
    return $res;
}

$fibs = fib(9);
foreach ($fibs as $fib) {
    echo " " . $fib;
}
inxomnyaa commented 7 years ago

Oh actually i see now. it simply doesn't save an array to memory

Ad5001 commented 7 years ago

@thebigsmileXD There is an another difference, yield pauses the function execution and execute the code on the foreach (where you can send values back using the $gen->send() function).
Your code should look like this:

<?php
function fib($n) {
    $cur = 1;
    for ($i = 0; $i < $n; $i++) {
        echo " " . $cur;
        $cur += yield $cur;
    }
}

$prev = 0;
foreach ($gen = fib(9) as $fib) {
    echo " Foreach:" . $fib;
    $gen->send($fib);
    $prev = $fib;
}

This would output:

1 Foreach:1 2 2 Foreach:2 4 4 Foreach:4 8 8 Foreach:8 16 16 Foreach:16
Ad5001 commented 7 years ago

Uhh. What branch are you runing?

inxomnyaa commented 7 years ago

Not sure, i guess.. master?

Ad5001 commented 7 years ago

Well on master, BetterNormal::$options is public. Try updating it maybe?

Ad5001 commented 7 years ago

Do anyone still get this bug or I can close it? I cannot reproduce it.

AvgZing commented 7 years ago

👍