package net.minecraft.world.level.block;

import net.minecraft.world.level.block.state.StateHolder;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.level.ItemLike;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.state.properties.Property;
import net.minecraft.sounds.SoundSource;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.core.Direction;
import net.minecraft.world.item.Items;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.player.Player;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.BlockBehaviour;

public class PumpkinBlock extends StemGrownBlock {
    protected PumpkinBlock(final Properties c) {
        super(c);
    }
    
    @Override
    public InteractionResult use(final BlockState cfj, final Level bqb, final BlockPos fu, final Player bec, final InteractionHand anf, final BlockHitResult deh) {
        final ItemStack bki8 = bec.getItemInHand(anf);
        if (bki8.getItem() == Items.SHEARS) {
            if (!bqb.isClientSide) {
                final Direction fz9 = deh.getDirection();
                final Direction fz10 = (fz9.getAxis() == Direction.Axis.Y) ? bec.getDirection().getOpposite() : fz9;
                bqb.playSound(null, fu, SoundEvents.PUMPKIN_CARVE, SoundSource.BLOCKS, 1.0f, 1.0f);
                bqb.setBlock(fu, ((StateHolder<O, BlockState>)Blocks.CARVED_PUMPKIN.defaultBlockState()).<Comparable, Direction>setValue((Property<Comparable>)CarvedPumpkinBlock.FACING, fz10), 11);
                final ItemEntity bbg11 = new ItemEntity(bqb, fu.getX() + 0.5 + fz10.getStepX() * 0.65, fu.getY() + 0.1, fu.getZ() + 0.5 + fz10.getStepZ() * 0.65, new ItemStack(Items.PUMPKIN_SEEDS, 4));
                bbg11.setDeltaMovement(0.05 * fz10.getStepX() + bqb.random.nextDouble() * 0.02, 0.05, 0.05 * fz10.getStepZ() + bqb.random.nextDouble() * 0.02);
                bqb.addFreshEntity(bbg11);
                bki8.<Player>hurtAndBreak(1, bec, bec -> bec.broadcastBreakEvent(anf));
            }
            return InteractionResult.sidedSuccess(bqb.isClientSide);
        }
        return super.use(cfj, bqb, fu, bec, anf, deh);
    }
    
    @Override
    public StemBlock getStem() {
        return (StemBlock)Blocks.PUMPKIN_STEM;
    }
    
    @Override
    public AttachedStemBlock getAttachedStem() {
        return (AttachedStemBlock)Blocks.ATTACHED_PUMPKIN_STEM;
    }
}
