package net.minecraft.world.level.block;

import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.server.level.ServerLevel;
import java.util.Random;
import net.minecraft.world.level.Level;
import net.minecraft.tags.Tag;
import net.minecraft.tags.BlockTags;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.levelgen.feature.HugeFungusConfiguration;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import java.util.function.Supplier;
import net.minecraft.world.phys.shapes.VoxelShape;

public class FungusBlock extends BushBlock implements BonemealableBlock {
    protected static final VoxelShape SHAPE;
    private final Supplier<ConfiguredFeature<HugeFungusConfiguration, ?>> feature;
    
    protected FungusBlock(final Properties c, final Supplier<ConfiguredFeature<HugeFungusConfiguration, ?>> supplier) {
        super(c);
        this.feature = supplier;
    }
    
    @Override
    public VoxelShape getShape(final BlockState cfj, final BlockGetter bpg, final BlockPos fu, final CollisionContext der) {
        return FungusBlock.SHAPE;
    }
    
    @Override
    protected boolean mayPlaceOn(final BlockState cfj, final BlockGetter bpg, final BlockPos fu) {
        return cfj.is(BlockTags.NYLIUM) || cfj.is(Blocks.SOUL_SOIL) || super.mayPlaceOn(cfj, bpg, fu);
    }
    
    @Override
    public boolean isValidBonemealTarget(final BlockGetter bpg, final BlockPos fu, final BlockState cfj, final boolean boolean4) {
        final Block bvr6 = this.feature.get().config.validBaseState.getBlock();
        final Block bvr7 = bpg.getBlockState(fu.below()).getBlock();
        return bvr7 == bvr6;
    }
    
    @Override
    public boolean isBonemealSuccess(final Level bqb, final Random random, final BlockPos fu, final BlockState cfj) {
        return random.nextFloat() < 0.4;
    }
    
    @Override
    public void performBonemeal(final ServerLevel zd, final Random random, final BlockPos fu, final BlockState cfj) {
        this.feature.get().place(zd, zd.structureFeatureManager(), zd.getChunkSource().getGenerator(), random, fu);
    }
    
    static {
        SHAPE = Block.box(4.0, 0.0, 4.0, 12.0, 9.0, 12.0);
    }
}
