package net.minecraft.world.item;

import com.google.common.collect.Maps;
import net.minecraft.world.entity.animal.Sheep;
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 bdj, final Properties a) {
        super(a);
        this.dyeColor = bdj;
        DyeItem.ITEM_BY_COLOR.put(bdj, this);
    }
    
    @Override
    public boolean interactEnemy(final ItemStack ben, final Player ayj, final LivingEntity akz, final InteractionHand ajk) {
        if (akz instanceof Sheep) {
            final Sheep atv6 = (Sheep)akz;
            if (atv6.isAlive() && !atv6.isSheared() && atv6.getColor() != this.dyeColor) {
                atv6.setColor(this.dyeColor);
                ben.shrink(1);
            }
            return true;
        }
        return false;
    }
    
    public DyeColor getDyeColor() {
        return this.dyeColor;
    }
    
    public static DyeItem byColor(final DyeColor bdj) {
        return DyeItem.ITEM_BY_COLOR.get(bdj);
    }
    
    static {
        ITEM_BY_COLOR = Maps.<DyeColor, Object>newEnumMap(DyeColor.class);
    }
}
