-
Notifications
You must be signed in to change notification settings - Fork 755
/
TProxyClient.java
152 lines (129 loc) · 4.9 KB
/
TProxyClient.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
package tconstruct.client;
import java.io.InputStream;
import javax.xml.parsers.*;
import mantle.client.SmallFontRenderer;
import mantle.lib.client.MantleClientRegistry;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.init.*;
import net.minecraft.item.ItemStack;
import net.minecraft.util.*;
import org.w3c.dom.Document;
import tconstruct.TConstruct;
import tconstruct.armor.ArmorProxyClient;
import tconstruct.armor.player.TPlayerStats;
import tconstruct.common.TProxyCommon;
import tconstruct.tools.items.ManualInfo;
public class TProxyClient extends TProxyCommon
{
/* TODO: Split this class up into its respective parts */
public static SmallFontRenderer smallFontRenderer;
public static IIcon metalBall;
public static Minecraft mc;
public static RenderItem itemRenderer = new RenderItem();
public void initialize ()
{
registerRenderer();
readManuals();
}
/* Registers any rendering code. */
public void registerRenderer ()
{
Minecraft mc = Minecraft.getMinecraft();
smallFontRenderer = new SmallFontRenderer(mc.gameSettings, new ResourceLocation("textures/font/ascii.png"), mc.renderEngine, false);
}
public static Document diary;
public static Document volume1;
public static Document volume2;
public static Document smelter;
public static ManualInfo manualData;
public void readManuals ()
{
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
String CurrentLanguage = Minecraft.getMinecraft().getLanguageManager().getCurrentLanguage().getLanguageCode();
Document diary_cl = readManual("/assets/tinker/manuals/" + CurrentLanguage +"/diary.xml", dbFactory);
Document volume1_cl = readManual("/assets/tinker/manuals/" + CurrentLanguage + "/firstday.xml", dbFactory);
Document volume2_cl = readManual("/assets/tinker/manuals/" + CurrentLanguage + "/materials.xml", dbFactory);
Document smelter_cl = readManual("/assets/tinker/manuals/" + CurrentLanguage + "/smeltery.xml", dbFactory);
diary = readManual("/assets/tinker/manuals/en_US/diary.xml", dbFactory);
volume1 = readManual("/assets/tinker/manuals/en_US/firstday.xml", dbFactory);
volume2 = readManual("/assets/tinker/manuals/en_US/materials.xml", dbFactory);
smelter = readManual("/assets/tinker/manuals/en_US/smeltery.xml", dbFactory);
if(diary_cl != null)
{
diary = diary_cl;
}
if(volume1_cl != null)
{
volume1 = volume1_cl;
}
if(volume2_cl != null)
{
volume2 = volume2_c1;
}
if(smelter_cl != null)
{
smelter = smelter_cl;
}
initManualIcons();
initManualRecipes();
initManualPages();
manualData = new ManualInfo();
}
Document readManual (String location, DocumentBuilderFactory dbFactory)
{
try
{
InputStream stream = TConstruct.class.getResourceAsStream(location);
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(stream);
doc.getDocumentElement().normalize();
return doc;
}
catch (Exception e)
{
e.printStackTrace();
return null;
}
}
public void initManualIcons ()
{
MantleClientRegistry.registerManualIcon("torch", new ItemStack(Blocks.torch));
MantleClientRegistry.registerManualIcon("sapling", new ItemStack(Blocks.sapling));
MantleClientRegistry.registerManualIcon("workbench", new ItemStack(Blocks.crafting_table));
MantleClientRegistry.registerManualIcon("coal", new ItemStack(Items.coal));
MantleClientRegistry.registerManualIcon("woodplanks", new ItemStack(Blocks.planks));
MantleClientRegistry.registerManualIcon("stoneblock", new ItemStack(Blocks.stone));
MantleClientRegistry.registerManualIcon("ironingot", new ItemStack(Items.iron_ingot));
MantleClientRegistry.registerManualIcon("flint", new ItemStack(Items.flint));
MantleClientRegistry.registerManualIcon("cactus", new ItemStack(Blocks.cactus));
MantleClientRegistry.registerManualIcon("bone", new ItemStack(Items.bone));
MantleClientRegistry.registerManualIcon("obsidian", new ItemStack(Blocks.obsidian));
MantleClientRegistry.registerManualIcon("netherrack", new ItemStack(Blocks.netherrack));
}
public void initManualRecipes ()
{
}
void initManualPages ()
{
}
public static Document getManualFromStack (ItemStack stack)
{
switch (stack.getItemDamage())
{
case 0:
return volume1;
case 1:
return volume2;
case 2:
return smelter;
case 3:
return diary;
}
return null;
}
public void recalculateHealth ()
{
ArmorProxyClient.armorExtended.recalculateHealth(mc.thePlayer, TPlayerStats.get(mc.thePlayer));
}
}