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.
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
relates to 1
Attachments
Comments 4
Relates to MCPE-152559.
Relates to MC-250267.