/* * Decompiled with CFR 0.152. * * Could not load the following classes: * com.mojang.serialization.MapCodec */ package net.minecraft.world.level.block; import com.mojang.serialization.MapCodec; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.server.level.ServerLevel; import net.minecraft.tags.FluidTags; import net.minecraft.util.RandomSource; import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.SnowLayerBlock; import net.minecraft.world.level.block.SnowyDirtBlock; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.lighting.LightEngine; public abstract class SpreadingSnowyDirtBlock extends SnowyDirtBlock { protected SpreadingSnowyDirtBlock(BlockBehaviour.Properties properties) { super(properties); } private static boolean canBeGrass(BlockState state, LevelReader level, BlockPos pos) { BlockPos above = pos.above(); BlockState aboveState = level.getBlockState(above); if (aboveState.is(Blocks.SNOW) && aboveState.getValue(SnowLayerBlock.LAYERS) == 1) { return true; } if (aboveState.getFluidState().getAmount() == 8) { return false; } int lightBlockInto = LightEngine.getLightBlockInto(state, aboveState, Direction.UP, aboveState.getLightBlock()); return lightBlockInto < 15; } protected abstract MapCodec codec(); private static boolean canPropagate(BlockState state, LevelReader level, BlockPos pos) { BlockPos above = pos.above(); return SpreadingSnowyDirtBlock.canBeGrass(state, level, pos) && !level.getFluidState(above).is(FluidTags.WATER); } @Override protected void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { if (!SpreadingSnowyDirtBlock.canBeGrass(state, level, pos)) { level.setBlockAndUpdate(pos, Blocks.DIRT.defaultBlockState()); return; } if (level.getMaxLocalRawBrightness(pos.above()) >= 9) { BlockState defaultBlockState = this.defaultBlockState(); for (int i = 0; i < 4; ++i) { BlockPos testPos = pos.offset(random.nextInt(3) - 1, random.nextInt(5) - 3, random.nextInt(3) - 1); if (!level.getBlockState(testPos).is(Blocks.DIRT) || !SpreadingSnowyDirtBlock.canPropagate(defaultBlockState, level, testPos)) continue; level.setBlockAndUpdate(testPos, (BlockState)defaultBlockState.setValue(SNOWY, SpreadingSnowyDirtBlock.isSnowySetting(level.getBlockState(testPos.above())))); } } } }