/* * Decompiled with CFR 0.152. * * Could not load the following classes: * com.mojang.datafixers.kinds.App * com.mojang.datafixers.kinds.Applicative * com.mojang.serialization.MapCodec * com.mojang.serialization.codecs.RecordCodecBuilder */ package net.minecraft.world.level.block; import com.mojang.datafixers.kinds.App; import com.mojang.datafixers.kinds.Applicative; import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; import net.minecraft.core.BlockPos; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; import net.minecraft.server.level.ServerLevel; import net.minecraft.util.RandomSource; import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.BonemealableBlock; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; public class BonemealableFeaturePlacerBlock extends Block implements BonemealableBlock { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(i -> i.group((App)ResourceKey.codec(Registries.CONFIGURED_FEATURE).fieldOf("feature").forGetter(b -> b.feature), BonemealableFeaturePlacerBlock.propertiesCodec()).apply((Applicative)i, BonemealableFeaturePlacerBlock::new)); private final ResourceKey> feature; public MapCodec codec() { return CODEC; } public BonemealableFeaturePlacerBlock(ResourceKey> feature, BlockBehaviour.Properties properties) { super(properties); this.feature = feature; } @Override public boolean isValidBonemealTarget(LevelReader level, BlockPos pos, BlockState state) { return level.getBlockState(pos.above()).isAir(); } @Override public boolean isBonemealSuccess(Level level, RandomSource random, BlockPos pos, BlockState state) { return true; } @Override public void performBonemeal(ServerLevel level, RandomSource random, BlockPos pos, BlockState state) { level.registryAccess().lookup(Registries.CONFIGURED_FEATURE).flatMap(registry -> registry.get(this.feature)).ifPresent(mossPatch -> ((ConfiguredFeature)mossPatch.value()).place(level, level.getChunkSource().getGenerator(), random, pos.above())); } @Override public BonemealableBlock.Type getType() { return BonemealableBlock.Type.NEIGHBOR_SPREADER; } }