aboutsummaryrefslogtreecommitdiff
path: root/src/Java/miscutil/core/util/Utils.java
blob: 00acfba45fddc12721d48473a8698b1f36cee537 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package miscutil.core.util;

import java.awt.Graphics;

import miscutil.core.lib.Strings;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.common.FMLLog;

public class Utils {

	public static final int WILDCARD_VALUE = Short.MAX_VALUE;
    public static boolean containsMatch(boolean strict, ItemStack[] inputs, ItemStack... targets)
    {
        for (ItemStack input : inputs)
        {
            for (ItemStack target : targets)
            {
                if (itemMatches(target, input, strict))
                {
                    return true;
                }
            }
        }
        return false;
    }

    public static boolean itemMatches(ItemStack target, ItemStack input, boolean strict)
    {
        if (input == null && target != null || input != null && target == null)
        {
            return false;
        }
        return (target.getItem() == input.getItem() && ((target.getItemDamage() == WILDCARD_VALUE && !strict) || target.getItemDamage() == input.getItemDamage()));
    }
    
    //Non-Dev Comments 
    public static void LOG_INFO(String s){
    	//if (Strings.DEBUG){
			FMLLog.info("MiscUtils: "+s);
		//}
    }
    
    //Developer Comments
    public static void LOG_WARNING(String s){
    	if (Strings.DEBUG){
			FMLLog.warning("MiscUtils: "+s);
		}
    }
    
    //Errors
    public static void LOG_ERROR(String s){
    	if (Strings.DEBUG){
			FMLLog.severe("MiscUtils: "+s);
		}
    }
    
    public static void paintBox(Graphics g, int MinA, int MinB, int MaxA, int MaxB){
    	    g.drawRect (MinA, MinB, MaxA, MaxB);  
    }
    
}