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

131 lines
4.3 KiB
Java
Raw Normal View History

package tconstruct.client;
import java.io.InputStream;
2013-12-13 23:14:46 -05:00
2014-02-05 10:28:54 -05:00
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
2013-12-13 23:14:46 -05:00
import mantle.client.SmallFontRenderer;
2013-12-13 23:14:46 -05:00
import mantle.lib.client.MantleClientRegistry;
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;
2013-12-31 14:11:05 -05:00
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
2014-02-05 10:28:54 -05:00
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
2013-12-13 23:14:46 -05:00
import org.w3c.dom.Document;
2013-12-13 23:14:46 -05:00
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;
2013-08-19 09:08:54 -07:00
public class TProxyClient extends TProxyCommon
{
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-06-30 14:57:06 -08:00
public void initialize()
{
registerRenderer();
readManuals();
}
2013-08-19 09:08:54 -07:00
/* Registers any rendering code. */
public void registerRenderer ()
{
Minecraft mc = Minecraft.getMinecraft();
2013-09-20 18:55:24 -04:00
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;
public static ManualInfo manualData;
2014-02-20 15:35:34 -05:00
2013-08-19 09:08:54 -07:00
public void readManuals ()
{
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
diary = readManual("/assets/tinker/manuals/diary.xml", dbFactory);
volume1 = readManual("/assets/tinker/manuals/firstday.xml", dbFactory);
volume2 = readManual("/assets/tinker/manuals/materials.xml", dbFactory);
smelter = readManual("/assets/tinker/manuals/smeltery.xml", dbFactory);
initManualIcons();
initManualRecipes();
initManualPages();
manualData = new ManualInfo();
2013-08-19 09:08:54 -07:00
}
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 ()
{
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 ()
{
}
void initManualPages ()
{
2013-12-13 23:14:46 -05:00
2013-08-19 09:08:54 -07: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;
}
return null;
}
public void recalculateHealth ()
{
2014-07-06 22:59:44 -08:00
ArmorProxyClient.armorExtended.recalculateHealth(mc.thePlayer, TPlayerStats.get(mc.thePlayer));
}
}