Files
TinkersConstruct/src/main/java/tconstruct/client/TProxyClient.java
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

130 lines
5.2 KiB
Java
Raw Normal View History

package tconstruct.client;
import java.io.InputStream;
import java.text.DecimalFormat;
2014-09-09 18:30:15 +10:00
import javax.xml.parsers.*;
2013-08-12 00:19:27 +10:00
import net.minecraft.client.Minecraft;
2014-02-05 10:28:54 -05:00
import net.minecraft.client.renderer.entity.RenderItem;
2014-09-09 18:30:15 +10:00
import net.minecraft.init.*;
2014-02-05 10:28:54 -05:00
import net.minecraft.item.ItemStack;
2014-09-09 18:30:15 +10:00
import net.minecraft.util.*;
import org.w3c.dom.Document;
2023-05-15 15:07:18 +09:00
import mantle.client.SmallFontRenderer;
import mantle.lib.client.MantleClientRegistry;
import tconstruct.TConstruct;
2014-07-06 22:59:44 -08:00
import tconstruct.armor.ArmorProxyClient;
import tconstruct.armor.player.TPlayerStats;
2014-02-05 10:28:54 -05:00
import tconstruct.common.TProxyCommon;
2014-06-04 21:44:48 -08:00
import tconstruct.tools.items.ManualInfo;
2014-10-29 22:33:00 +01:00
public class TProxyClient extends TProxyCommon {
public static DecimalFormat df = new DecimalFormat("##.#");
2014-06-30 14:57:06 -08:00
/* TODO: Split this class up into its respective parts */
2013-08-19 09:08:54 -07:00
public static SmallFontRenderer smallFontRenderer;
2013-12-31 11:26:08 -05:00
public static IIcon metalBall;
2013-08-19 09:08:54 -07:00
public static Minecraft mc;
public static RenderItem itemRenderer = new RenderItem();
2014-10-29 22:33:00 +01:00
public void initialize() {
2014-06-30 14:57:06 -08:00
registerRenderer();
readManuals();
}
2014-09-09 18:30:15 +10:00
2013-08-19 09:08:54 -07:00
/* Registers any rendering code. */
2014-10-29 22:33:00 +01:00
public void registerRenderer() {
2013-08-19 09:08:54 -07:00
Minecraft mc = Minecraft.getMinecraft();
smallFontRenderer = new SmallFontRenderer(
mc.gameSettings,
new ResourceLocation("textures/font/ascii.png"),
mc.renderEngine,
false);
2013-08-19 09:08:54 -07:00
}
public static Document diary;
public static Document volume1;
public static Document volume2;
public static Document smelter;
2014-10-29 22:33:00 +01:00
public static Document weaponry;
public static ManualInfo manualData;
2014-02-20 15:35:34 -05:00
2014-10-29 22:33:00 +01:00
public void readManuals() {
2013-08-19 09:08:54 -07:00
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
String CurrentLanguage = Minecraft.getMinecraft().getLanguageManager().getCurrentLanguage().getLanguageCode();
2014-10-29 22:33:00 +01:00
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);
Document weaponry_cl = readManual("/assets/tinker/manuals/" + CurrentLanguage + "/weaponry.xml", dbFactory);
diary = diary_cl != null ? diary_cl : readManual("/assets/tinker/manuals/en_US/diary.xml", dbFactory);
volume1 = volume1_cl != null ? volume1_cl : readManual("/assets/tinker/manuals/en_US/firstday.xml", dbFactory);
volume2 = volume2_cl != null ? volume2_cl : readManual("/assets/tinker/manuals/en_US/materials.xml", dbFactory);
smelter = smelter_cl != null ? smelter_cl : readManual("/assets/tinker/manuals/en_US/smeltery.xml", dbFactory);
weaponry = weaponry_cl != null ? weaponry_cl
: readManual("/assets/tinker/manuals/en_US/weaponry.xml", dbFactory);
2014-10-29 22:33:00 +01:00
initManualIcons();
2013-08-19 09:08:54 -07:00
initManualRecipes();
initManualPages();
manualData = new ManualInfo();
2013-08-19 09:08:54 -07:00
}
2014-10-29 22:33:00 +01:00
Document readManual(String location, DocumentBuilderFactory dbFactory) {
try {
2013-08-19 09:08:54 -07:00
InputStream stream = TConstruct.class.getResourceAsStream(location);
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(stream);
doc.getDocumentElement().normalize();
return doc;
2014-10-29 22:33:00 +01:00
} catch (Exception e) {
2013-08-19 09:08:54 -07:00
e.printStackTrace();
return null;
}
}
2014-10-29 22:33:00 +01:00
public void initManualIcons() {
2013-12-31 14:11:05 -05:00
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));
2013-12-13 23:14:46 -05:00
2013-12-31 14:11:05 -05:00
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));
2013-08-19 09:08:54 -07:00
}
public void initManualRecipes() {}
2013-08-19 09:08:54 -07:00
void initManualPages() {}
2013-08-19 09:08:54 -07:00
2014-10-29 22:33:00 +01:00
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;
2013-08-19 09:08:54 -07:00
}
return null;
}
2014-10-29 22:33:00 +01:00
public void recalculateHealth() {
2014-07-06 22:59:44 -08:00
ArmorProxyClient.armorExtended.recalculateHealth(mc.thePlayer, TPlayerStats.get(mc.thePlayer));
}
}