package net.minecraft.core.dispenser;

import net.minecraft.core.BlockPos;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.BlockPlaceContext;
import net.minecraft.world.item.DirectionalPlaceContext;
import net.minecraft.world.level.block.state.properties.Property;
import net.minecraft.world.level.block.DispenserBlock;
import net.minecraft.core.Direction;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.core.BlockSource;

public class ShulkerBoxDispenseBehavior extends OptionalDispenseItemBehavior {
    @Override
    protected ItemStack execute(final BlockSource fv, final ItemStack bki) {
        this.setSuccess(false);
        final Item bke4 = bki.getItem();
        if (bke4 instanceof BlockItem) {
            final Direction fz5 = fv.getBlockState().<Direction>getValue((Property<Direction>)DispenserBlock.FACING);
            final BlockPos fu6 = fv.getPos().relative(fz5);
            final Direction fz6 = fv.getLevel().isEmptyBlock(fu6.below()) ? fz5 : Direction.UP;
            this.setSuccess(((BlockItem)bke4).place(new DirectionalPlaceContext(fv.getLevel(), fu6, fz5, bki, fz6)).consumesAction());
        }
        return bki;
    }
}
