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

Frogs can lay spawn on flowing water

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • 22w24a
    • 22w15a, 22w16b, 22w17a, 22w19a, 1.19 Pre-release 1, 1.19 Pre-release 5, 1.19 Release Candidate 2, 1.19
    • Confirmed
    • Mob behaviour
    • Normal

      The Bug:

      Players are unable to manually place frogspawn on flowing water so having frogs being able to lay spawn here seems illogical. Additionally, when the frogspawn receives a block update, it is instantly destroyed.

      Steps to Reproduce:

      • Build the setup as shown in the attachment below. setup.png
      • Summon two frogs nearby and breed them.
      • Wait for the pregnant frog to approach the water and lay its spawn.
      • Take note as to whether or not frogs can lay spawn on flowing water.

      Observed Behavior:

      Frogs can lay spawn on flowing water.

      Expected Behavior:

      Frogs would not be able to lay spawn on flowing water.

      Code Analysis:

      Code analysis by ampolive can be found below.

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

      In FrogAi#initLaySpawnActivity(...), a new TryLaySpawnOnWaterNearLand behavior is created for the frog. In the code:

      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;
              }
          }
      ...
      

      The behavior checks if the block adjacent to the block the frog is standing on is water, and if there is air on top of it. Because flowing water is considered a water block, frogs are able to lay their spawn here.

        1. MC-250261.mp4
          5.91 MB
        2. MC-250261.png
          MC-250261.png
          3.49 MB
        3. setup.png
          setup.png
          279 kB

            bagucode [Mojang] Markus Gustavsson
            Avoma [Mod] Avoma
            Votes:
            8 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: