TinkersConstruct/tinker/tconstruct/TConstructRegistry.java
2013-01-31 02:55:09 -08:00

84 lines
2.3 KiB
Java

package tinker.tconstruct;
import java.util.ArrayList;
import java.util.HashMap;
import tinker.tconstruct.client.gui.ToolGuiElement;
import tinker.tconstruct.tools.ToolCore;
/** A registry to store any relevant API work
*
* @author mDiyo
*/
public class TConstructRegistry
{
public static TConstructRegistry instance = new TConstructRegistry();
public static ArrayList<ToolCore> tools = new ArrayList<ToolCore>(20);
public static ArrayList<ToolGuiElement> toolButtons = new ArrayList<ToolGuiElement>(20);
public static HashMap<Integer, ToolMaterial> toolMaterials = new HashMap<Integer, ToolMaterial>(60);
/* Mappings */
public static void addToolMapping(ToolCore tool)
{
tools.add(tool);
}
//Tools
public static ArrayList<ToolCore> getToolMapping()
{
return tools;
}
//Rendering
public static void addMaterialRenderMapping(int materialID, String textureLocation)
{
for (ToolCore tool : TConstructRegistry.getToolMapping())
{
tool.partTextures.put(materialID, textureLocation);
}
}
public static void addEffectRenderMapping(int materialID, String textureLocation)
{
for (ToolCore tool : TConstructRegistry.getToolMapping())
{
tool.effectTextures.put(materialID, textureLocation);
}
}
//Materials
public static void addToolMaterial(int materialID, String materialName, int craftingTier, int harvestLevel,
int durability, int miningspeed, int attack, float handleModifier, int reinforced, float shoddy)
{
ToolMaterial mat = toolMaterials.get(materialID);
if (mat == null)
{
toolMaterials.put(materialID, new ToolMaterial(materialName, craftingTier, harvestLevel, durability, miningspeed, attack, handleModifier, reinforced, shoddy));
}
else
throw new RuntimeException("TConstruct material ID "+materialID+" is already occupied by "+mat.materialName);
}
public static ToolMaterial getMaterial(int key)
{
return (toolMaterials.get(key));
}
//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 texture)
{
toolButtons.add(new ToolGuiElement(slotType, xButton, yButton, xIcons, yIcons, title, body, texture));
}
public static ArrayList<ToolGuiElement> getToolButtons()
{
return toolButtons;
}
}