Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-250310

Frogs cannot lay their spawn on water that has light blocks or structure void above it

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Works As Intended
    • None
    • 22w15a, 22w16b
    • None
    • Confirmed
    • (Unassigned)

      The Bug:

      Frogs cannot lay their spawn on water that has light blocks or structure void above it.

      Steps to Reproduce:

      • Summon a small area of water that has light blocks above it by running the following commands provided below.
      • /fill ~1 ~ ~1 ~15 ~2 ~15 minecraft:stone
      • /fill ~4 ~ ~4 ~12 ~2 ~12 minecraft:water
      • /fill ~4 ~3 ~4 ~12 ~3 ~12 minecraft:light
      • Summon multiple frogs on the stone and breed them.
      • Observe the behavior of the frogs closely for around a minute.
      • Take note as to whether or not frogs can lay their spawn on water that has light blocks or structure void above it.

      Observed Behavior:

      Frogs cannot lay their spawn.

      Expected Behavior:

      Frogs would be able to lay their spawn.

      Code Analysis:

      Code analysis by Avoma can be found below.

      The following is based on a decompiled version of Minecraft 22w15a using Mojang mappings.

      net.minecraft.world.entity.ai.behavior.TryLaySpawnOnWaterNearLand.java
      ...
          @Override
          protected void start(ServerLevel $$0, Frog $$1, long $$2) {
              BlockPos $$3 = $$1.blockPosition().below();
              for (Direction $$4 : Direction.Plane.HORIZONTAL) {
                  BlockPos $$6;
                  BlockPos $$5 = $$3.relative($$4);
                  if (!$$0.getBlockState($$5).is(Blocks.WATER) || !$$0.getBlockState($$6 = $$5.above()).isAir()) continue;
                  $$0.setBlock($$6, this.spawnBlock.defaultBlockState(), 3);
                  $$0.playSound(null, $$1, SoundEvents.FROG_LAY_SPAWN, SoundSource.BLOCKS, 1.0f, 1.0f);
                  $$1.getBrain().eraseMemory(this.memoryModule);
                  return;
              }
          }
      ...
      

      If we look at the above class, we can see that the block above the desired placing location must be air in order for frogs to be able to lay their spawn here. This is evident through the following line of code:

      ... $$5.above()).isAir()) ...

      Because light blocks and structure void are not considered air, frogs are unable to lay spawn on water that has these blocks above it.

            Unassigned Unassigned
            Avoma [Mod] Avoma
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: