blob: 333939d80044a3ac5a593b1a1e1daa9129d929ca (
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
package gtPlusPlus.xmod.gregtech.common.helpers;
import java.util.HashMap;
import gregtech.api.enums.OrePrefixes;
import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Utility;
import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.material.Material;
import gtPlusPlus.core.util.data.AES;
import gtPlusPlus.xmod.gregtech.api.enums.CustomOrePrefix;
import net.minecraft.item.ItemStack;
public class FlotationRecipeHandler {
private static HashMap<String, Material> sMaterialMap = new HashMap<String, Material>();
private static HashMap<String, ItemStack> sMilledMap = new HashMap<String, ItemStack>();
private static final AES sEncodingHandler = new AES();
public static boolean registerOreType(Material aMaterial) {
String aMaterialKey = sEncodingHandler.encode(aMaterial.getUnlocalizedName());
if (sMaterialMap.containsKey(aMaterialKey)) {
CORE.crash("Tried to register a Flotation material to an ID already in use. ID: "+aMaterialKey);
return false;
}
else {
sMaterialMap.put(aMaterialKey, aMaterial);
sMilledMap.put(aMaterialKey, aMaterial.getMilled(1));
}
return true;
}
public static int getHashForMaterial(Material aMaterial) {
return getMaterialsID(aMaterial).hashCode();
}
public static String getMaterialsID(Material aMaterial) {
for (String aKey : sMaterialMap.keySet()) {
if (sMaterialMap.get(aKey).equals(aMaterial)) {
return aKey;
}
}
return "BAD_MATERIAL_ID";
}
public static Material getMaterialOfMilledProduct(ItemStack aMilled) {
for (String aKey : sMilledMap.keySet()) {
ItemStack aTempMilledStack = sMilledMap.get(aKey);
if (GT_Utility.areStacksEqual(aTempMilledStack, aMilled, true)) {
return sMaterialMap.get(aKey);
}
}
return null;
}
public static ItemStack findMilledStack(GT_Recipe aRecipe) {
if (aRecipe == null || aRecipe.mInputs == null || aRecipe.mInputs.length <= 0) {
return null;
}
return findMilledStack(aRecipe.mInputs);
}
public static ItemStack findMilledStack(ItemStack[] aInputs) {
if (aInputs == null || aInputs.length <= 0) {
return null;
}
for (ItemStack aStack : aInputs) {
if (CustomOrePrefix.milled.get().contains(aStack)) {
return aStack;
}
}
return null;
}
public static AES getEncoder() {
return sEncodingHandler;
}
}
|