mojira.dev
MC-250261

Frogs can lay spawn on flowing water

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.

[media]
  • 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 @unknown 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.

Linked issues

Attachments

Comments 4

@unknown, I've included the code analysis you did on MC-250267 to the description of this ticket (MC-250261) since I feel it's insightful and also because it's essentially the same cause of both of these issues. I've credited you where appropriate and I hope you're okay with this. 🙂

No problem at all! 🙂

Avoma

mgustavsson

Confirmed

Normal

Mob behaviour

frog, frog-spawn

22w15a, 22w16b, 22w17a, 22w19a, 1.19 Pre-release 1, 1.19 Pre-release 5, 1.19 Release Candidate 2, 1.19

22w24a

Retrieved