package net.minecraft.world.level.block;

import net.minecraft.world.level.block.state.StateHolder;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.material.FluidState;
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.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;

public interface SimpleWaterloggedBlock extends BucketPickup, LiquidBlockContainer {
    default boolean canPlaceLiquid(final BlockGetter bpg, final BlockPos fu, final BlockState cfj, final Fluid cwz) {
        return !cfj.<Boolean>getValue((Property<Boolean>)BlockStateProperties.WATERLOGGED) && cwz == Fluids.WATER;
    }
    
    default boolean placeLiquid(final LevelAccessor bqc, final BlockPos fu, final BlockState cfj, final FluidState cxa) {
        if (!cfj.<Boolean>getValue((Property<Boolean>)BlockStateProperties.WATERLOGGED) && cxa.getType() == Fluids.WATER) {
            if (!bqc.isClientSide()) {
                bqc.setBlock(fu, ((StateHolder<O, BlockState>)cfj).<Comparable, Boolean>setValue((Property<Comparable>)BlockStateProperties.WATERLOGGED, true), 3);
                bqc.getLiquidTicks().scheduleTick(fu, cxa.getType(), cxa.getType().getTickDelay(bqc));
            }
            return true;
        }
        return false;
    }
    
    default Fluid takeLiquid(final LevelAccessor bqc, final BlockPos fu, final BlockState cfj) {
        if (cfj.<Boolean>getValue((Property<Boolean>)BlockStateProperties.WATERLOGGED)) {
            bqc.setBlock(fu, ((StateHolder<O, BlockState>)cfj).<Comparable, Boolean>setValue((Property<Comparable>)BlockStateProperties.WATERLOGGED, false), 3);
            return Fluids.WATER;
        }
        return Fluids.EMPTY;
    }
}
