mojira.dev
MCPE-150191

Cod & Salmon not spawning in Deep variants

Cod and Salmon have normal spawning patterns for cold, normal, and lukewarm oceans. For both frozen oceans and all deep variants of other oceans Cod and Salmon are not spawning

Attachments

Comments 6

Cod and Salmon spawn rules in the vanilla behavior pack were updated in 1.18.0 to only let them spawn in oceans between Y = 50 and Y = 64. The way spawning works in Bedrock, that means the ocean floor or other solid blocks must within that range in order for them to spawn in water above. I'm not sure if that's exactly what the developers intended or not.

In frozen oceans the ice on the ocean surface counts as the "surface" for spawning, so fish have never spawned under the ice in any version.

This is a difficult one as water caves can come above Y = 50. Perhaps updating the spawn rule to match Drowned minus light level. The only bug in copying over code I can foresee is where Drowned can spawn within cave systems, where we don't want salmon and cod spawning.

 

Second thought is matching them to vanilla squid spawn rules with a biome discriminator for the correct biomes, as squid spawn in warm oceans if I am not mistaken.

Hi, 
Thank you for pointing out the issue. I tested it out and the fishes are indeed harder to find. However, I can still see them, occasionally in deep ocean biomes.

I follow your suggestion and dig deeper into the spawning logic but couldn't find code evidence that support this statement for cod and salmon:
```
The way spawning works in Bedrock, that means the ocean floor or other solid blocks must within that range in order for them to spawn in water above.
```
I am curious, how did you arrive in the suggestion above?

I based my statement on Reed Cartwright’s reverse engineering of the spawning algorithm after the 1.16 update. He has summarized how the game searches for a spawnable block on which to attempt a spawn in a flowchart:

[media]

Note: On this flowchart a “gap block” is air, water, lava, or certain collisionless blocks like grass and flowers.

If you follow the chart, you’ll see that spawn attempts occur only when the block search (which starts at the top of the world for a given x, z) finds either ice, frosted ice, a top slab, or a solid block. The height_filter in the chosen mobs’ spawn rules json file is checked against this block, which is under the spot where the mob will spawn—thus its name, findNextSpawnBlockUnder. Land mobs spawn in the “gap block” immediately above the spawnable block, but water mobs get shifted upwards some random number of blocks if there is a continuous water source column above the spawnable block.

So based on how spawning works, this is what the fish height_filter does for ocean biome spawning in the current version:

  • Fish cannot spawn where the ocean floor is below Y = 49 or above Y = 63.

  • Fish can spawn at any height where there is a continuous column of source water blocks downward to a spawnable block at Y = 49 to 63.

[media]

demonstrates these behaviors using

[media]

. It contains command blocks that count fish and teleport them to their present location to hold them in place. No fish spawn when you stand on the light at -1450, 1270 because the ocean floor is below Y = 50 everywhere within fish spawn range. Fish spawn near Y = 100 in the chamber to the north when you move close enough because there is a solid block floor at Y = 63 with source water above it for about 40 blocks.

If the goal is to actually have fish spawn between Y = 50 and Y = 64 in all non-warm ocean biomes, then that Y range should be put into the hard-coded function that offsets fish spawns upward from the spawnable block. (It may technically be offsetting them downward from the highest connected water source above the spawnable block.) The data-driven height_filter is ill-suited to accomplish that goal.

Nhi Vo I completed a similar process as GoldenHelmet did. Any fish that are found in deep biomes spawn at a nearby valid space Y=>50. I never noticed spawning according to the second condition GoldenHelmet describes.

In my digging in the .json files for spawn rules the only variation between cod, salmon, and squid is nested in the Vanilla, 1.18.0, and 1.15 folders was the height filter on cod and salmon in 1.18.0.

Package paths:
WindowsApp folder \data\behavior_packs\vanilla\spawn_rules

WindowsApp folder \data\behavior_packs\vanilla_1.15\spawn_rules

WindowsApp folder \data\behavior_packs\vanilla_1.18.0\spawn_rules

 cod.json example:
Vanilla

{
  "format_version": "1.8.0",
  "minecraft:spawn_rules": {
    "description": {
      "identifier": "minecraft:cod",
      "population_control": "water_animal"
    },
    "conditions": [
      {
        "minecraft:spawns_on_surface": {},
        "minecraft:spawns_underwater": {},

        "minecraft:distance_filter": {
          "min": 12,
          "max": 32
        },
        "minecraft:weight": {
          "default": 75
        },
        "minecraft:density_limit": {
          "surface":20
        },
        "minecraft:herd": {
          "min_size":4,
          "max_size":7
        },

        "minecraft:biome_filter": [
          {"test": "has_biome_tag", "operator":"==", "value": "ocean"},
          {"test": "has_biome_tag", "operator":"!=", "value": "warm"}
        ]
      }
    ]
  }
}

1.18

{
  "format_version": "1.8.0",
  "minecraft:spawn_rules": {
    "description": {
      "identifier": "minecraft:cod",
      "population_control": "water_animal"
    },
    "conditions": [
      {
        "minecraft:spawns_on_surface": {},
        "minecraft:spawns_underwater": {},

        "minecraft:distance_filter": {
          "min": 12,
          "max": 32
        },
        "minecraft:weight": {
          "default": 75
        },
        "minecraft:density_limit": {
          "surface":20
        },
        "minecraft:height_filter": {
          "min": 50,
          "max": 64
        },
        "minecraft:herd": {
          "min_size":4,
          "max_size":7
        },

        "minecraft:biome_filter": [
          \{"test": "has_biome_tag", "operator":"==", "value": "ocean"},
          \{"test": "has_biome_tag", "operator":"!=", "value": "warm"}
        ]
      }
    ]
  }
}

Thank you for all of the useful information. 

Draco894

(Unassigned)

677638

Confirmed

Multiple

1.18.10.21 Beta, 1.18.0, 1.18.1 Hotfix, 1.18.2 Hotfix

1.18.20.21 Beta, 1.18.30

Retrieved