package net.minecraft.world.level.block;

import net.minecraft.world.level.block.state.StateHolder;
import net.minecraft.world.level.block.state.properties.Property;
import net.minecraft.world.level.block.state.properties.DoubleBlockHalf;
import net.minecraft.server.level.ServerLevel;
import java.util.Random;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.level.LevelAccessor;
import javax.annotation.Nullable;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.tags.Tag;
import net.minecraft.tags.FluidTags;
import net.minecraft.world.item.BlockPlaceContext;
import net.minecraft.core.Direction;
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.phys.shapes.VoxelShape;

public class Seagrass extends BushBlock implements BonemealableBlock, LiquidBlockContainer {
    protected static final VoxelShape SHAPE;
    
    protected Seagrass(final Properties c) {
        super(c);
    }
    
    @Override
    public VoxelShape getShape(final BlockState cfj, final BlockGetter bpg, final BlockPos fu, final CollisionContext der) {
        return Seagrass.SHAPE;
    }
    
    @Override
    protected boolean mayPlaceOn(final BlockState cfj, final BlockGetter bpg, final BlockPos fu) {
        return cfj.isFaceSturdy(bpg, fu, Direction.UP) && !cfj.is(Blocks.MAGMA_BLOCK);
    }
    
    @Nullable
    @Override
    public BlockState getStateForPlacement(final BlockPlaceContext bin) {
        final FluidState cxa3 = bin.getLevel().getFluidState(bin.getClickedPos());
        if (cxa3.is(FluidTags.WATER) && cxa3.getAmount() == 8) {
            return super.getStateForPlacement(bin);
        }
        return null;
    }
    
    @Override
    public BlockState updateShape(final BlockState cfj1, final Direction fz, final BlockState cfj3, final LevelAccessor bqc, final BlockPos fu5, final BlockPos fu6) {
        final BlockState cfj4 = super.updateShape(cfj1, fz, cfj3, bqc, fu5, fu6);
        if (!cfj4.isAir()) {
            bqc.getLiquidTicks().scheduleTick(fu5, Fluids.WATER, Fluids.WATER.getTickDelay(bqc));
        }
        return cfj4;
    }
    
    @Override
    public boolean isValidBonemealTarget(final BlockGetter bpg, final BlockPos fu, final BlockState cfj, final boolean boolean4) {
        return true;
    }
    
    @Override
    public boolean isBonemealSuccess(final Level bqb, final Random random, final BlockPos fu, final BlockState cfj) {
        return true;
    }
    
    @Override
    public FluidState getFluidState(final BlockState cfj) {
        return Fluids.WATER.getSource(false);
    }
    
    @Override
    public void performBonemeal(final ServerLevel zd, final Random random, final BlockPos fu, final BlockState cfj) {
        final BlockState cfj2 = Blocks.TALL_SEAGRASS.defaultBlockState();
        final BlockState cfj3 = ((StateHolder<O, BlockState>)cfj2).<DoubleBlockHalf, DoubleBlockHalf>setValue(TallSeagrass.HALF, DoubleBlockHalf.UPPER);
        final BlockPos fu2 = fu.above();
        if (zd.getBlockState(fu2).is(Blocks.WATER)) {
            zd.setBlock(fu, cfj2, 2);
            zd.setBlock(fu2, cfj3, 2);
        }
    }
    
    @Override
    public boolean canPlaceLiquid(final BlockGetter bpg, final BlockPos fu, final BlockState cfj, final Fluid cwz) {
        return false;
    }
    
    @Override
    public boolean placeLiquid(final LevelAccessor bqc, final BlockPos fu, final BlockState cfj, final FluidState cxa) {
        return false;
    }
    
    static {
        SHAPE = Block.box(2.0, 0.0, 2.0, 14.0, 12.0, 14.0);
    }
}
