MCPcopy Create free account
hub / github.com/GregTech6/gregtech6 / TextureSet

Class TextureSet

src/main/java/gregapi/render/TextureSet.java:37–230  ·  view source on GitHub ↗

@author Gregorius Techneticies

Source from the content-addressed store, hash-verified

35 * @author Gregorius Techneticies
36 */
37public class TextureSet {
38 public static final List<TextureSet> INSTANCES_ITEM = new ArrayListNoNulls<>();
39 public static final List<TextureSet> INSTANCES_BLOCK = new ArrayListNoNulls<>();
40 public static final List<String> FILENAMES_ITEM = new ArrayListNoNulls<>();
41 public static final List<String> FILENAMES_BLOCK = new ArrayListNoNulls<>();
42 public final List<IIconContainer> mList = new ArrayListNoNulls<>();
43
44 private final boolean mIsItem;
45 private final String mNameSet;
46
47 private TextureSet(boolean aIsItem, String aNameSet) {
48 mIsItem = aIsItem;
49 mNameSet = aNameSet;
50 }
51
52 /**
53 * Adds a new Texture Set, unless another Set with the same Name already exists.
54 * @param aModID the Mod responsible for adding the Icons (which are located in either assets\aModID.toLowerCase()\textures\items\materialicons\ or assets\aModID.toLowerCase()\textures\blocks\materialicons\).
55 * @param aIsItem true if this is an Item Icon, false if this is a Block Icon.
56 */
57 public static TextureSet addTextureSet(String aModID, boolean aIsItem, String aNameSet) {
58 List<TextureSet> tTextureSetList = (aIsItem?INSTANCES_ITEM:INSTANCES_BLOCK);
59 List<String> tFileNameList = (aIsItem?FILENAMES_ITEM:FILENAMES_BLOCK);
60 for (TextureSet tSet : tTextureSetList) if (tSet.mNameSet.equals(aNameSet)) return tSet;
61 TextureSet rSet = new TextureSet(aIsItem, aNameSet);
62 tTextureSetList.add(rSet);
63 for (int i = 0, j = tFileNameList.size(); i < j; i++) rSet.mList.add(aIsItem?new TextureSetIconItem(aModID, aNameSet+"/"+tFileNameList.get(i)):new TextureSetIconBlock(aModID, aNameSet+"/"+tFileNameList.get(i)));
64 return rSet;
65 }
66
67 /**
68 * Adds a new Icon Name to all Texture Sets, or just returns the Index of an already existing Set with the same File Name.
69 * @param aModID the Mod responsible for adding the Icons (which are located in either assets\aModID.toLowerCase()\textures\items\materialicons\ or assets\aModID.toLowerCase()\textures\blocks\materialicons\).
70 * @param aNameFile the Name of the File inside each Set Folder.
71 * @return the Index of this Icon inside the Set Lists.
72 */
73 public static int addToAll(String aModID, boolean aIsItem, String aNameFile) {
74 List<String> tFileNameList = (aIsItem?FILENAMES_ITEM:FILENAMES_BLOCK);
75 int tIndex = tFileNameList.indexOf(aNameFile);
76 if (tIndex >= 0) return tIndex;
77 tFileNameList.add(aNameFile);
78 for (TextureSet tSet : (aIsItem?INSTANCES_ITEM:INSTANCES_BLOCK)) tSet.mList.add(tSet.mIsItem?new TextureSetIconItem(aModID, tSet.mNameSet+"/"+aNameFile):new TextureSetIconBlock(aModID, tSet.mNameSet+"/"+aNameFile));
79 return tFileNameList.size() - 1;
80 }
81
82 public static class TextureSetIconItem implements IIconContainer, Runnable {
83 private final String mMod, mName;
84 private IIcon mIconColored, mIconOverlay;
85
86 public TextureSetIconItem(String aMod, String aName) {
87 mName = aName;
88 mMod = aMod.toLowerCase();
89 if (GT_API.sItemIconload != null) GT_API.sItemIconload.add(this);
90 }
91
92 @Override
93 public IIcon getIcon(int aRenderPass) {
94 return aRenderPass == 0 ? mIconColored : mIconOverlay;

Callers

nothing calls this directly

Calls 1

addTextureSetMethod · 0.95

Tested by

no test coverage detected