-
Notifications
You must be signed in to change notification settings - Fork 755
/
TConstructClientRegistry.java
173 lines (150 loc) · 6.19 KB
/
TConstructClientRegistry.java
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
package tconstruct.library.client;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.crafting.ToolBuilder;
import tconstruct.library.tools.ToolCore;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public class TConstructClientRegistry
{
public static ArrayList<ToolGuiElement> toolButtons = new ArrayList<ToolGuiElement>(20);
public static ArrayList<ToolGuiElement> tierTwoButtons = new ArrayList<ToolGuiElement>();
public static Map<String, ItemStack> manualIcons = new HashMap<String, ItemStack>();
public static Map<String, ItemStack[]> recipeIcons = new HashMap<String, ItemStack[]>();
public static ItemStack defaultStack = new ItemStack(Item.ingotIron);
public static void addMaterialRenderMapping (int materialID, String domain, String renderName, boolean useDefaultFolder)
{
for (ToolCore tool : TConstructRegistry.getToolMapping())
{
String[] toolIcons = new String[tool.getPartAmount() + 1];
for (int i = 0; i < tool.getPartAmount() + 1; i++)
{
String icon = domain + ":";
if (useDefaultFolder)
icon += tool.getDefaultFolder() + "/";
icon += renderName + tool.getIconSuffix(i);
toolIcons[i] = icon;
}
tool.registerPartPaths(materialID, toolIcons);
}
}
public static void addAlternateMaterialRenderMapping (ToolCore tool, int materialID, String domain, String renderName, boolean useDefaultFolder)
{
String[] toolIcons = new String[tool.getPartAmount() + 1];
for (int i = 0; i < tool.getPartAmount() + 1; i++)
{
String icon = domain + ":";
if (useDefaultFolder)
icon += tool.getDefaultFolder() + "/";
icon += renderName + tool.getIconSuffix(i);
toolIcons[i] = icon;
}
tool.registerAlternatePartPaths(materialID, toolIcons);
}
public static void addEffectRenderMapping (ToolCore tool, int materialID, String domain, String renderName, boolean useDefaultFolder)
{
String icon = domain + ":";
if (useDefaultFolder)
icon += tool.getDefaultFolder() + "/";
icon += renderName + tool.getEffectSuffix();
tool.registerEffectPath(materialID, icon);
}
public static void addEffectRenderMapping (int materialID, String domain, String renderName, boolean useDefaultFolder)
{
for (ToolCore tool : TConstructRegistry.getToolMapping())
{
String icon = domain + ":";
if (useDefaultFolder)
icon += tool.getDefaultFolder() + "/";
icon += renderName + tool.getEffectSuffix();
tool.registerEffectPath(materialID, icon);
}
}
public static void addSingleEffectRenderMapping (ToolCore tool, int materialID, String domain, String renderName, boolean useDefaultFolder)
{
String icon = domain + ":";
if (useDefaultFolder)
icon += tool.getDefaultFolder() + "/";
icon += renderName + tool.getEffectSuffix();
tool.registerEffectPath(materialID, icon);
}
public static void registerManualIcon (String name, ItemStack stack)
{
manualIcons.put(name, stack);
}
public static ItemStack getManualIcon (String textContent)
{
ItemStack stack = manualIcons.get(textContent);
if (stack != null)
return stack;
return defaultStack;
}
public static void registerManualSmallRecipe (String name, ItemStack output, ItemStack... stacks)
{
ItemStack[] recipe = new ItemStack[5];
recipe[0] = output;
System.arraycopy(stacks, 0, recipe, 1, 4);
recipeIcons.put(name, recipe);
}
public static void registerManualLargeRecipe (String name, ItemStack output, ItemStack... stacks)
{
ItemStack[] recipe = new ItemStack[10];
recipe[0] = output;
System.arraycopy(stacks, 0, recipe, 1, 9);
recipeIcons.put(name, recipe);
}
public static void registerManualFurnaceRecipe (String name, ItemStack output, ItemStack input)
{
ItemStack[] recipe = new ItemStack[2];
recipe[0] = output;
recipe[1] = input;
recipeIcons.put(name, recipe);
}
public static void registerManualModifier (String name, ItemStack output, ItemStack topinput)
{
registerManualModifier(name, output, topinput, null);
}
public static void registerManualModifier (String name, ItemStack output, ItemStack topinput, ItemStack bottominput)
{
ItemStack[] recipe = new ItemStack[3];
recipe[0] = ToolBuilder.instance.buildTool(output, topinput, bottominput, "");
recipe[1] = topinput;
recipe[2] = bottominput;
recipeIcons.put(name, recipe);
}
public static void registerManualSmeltery (String name, ItemStack output, ItemStack liquid, ItemStack cast)
{
ItemStack[] recipe = new ItemStack[3];
recipe[0] = output;
recipe[1] = liquid;
recipe[2] = cast;
recipeIcons.put(name, recipe);
}
public static ItemStack[] getRecipeIcons (String recipeName)
{
return recipeIcons.get(recipeName);
}
//Gui
public static void addToolButton (ToolGuiElement element)
{
toolButtons.add(element);
}
public static void addToolButton (int slotType, int xButton, int yButton, int[] xIcons, int[] yIcons, String title, String body, String domain, String texture)
{
toolButtons.add(new ToolGuiElement(slotType, xButton, yButton, xIcons, yIcons, title, body, domain, texture));
}
public static void addTierTwoButton (ToolGuiElement element)
{
tierTwoButtons.add(element);
}
public static void addTierTwoButton (int slotType, int xButton, int yButton, int[] xIcons, int[] yIcons, String title, String body, String domain, String texture)
{
tierTwoButtons.add(new ToolGuiElement(slotType, xButton, yButton, xIcons, yIcons, title, body, domain, texture));
}
public static ArrayList<ToolGuiElement> getToolButtons ()
{
return toolButtons;
}
}