package net.minecraft.world.item;

import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.ItemLike;
import net.minecraft.world.level.block.DispenserBlock;

public class ElytraItem extends Item implements Wearable {
    public ElytraItem(final Properties a) {
        super(a);
        DispenserBlock.registerBehavior(this, ArmorItem.DISPENSE_ITEM_BEHAVIOR);
    }
    
    public static boolean isFlyEnabled(final ItemStack bki) {
        return bki.getDamageValue() < bki.getMaxDamage() - 1;
    }
    
    @Override
    public boolean isValidRepairItem(final ItemStack bki1, final ItemStack bki2) {
        return bki2.getItem() == Items.PHANTOM_MEMBRANE;
    }
    
    @Override
    public InteractionResultHolder<ItemStack> use(final Level bqb, final Player bec, final InteractionHand anf) {
        final ItemStack bki5 = bec.getItemInHand(anf);
        final EquipmentSlot aor6 = Mob.getEquipmentSlotForItem(bki5);
        final ItemStack bki6 = bec.getItemBySlot(aor6);
        if (bki6.isEmpty()) {
            bec.setItemSlot(aor6, bki5.copy());
            bki5.setCount(0);
            return InteractionResultHolder.<ItemStack>sidedSuccess(bki5, bqb.isClientSide());
        }
        return InteractionResultHolder.<ItemStack>fail(bki5);
    }
}
