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> sCosmicItemRendererGtMapping = new HashMap>(); private static boolean sInit = false; public static void registerItemWithMeta(Item aItem, List aMeta) { if (aItem != null) { if (aMeta == null || aMeta.isEmpty()) { ArrayList aWildCard = new ArrayList(); 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 aSingleMeta = new ArrayList(); 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 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); } }