package net.minecraft.world.level.levelgen.feature; import com.mojang.serialization.Codec; import net.minecraft.core.BlockPos; import net.minecraft.world.level.WorldGenLevel; import net.minecraft.world.level.levelgen.feature.configurations.ReplaceBlockConfiguration; import net.minecraft.world.level.levelgen.feature.configurations.OreConfiguration.TargetBlockState; public class ReplaceBlockFeature extends Feature { public ReplaceBlockFeature(Codec codec) { super(codec); } @Override public boolean place(FeaturePlaceContext context) { WorldGenLevel worldGenLevel = context.level(); BlockPos blockPos = context.origin(); ReplaceBlockConfiguration replaceBlockConfiguration = context.config(); for (TargetBlockState targetBlockState : replaceBlockConfiguration.targetStates) { if (targetBlockState.target.test(worldGenLevel.getBlockState(blockPos), context.random())) { worldGenLevel.setBlock(blockPos, targetBlockState.state, 2); break; } } return true; } }