blob: 271b361da03517cd4f1c14dc0afa91acaae97647 (
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 gregtech.api.util;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
public class GT_ToolHarvestHelper {
public static boolean isAppropriateTool(Block aBlock, byte aMetaData, String... tTools) {
if (aBlock == null || tTools == null) {
return false;
}
String targetTool = aBlock.getHarvestTool(aMetaData);
return !isStringEmpty(targetTool) && isArrayContains(targetTool, tTools);
}
public static boolean isAppropriateMaterial(Block aBlock, Material... tMats) {
if (aBlock == null || tMats == null) {
return false;
}
return isArrayContains(aBlock.getMaterial(), tMats);
}
public static boolean isSpecialBlock(Block aBlock, Block... tBlocks) {
if (aBlock == null || tBlocks == null) {
return false;
}
return isArrayContains(aBlock, tBlocks);
}
public static <T> boolean isArrayContains(T obj, T[] list) {
if (obj == null || list == null) {
return false;
}
for (T iObj : list) {
if (obj == iObj || obj.equals(iObj)) {
return true;
}
}
return false;
}
public static boolean isStringEmpty(String s) {
return s == null || s.length() == 0;
}
public static boolean hasNull(Object... obj) {
for (Object iObj : obj) {
if (iObj == null) {
return true;
}
}
return false;
}
}
|