package net.minecraft.world.level.block;

import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.level.block.state.properties.Property;
import net.minecraft.world.level.LevelReader;
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.world.level.ItemLike;
import net.minecraft.world.item.ItemStack;
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;
import net.minecraft.world.level.block.state.properties.DoubleBlockHalf;
import net.minecraft.world.level.block.state.properties.EnumProperty;

public class TallSeagrass extends DoublePlantBlock implements LiquidBlockContainer {
    public static final EnumProperty<DoubleBlockHalf> HALF;
    protected static final VoxelShape SHAPE;
    
    public TallSeagrass(final Properties c) {
        super(c);
    }
    
    @Override
    public VoxelShape getShape(final BlockState cfj, final BlockGetter bpg, final BlockPos fu, final CollisionContext der) {
        return TallSeagrass.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);
    }
    
    @Override
    public ItemStack getCloneItemStack(final BlockGetter bpg, final BlockPos fu, final BlockState cfj) {
        return new ItemStack(Blocks.SEAGRASS);
    }
    
    @Nullable
    @Override
    public BlockState getStateForPlacement(final BlockPlaceContext bin) {
        final BlockState cfj3 = super.getStateForPlacement(bin);
        if (cfj3 != null) {
            final FluidState cxa4 = bin.getLevel().getFluidState(bin.getClickedPos().above());
            if (cxa4.is(FluidTags.WATER) && cxa4.getAmount() == 8) {
                return cfj3;
            }
        }
        return null;
    }
    
    @Override
    public boolean canSurvive(final BlockState cfj, final LevelReader bqd, final BlockPos fu) {
        if (cfj.<DoubleBlockHalf>getValue(TallSeagrass.HALF) == DoubleBlockHalf.UPPER) {
            final BlockState cfj2 = bqd.getBlockState(fu.below());
            return cfj2.is(this) && cfj2.<DoubleBlockHalf>getValue(TallSeagrass.HALF) == DoubleBlockHalf.LOWER;
        }
        final FluidState cxa5 = bqd.getFluidState(fu);
        return super.canSurvive(cfj, bqd, fu) && cxa5.is(FluidTags.WATER) && cxa5.getAmount() == 8;
    }
    
    @Override
    public FluidState getFluidState(final BlockState cfj) {
        return Fluids.WATER.getSource(false);
    }
    
    @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 {
        HALF = DoublePlantBlock.HALF;
        SHAPE = Block.box(2.0, 0.0, 2.0, 14.0, 16.0, 14.0);
    }
}
