aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gregtech/api/enums/TAE.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/Java/gregtech/api/enums/TAE.java')
-rw-r--r--src/Java/gregtech/api/enums/TAE.java79
1 files changed, 54 insertions, 25 deletions
diff --git a/src/Java/gregtech/api/enums/TAE.java b/src/Java/gregtech/api/enums/TAE.java
index 2827704f62..d7e16feb09 100644
--- a/src/Java/gregtech/api/enums/TAE.java
+++ b/src/Java/gregtech/api/enums/TAE.java
@@ -1,10 +1,14 @@
package gregtech.api.enums;
import java.lang.reflect.Field;
+import java.util.HashMap;
+import java.util.HashSet;
import gregtech.api.interfaces.ITexture;
import gregtech.api.objects.GT_CopiedBlockTexture;
import gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.api.objects.data.AutoMap;
+import gtPlusPlus.core.block.ModBlocks;
import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.util.Utils;
import gtPlusPlus.core.util.reflect.ReflectionUtils;
@@ -13,40 +17,65 @@ public class TAE {
//TAE stands for Texture Array Expansion.
- public static int gtTexturesArrayStartOrigin;
public static int gtPPLastUsedIndex = 64;
public static int secondaryIndex = 0;
- public static boolean hasArrayBeenExpanded = false;
+
+ public static HashMap<Integer, GT_CopiedBlockTexture> mTAE = new HashMap<Integer, GT_CopiedBlockTexture>();
+ private static final HashSet<Integer> mFreeSlots = new HashSet<Integer>(64);
+
+ static {
+ for (int i=64;i<128;i++) {
+ mFreeSlots.add(i);
+ }
+ Logger.INFO("Initialising TAE.");
+ }
- public static boolean hookGtTextures() {
- /*ITexture[] textureArrayDump = Textures.BlockIcons.CASING_BLOCKS;
- ITexture[] newTextureArray = new ITexture[1024];
- Utils.LOG_INFO("|======| Texture Array Start Length: "+textureArrayDump.length+" |======|");
- for (int r=0;r<textureArrayDump.length;r++){
- if (textureArrayDump[r] == null){
- Utils.LOG_WARNING("Texture slot "+r+" is empty.");
+ /**
+ *
+ * @param aPage - The Texture page (0-3)
+ * @param aID - The ID on the specified page (0-15)
+ * @param gt_CopiedBlockTexture - The Texture to register
+ * @return - Did it register correctly?
+ */
+ public static boolean registerTexture(int aPage, int aID, GT_CopiedBlockTexture gt_CopiedBlockTexture) {
+ int aRealID = aID + (aPage * 16);
+ return registerTexture(64 + aRealID, gt_CopiedBlockTexture);
+ }
+
+ private static boolean registerTexture(int aID, GT_CopiedBlockTexture gt_CopiedBlockTexture) {
+ if (mFreeSlots.contains(aID)) {
+ mFreeSlots.remove(aID);
+ mTAE.put(aID, gt_CopiedBlockTexture);
+ return true;
+ }
+ else {
+ CORE.crash("Tried to register texture with ID "+aID+" to TAE, but it is already in use.");
+ return false; // Dead Code
+ }
+ }
+
+ public static void finalizeTAE() {
+ String aFreeSpaces = "";
+ AutoMap<Integer> aTemp = new AutoMap<Integer>(mFreeSlots);
+ for (int i = 0; i < mFreeSlots.size() ; i++) {
+ aFreeSpaces += aTemp.get(i);
+ if (i != (mFreeSlots.size() - 1)) {
+ aFreeSpaces += ", ";
}
}
- gtTexturesArrayStartOrigin = textureArrayDump.length;
- System.arraycopy(textureArrayDump, 0, newTextureArray, 0, textureArrayDump.length);
- Textures.BlockIcons.CASING_BLOCKS = newTextureArray;
- if (Textures.BlockIcons.CASING_BLOCKS.length == 1024){
- hasArrayBeenExpanded = true;
+ Logger.INFO("Free Indexes within TAE: "+aFreeSpaces);
+ Logger.INFO("Filling them with ERROR textures.");
+ for (int aFreeSlot : aTemp.values()) {
+ registerTexture(aFreeSlot, new GT_CopiedBlockTexture(ModBlocks.blockCasingsTieredGTPP, 1, 15));
}
- else {
- hasArrayBeenExpanded = false;
+ Logger.INFO("Finalising TAE.");
+ for (int aKeyTae : mTAE.keySet()) {
+ Textures.BlockIcons.CASING_BLOCKS[aKeyTae] = mTAE.get(aKeyTae);
}
- return hasArrayBeenExpanded;*/
- return true;
+ Logger.INFO("Finalised TAE.");
}
- /*public static boolean registerTextures(GT_RenderedTexture textureToRegister) {
- Textures.BlockIcons.CASING_BLOCKS[gtPPLastUsedIndex] = textureToRegister;
- //Just so I know registration is done.
- return true;
- }*/
-
- public static boolean registerTextures(GT_CopiedBlockTexture gt_CopiedBlockTexture) {
+ private static boolean registerTextures(GT_CopiedBlockTexture gt_CopiedBlockTexture) {
try {
//Handle page 2.
Logger.INFO("[TAE} Registering Texture, Last used casing ID is "+gtPPLastUsedIndex+".");