@Nonnull private static List<TextureDetails> getIcons(Block block, int meta, ItemBlock itemBlock) { TextureDetails any = null; TextureDetails top = null; TextureDetails side = null; int col = itemBlock.getColorFromItemStack(new ItemStack(itemBlock, 1, meta), 0); TextureDetails[] icons = new TextureDetails[6]; for (int s = 0; s < 6; s++) { String iconName = null; if (meta == OreDictionary.WILDCARD_VALUE) { for (int i = 0; i < 16; i++) { try { iconName = getIconName(block.getIcon(s, meta)); } catch (Throwable err) { continue; } if (iconName != null) break; } } else try { iconName = getIconName(block.getIcon(s, meta)); } catch (Throwable err) { continue; } if (iconName == null) continue; TextureDetails textureDetails = TextureDetails.createTextureDetails(iconName, col, 0); icons[s] = textureDetails; if (any == null) any = textureDetails; if (s < 2) { if (top == null) top = textureDetails; } else { if (side == null) side = textureDetails; } } if (any == null) return ImmutableList.of(); for (int i = 0; i < icons.length; i++) { if (icons[i] != null) continue; if (i < 2 && top != null) icons[i] = top; else if (i >= 2 && side != null) icons[i] = side; else icons[i] = any; } return Lists.newArrayList(icons); }
@Nonnull private static List<TextureDetails> getIcon(Item item, int meta) { String iconName = null; int col = 0xffffffff; if (meta != OreDictionary.WILDCARD_VALUE) { try { ItemStack stack = new ItemStack(item, 1, meta); iconName = getIconName(item.getIcon(stack, 0)); col = item.getColorFromItemStack(stack, 0); } catch (Throwable ignore) { } } if (iconName == null) { for (ItemStack itemStack : TinkersTailor.proxy.addVariants(item, new ArrayList<ItemStack>())) { try { iconName = getIconName(item.getIcon(itemStack, 0)); col = item.getColorFromItemStack(itemStack, 0); } catch (Throwable ignore) { } if (iconName != null) break; } } if (iconName == null) { try { ItemStack stack = new ItemStack(item); iconName = getIconName(item.getIcon(stack, 0)); col = item.getColorFromItemStack(stack, 0); } catch (Throwable ignore) { } } if (iconName == null) return ImmutableList.of(); return Lists.newArrayList(TextureDetails.createTextureDetails(iconName, col, 1)); }