The bug
Grass blocks turn into dirt when there's at least two snow layers on top of it.
To reproduce
Place a grass block
Place two snow layers on top of it
Wait (or use
/gamerule randomTickSpeed
if you're impatient)❌ The grass block turns into dirt
Original description
Light used to go through snow layers, but doesn't anymore. Also, when placing more than 1 layer on a grass block the game removes the grass from the dirt.
Linked issues
is duplicated by 2
relates to 2
Attachments
Comments 13
Code analysis (Mojang mappings, 1.19.2): SpreadingSnowyDirtBlock#canBeGrass(...)
(which is called in randomTick(...)
to turn the snowy block back into a dirt block) only early returns true
if the block above is a snow (layer) block with one layer:
...
private static boolean canBeGrass(BlockState $$0, LevelReader $$1, BlockPos $$2) {
BlockPos $$3 = $$2.above();
BlockState $$4 = $$1.getBlockState($$3);
if ($$4.is(Blocks.SNOW) && $$4.getValue(SnowLayerBlock.LAYERS) == 1) {
return true;
}
...
}
...
Changing $$4.getValue(SnowLayerBlock.LAYERS) == 1
to $$4.getValue(SnowLayerBlock.LAYERS) < 8
(or removing this additional check altogether, if it is desirable) should fix this issue.
Snow layers not letting light through is MC-139459 and intended. However, I can confirm that grass turns into dirt when there's snow layers on top of it with at least level 2. I have edited this ticket so that it no longer contains the issue about the lighting but only about the grass turning into dirt.