blob: d8539a6f9ad2d2a6ccd309c1fa1296969e54a8b8 (
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
|
package gregtech.common.render;
import fox.spiteful.avaritia.render.CosmicItemRenderer;
import java.util.*;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.oredict.OreDictionary;
public class CosmicItemRendererGT extends CosmicItemRenderer {
private static CosmicItemRendererGT sInstance = null;
public static HashMap<Item, List<Integer>> sCosmicItemRendererGtMapping = new HashMap<Item, List<Integer>>();
private static boolean sInit = false;
public static void registerItemWithMeta(Item aItem, List<Integer> aMeta) {
if (aItem != null) {
if (aMeta == null || aMeta.isEmpty()) {
ArrayList<Integer> aWildCard = new ArrayList<Integer>();
aWildCard.add(OreDictionary.WILDCARD_VALUE);
sCosmicItemRendererGtMapping.put(aItem, aWildCard);
} else {
sCosmicItemRendererGtMapping.put(aItem, aMeta);
}
}
}
public static void registerItemWithMeta(Item aItem, int aMeta) {
if (aItem != null) {
ArrayList<Integer> aSingleMeta = new ArrayList<Integer>();
aSingleMeta.add(aMeta);
sCosmicItemRendererGtMapping.put(aItem, aSingleMeta);
}
}
public static void init() {
if (sInstance == null) {
sInstance = new CosmicItemRendererGT();
}
if (!sInit) {
for (Item aItem : sCosmicItemRendererGtMapping.keySet()) {
MinecraftForgeClient.registerItemRenderer(aItem, sInstance);
}
sInit = true;
}
}
private boolean isSupported(ItemStack aStack) {
List<Integer> aMeta = sCosmicItemRendererGtMapping.get(aStack.getItem());
if (aMeta != null && !aMeta.isEmpty()) {
for (int meta : aMeta) {
if (meta == OreDictionary.WILDCARD_VALUE) {
return true;
} else {
if (aStack.getItemDamage() == meta) {
return true;
}
}
}
}
return false;
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
if (!isSupported(item)) {
return;
}
super.renderItem(type, item, data);
}
}
|