blob: 3ec018b3a1f335a58485bd0fd5c86ab65c135356 (
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
package gregtech.api.enums;
import java.lang.reflect.Field;
import gregtech.api.interfaces.ITexture;
import gregtech.api.objects.GT_CopiedBlockTexture;
import gtPlusPlus.api.objects.Logger;
import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.util.Utils;
import gtPlusPlus.core.util.reflect.ReflectionUtils;
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 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.");
}
}
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;
}
else {
hasArrayBeenExpanded = false;
}
return hasArrayBeenExpanded;*/
return true;
}
/*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) {
try {
//Handle page 2.
Logger.INFO("[TAE} Registering Texture, Last used casing ID is "+gtPPLastUsedIndex+".");
if (gtPPLastUsedIndex >= 128) {
if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && Utils.getGregtechSubVersion() > 30) {
Field x = ReflectionUtils.getField(Textures.BlockIcons.class, "casingTexturePages");
if (x != null) {
ITexture[][] h = (ITexture[][]) x.get(null);
if (h != null) {
h[64][secondaryIndex++] = gt_CopiedBlockTexture;
x.set(null, h);
Logger.INFO("[TAE} Registered Texture with ID "+(secondaryIndex-1)+" in secondary index.");
return true;
}
}
}
}
//set to page 1.
else {
Textures.BlockIcons.CASING_BLOCKS[gtPPLastUsedIndex] = gt_CopiedBlockTexture;
Logger.INFO("[TAE} Registered Texture with ID "+(gtPPLastUsedIndex)+" in main index.");
gtPPLastUsedIndex++;
return true;
}
}
catch (Throwable t) {
t.printStackTrace();
}
Logger.INFO("[TAE} Failed to register texture, Last used casing ID is "+gtPPLastUsedIndex+".");
return false;
}
public static ITexture getTexture(int index){
if (gtPPLastUsedIndex >= 128) {
if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && Utils.getGregtechSubVersion() > 30) {
return Textures.BlockIcons.CASING_BLOCKS[((64*128)+index)];
}
}
return Textures.BlockIcons.CASING_BLOCKS[(64+index)];
}
public static int GTPP_INDEX(int ID){
if (gtPPLastUsedIndex >= 128) {
if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && Utils.getGregtechSubVersion() > 30) {
return (ID);
}
}
return (64+ID);
}
public static int getIndexFromPage(int page, int blockMeta) {
int id = 64;
id += (page == 0 ? 0 : page == 1 ? 16 : page == 2 ? 32 : page == 3 ? 48 : page == 4 ? 64 : 0);
id += blockMeta;
return id;
}
}
|