unresolved3169 / Altay

A server software for Minecraft: Bedrock Edition in PHP (ABONDONED)
GNU Lesser General Public License v3.0
143 stars 52 forks source link

Spawning doesn't work properly #271

Open tgwaste opened 4 years ago

tgwaste commented 4 years ago

Nothing else seems to spawn other than Creepers.

PopGTN commented 4 years ago

Have u wait and fly around the world about it from some odd reason creepers spawn the most

tgwaste commented 4 years ago

I’m not sure what you mean but mobs are definitely broken.

PopGTN commented 4 years ago

Do u have plugins that uses its own mod ai like pureenitites, burgerspawners, vanillaenitityai, etc?

tgwaste commented 4 years ago

No I am not using any of those plugins with Altay.

tgwaste commented 4 years ago

Maybe this is related:

./src/pocketmine/level/Level.php:               if($this->server->getAltayProperty("level.generic-auto-mob-spawning", false) and $this->gameRules->getBool(GameRules::RULE_DO_MOB_SPAWNING) and $currentTick % 400 === 0){

./src/pocketmine/level/Level.php:                               if($this->gameRules->getBool(GameRules::RULE_DO_MOB_SPAWNING, false)){

So the default there is False. Maybe we want to ignore the gamerule since there is a config file setting? Or maybe default that to true?

Even with the gamerule set to true though all I get are a bunch of Creepers.

PopGTN commented 4 years ago

Idk lol not coder because it works for me well...

phoshp commented 4 years ago

pls try latest commits

tgwaste commented 4 years ago

Using the latest release I watched a neutral spot in the plains for 1 hour.

Results:

No other mobs spawned any where.

I have a counter that shows me the number of mobs near me and every now and again the total would double for a second (like it was trying to spawn something) but then immediately go back to the previous value.

I am not running any other plugins.

There is definitely something wrong here. I don't see a single friendly mob. Perhaps thats what its trying to spawn and failing on?

tgwaste commented 4 years ago

I adjusted my debug plugin to print whats spawning and de-spawning. I did this test sitting at the bottom of the ocean, you can see in the log that as soon as the mobs spawn they despawn.

spawnlog.txt

tgwaste commented 4 years ago

To dramatically improve spawning I edited

src/pocketmine/level/AnimalSpawner.php

and made findChunksForSpawning look like:

  public function findChunksForSpawning(Level $level, bool $spawnHostileMobs, bool $spawnPeacefulMobs, array $eligibleChunks) : void{
    $x = $level->getTime() % 24000;
    $dayTime = ($x < 12300 or $x > 23850) ? true : false;

    if($spawnHostileMobs or $spawnPeacefulMobs){
      $spawn = $level->getSpawnLocation();

      foreach(self::$creatureTypes as $creatureType){
        if((!$creatureType->isPeacefulCreature() or $spawnPeacefulMobs) and ($creatureType->isPeacefulCreature() or $spawnHostileMobs) and ($creatureType->getCreatureClass() !== Animal::class or $dayTime)) {

I tried to do a PR but for some reason it wants to commit ~108 files instead of just the one I changed. Maybe ill keep trying.

tgwaste commented 4 years ago

Notes: PR #283 fixes animal spawning in normal worlds. Water Mob Spawning is still broken (Squids will spawn and immediately despawn in masses) Im thinking maybe its a biome issue. This happens when I am standing next to an Ocean.
I also believe FlatWorlds may have some spawning issues as well. Again, Biome related?

tgwaste commented 4 years ago

In a FlatWorld standing in one spot for an hour yielded: flatworld (22) - Spider (4) - Chicken (4) - Sheep (3) - Cow (1) - Slime (4) - Zombie (3) - Creeper (2) - Cat (1) So I guess this is OK? I would expect at least 4 of each to obtain the min values but at least we're getting something. Going to try to debug the Squid issue.

tgwaste commented 4 years ago

Standing in normal world for an hour yields: normalworld (73) - Spider (22) - Creeper (15) - Skeleton (12) - Sheep (4) - Pig (5) - Zombie (11) - Cow (3) - Chicken (1) So while Creepers look a bit better there is definitely an over spawn of hostile mobs happening still.