package net.minecraft.world.item;

import com.google.common.collect.Maps;
import net.minecraft.world.entity.animal.Sheep;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import java.util.Map;

public class DyeItem extends Item {
    private static final Map<DyeColor, DyeItem> ITEM_BY_COLOR;
    private final DyeColor dyeColor;
    
    public DyeItem(final DyeColor bje, final Properties a) {
        super(a);
        this.dyeColor = bje;
        DyeItem.ITEM_BY_COLOR.put(bje, this);
    }
    
    @Override
    public InteractionResult interactLivingEntity(final ItemStack bki, final Player bec, final LivingEntity aoy, final InteractionHand anf) {
        if (aoy instanceof Sheep) {
            final Sheep azd6 = (Sheep)aoy;
            if (azd6.isAlive() && !azd6.isSheared() && azd6.getColor() != this.dyeColor) {
                if (!bec.level.isClientSide) {
                    azd6.setColor(this.dyeColor);
                    bki.shrink(1);
                }
                return InteractionResult.sidedSuccess(bec.level.isClientSide);
            }
        }
        return InteractionResult.PASS;
    }
    
    public DyeColor getDyeColor() {
        return this.dyeColor;
    }
    
    public static DyeItem byColor(final DyeColor bje) {
        return DyeItem.ITEM_BY_COLOR.get(bje);
    }
    
    static {
        ITEM_BY_COLOR = Maps.<DyeColor, Object>newEnumMap(DyeColor.class);
    }
}
