package net.minecraft.world.level.block;

import net.minecraft.world.level.block.state.AbstractStateHolder;
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 bjg, final BlockPos fk, final BlockState byj, final Fluid coi) {
        return !byj.<Boolean>getValue((Property<Boolean>)BlockStateProperties.WATERLOGGED) && coi == Fluids.WATER;
    }
    
    default boolean placeLiquid(final LevelAccessor bjx, final BlockPos fk, final BlockState byj, final FluidState coj) {
        if (!byj.<Boolean>getValue((Property<Boolean>)BlockStateProperties.WATERLOGGED) && coj.getType() == Fluids.WATER) {
            if (!bjx.isClientSide()) {
                bjx.setBlock(fk, ((AbstractStateHolder<O, BlockState>)byj).<Comparable, Boolean>setValue((Property<Comparable>)BlockStateProperties.WATERLOGGED, true), 3);
                bjx.getLiquidTicks().scheduleTick(fk, coj.getType(), coj.getType().getTickDelay(bjx));
            }
            return true;
        }
        return false;
    }
    
    default Fluid takeLiquid(final LevelAccessor bjx, final BlockPos fk, final BlockState byj) {
        if (byj.<Boolean>getValue((Property<Boolean>)BlockStateProperties.WATERLOGGED)) {
            bjx.setBlock(fk, ((AbstractStateHolder<O, BlockState>)byj).<Comparable, Boolean>setValue((Property<Comparable>)BlockStateProperties.WATERLOGGED, false), 3);
            return Fluids.WATER;
        }
        return Fluids.EMPTY;
    }
}
