package net.minecraft.world.item;

import net.minecraft.stats.Stat;
import net.minecraft.stats.Stats;
import net.minecraft.util.Mth;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;

public class EmptyMapItem extends ComplexItem {
    public EmptyMapItem(final Properties a) {
        super(a);
    }
    
    @Override
    public InteractionResultHolder<ItemStack> use(final Level bjw, final Player ayj, final InteractionHand ajk) {
        final ItemStack ben5 = MapItem.create(bjw, Mth.floor(ayj.getX()), Mth.floor(ayj.getZ()), (byte)0, true, false);
        final ItemStack ben6 = ayj.getItemInHand(ajk);
        if (!ayj.abilities.instabuild) {
            ben6.shrink(1);
        }
        if (ben6.isEmpty()) {
            return InteractionResultHolder.<ItemStack>success(ben5);
        }
        if (!ayj.inventory.add(ben5.copy())) {
            ayj.drop(ben5, false);
        }
        ayj.awardStat(Stats.ITEM_USED.get(this));
        return InteractionResultHolder.<ItemStack>success(ben6);
    }
}
