package net.minecraft.world.level.block;

import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.material.Fluid;
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.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.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 ShearableDoublePlantBlock 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 byj, final BlockGetter bjg, final BlockPos fk, final CollisionContext cvq) {
        return TallSeagrass.SHAPE;
    }
    
    @Override
    protected boolean mayPlaceOn(final BlockState byj, final BlockGetter bjg, final BlockPos fk) {
        return byj.isFaceSturdy(bjg, fk, Direction.UP) && byj.getBlock() != Blocks.MAGMA_BLOCK;
    }
    
    @Override
    public ItemStack getCloneItemStack(final BlockGetter bjg, final BlockPos fk, final BlockState byj) {
        return new ItemStack(Blocks.SEAGRASS);
    }
    
    @Nullable
    @Override
    public BlockState getStateForPlacement(final BlockPlaceContext bcq) {
        final BlockState byj3 = super.getStateForPlacement(bcq);
        if (byj3 != null) {
            final FluidState coj4 = bcq.getLevel().getFluidState(bcq.getClickedPos().above());
            if (coj4.is(FluidTags.WATER) && coj4.getAmount() == 8) {
                return byj3;
            }
        }
        return null;
    }
    
    @Override
    public boolean canSurvive(final BlockState byj, final LevelReader bjz, final BlockPos fk) {
        if (byj.<DoubleBlockHalf>getValue(TallSeagrass.HALF) == DoubleBlockHalf.UPPER) {
            final BlockState byj2 = bjz.getBlockState(fk.below());
            return byj2.getBlock() == this && byj2.<DoubleBlockHalf>getValue(TallSeagrass.HALF) == DoubleBlockHalf.LOWER;
        }
        final FluidState coj5 = bjz.getFluidState(fk);
        return super.canSurvive(byj, bjz, fk) && coj5.is(FluidTags.WATER) && coj5.getAmount() == 8;
    }
    
    @Override
    public FluidState getFluidState(final BlockState byj) {
        return Fluids.WATER.getSource(false);
    }
    
    @Override
    public boolean canPlaceLiquid(final BlockGetter bjg, final BlockPos fk, final BlockState byj, final Fluid coi) {
        return false;
    }
    
    @Override
    public boolean placeLiquid(final LevelAccessor bjx, final BlockPos fk, final BlockState byj, final FluidState coj) {
        return false;
    }
    
    static {
        HALF = ShearableDoublePlantBlock.HALF;
        SHAPE = Block.box(2.0, 0.0, 2.0, 14.0, 16.0, 14.0);
    }
}
