package net.minecraft.world.item;

import com.google.common.collect.Maps;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.entity.player.Player;
import net.minecraft.sounds.SoundSource;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.core.Direction;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.level.block.state.BlockState;
import java.util.Map;
import net.minecraft.world.level.block.Block;
import java.util.Set;

public class HoeItem extends DiggerItem {
    private static final Set<Block> DIGGABLES;
    protected static final Map<Block, BlockState> TILLABLES;
    
    protected HoeItem(final Tier blo, final int integer, final float float3, final Properties a) {
        super((float)integer, float3, blo, HoeItem.DIGGABLES, a);
    }
    
    @Override
    public InteractionResult useOn(final UseOnContext blv) {
        final Level bqb3 = blv.getLevel();
        final BlockPos fu4 = blv.getClickedPos();
        if (blv.getClickedFace() != Direction.DOWN && bqb3.getBlockState(fu4.above()).isAir()) {
            final BlockState cfj5 = HoeItem.TILLABLES.get(bqb3.getBlockState(fu4).getBlock());
            if (cfj5 != null) {
                final Player bec2 = blv.getPlayer();
                bqb3.playSound(bec2, fu4, SoundEvents.HOE_TILL, SoundSource.BLOCKS, 1.0f, 1.0f);
                if (!bqb3.isClientSide) {
                    bqb3.setBlock(fu4, cfj5, 11);
                    if (bec2 != null) {
                        blv.getItemInHand().<Player>hurtAndBreak(1, bec2, bec -> bec.broadcastBreakEvent(blv.getHand()));
                    }
                }
                return InteractionResult.sidedSuccess(bqb3.isClientSide);
            }
        }
        return InteractionResult.PASS;
    }
    
    static {
        DIGGABLES = ImmutableSet.<Block>of(Blocks.NETHER_WART_BLOCK, Blocks.WARPED_WART_BLOCK, Blocks.HAY_BLOCK, Blocks.DRIED_KELP_BLOCK, Blocks.TARGET, Blocks.SHROOMLIGHT, Blocks.SPONGE, Blocks.WET_SPONGE, Blocks.JUNGLE_LEAVES, Blocks.OAK_LEAVES, Blocks.SPRUCE_LEAVES, Blocks.DARK_OAK_LEAVES, Blocks.ACACIA_LEAVES, Blocks.BIRCH_LEAVES);
        TILLABLES = Maps.newHashMap(ImmutableMap.<Block, BlockState>of(Blocks.GRASS_BLOCK, Blocks.FARMLAND.defaultBlockState(), Blocks.GRASS_PATH, Blocks.FARMLAND.defaultBlockState(), Blocks.DIRT, Blocks.FARMLAND.defaultBlockState(), Blocks.COARSE_DIRT, Blocks.DIRT.defaultBlockState()));
    }
}
