diff --git a/mechanical/src/main/java/resonantinduction/mechanical/energy/grid/EnergyNode.java b/mechanical/src/main/java/resonantinduction/mechanical/energy/grid/EnergyNode.java
deleted file mode 100644
index 0db690689..000000000
--- a/mechanical/src/main/java/resonantinduction/mechanical/energy/grid/EnergyNode.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package resonantinduction.mechanical.energy.grid;
-
-import resonantinduction.core.grid.Grid;
-import resonantinduction.core.grid.INodeProvider;
-import resonantinduction.core.grid.Node;
-
-public abstract class EnergyNode
extends Node
-{
- public EnergyNode(P parent)
- {
- super(parent);
- }
-
- /**
- * @return Gets the power of this node. Note that power by definition is energy per second.
- */
- public abstract double getPower();
-
- /**
- * @return Gets the energy buffered in this node at this instance.
- */
- public abstract double getEnergy();
-}
diff --git a/mechanical/src/main/java/resonantinduction/mechanical/energy/grid/IEnergyNode.java b/mechanical/src/main/java/resonantinduction/mechanical/energy/grid/IEnergyNode.java
new file mode 100644
index 000000000..7997af886
--- /dev/null
+++ b/mechanical/src/main/java/resonantinduction/mechanical/energy/grid/IEnergyNode.java
@@ -0,0 +1,14 @@
+package resonantinduction.mechanical.energy.grid;
+
+public interface IEnergyNode
+{
+ /**
+ * @return Gets the power of this node. Note that power by definition is energy per second.
+ */
+ public double getPower();
+
+ /**
+ * @return Gets the energy buffered in this node at this instance.
+ */
+ public double getEnergy();
+}
diff --git a/mechanical/src/main/java/resonantinduction/mechanical/energy/grid/IMechanicalNode.java b/mechanical/src/main/java/resonantinduction/mechanical/energy/grid/IMechanicalNode.java
new file mode 100644
index 000000000..c569dac40
--- /dev/null
+++ b/mechanical/src/main/java/resonantinduction/mechanical/energy/grid/IMechanicalNode.java
@@ -0,0 +1,16 @@
+package resonantinduction.mechanical.energy.grid;
+
+import net.minecraftforge.common.ForgeDirection;
+
+public interface IMechanicalNode extends IEnergyNode
+{
+ public double getTorque();
+
+ public double getAngularVelocity();
+
+ public void apply(double torque, double angularVelocity);
+
+ public float getRatio(ForgeDirection dir, MechanicalNode with);
+
+ public boolean inverseRotation(ForgeDirection dir, MechanicalNode with);
+}
diff --git a/mechanical/src/main/java/resonantinduction/mechanical/energy/grid/MechanicalNode.java b/mechanical/src/main/java/resonantinduction/mechanical/energy/grid/MechanicalNode.java
index fa5b02f40..e7d357fb1 100644
--- a/mechanical/src/main/java/resonantinduction/mechanical/energy/grid/MechanicalNode.java
+++ b/mechanical/src/main/java/resonantinduction/mechanical/energy/grid/MechanicalNode.java
@@ -9,6 +9,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import resonantinduction.core.ResonantInduction;
import resonantinduction.core.grid.INodeProvider;
+import resonantinduction.core.grid.Node;
import resonantinduction.core.grid.TickingGrid;
import universalelectricity.api.vector.Vector3;
import codechicken.multipart.TMultiPart;
@@ -29,7 +30,7 @@ import codechicken.multipart.TMultiPart;
*
* @author Calclavia
*/
-public class MechanicalNode extends EnergyNode
+public class MechanicalNode extends Node implements IMechanicalNode
{
public double torque = 0;
public double prevAngularVelocity, angularVelocity = 0;
@@ -148,27 +149,32 @@ public class MechanicalNode extends EnergyNode> recipes = new HashMap>();
+ private final Map> recipes = new HashMap>();
- public static final MachineRecipes INSTANCE = new MachineRecipes();
+ public static MachineRecipes INSTANCE = new MachineRecipes();
- private MachineRecipes()
- {
- for (RecipeType machine : RecipeType.values())
- {
- this.recipes.put(machine, new HashMap());
- }
- }
+ public MachineRecipes()
+ {
+ for (RecipeType machine : RecipeType.values())
+ {
+ recipes.put(machine, new HashMap());
+ }
+ }
- public RecipeResource getResourceFromObject(Object obj)
- {
- if (obj instanceof String)
- return new OreDictResource((String) obj);
-
- if (obj instanceof Block)
- return new ItemStackResource(new ItemStack((Block) obj));
-
- if (obj instanceof Item)
- return new ItemStackResource(new ItemStack((Item) obj));
-
- if (obj instanceof ItemStack)
- return new ItemStackResource((ItemStack) obj);
+ public RecipeResource getResourceFromObject(Object obj)
+ {
+ if (obj instanceof String)
+ return new OreDictResource((String) obj);
- if (obj instanceof FluidStack)
- return new FluidStackResource((FluidStack) obj);
+ if (obj instanceof Block)
+ return new ItemStackResource(new ItemStack((Block) obj));
- if (obj instanceof RecipeResource)
- return (RecipeResource) obj;
+ if (obj instanceof Item)
+ return new ItemStackResource(new ItemStack((Item) obj));
- return null;
- }
+ if (obj instanceof ItemStack)
+ return new ItemStackResource((ItemStack) obj);
- public void addRecipe(RecipeType machine, RecipeResource[] input, RecipeResource[] output)
- {
- this.recipes.get(machine).put(input, output);
- }
+ if (obj instanceof FluidStack)
+ return new FluidStackResource((FluidStack) obj);
- public void addRecipe(RecipeType machine, Object inputObj, Object... outputObj)
- {
- RecipeResource input = getResourceFromObject(inputObj);
- RecipeResource[] outputs = new RecipeResource[outputObj.length];
+ if (obj instanceof RecipeResource)
+ return (RecipeResource) obj;
- for (int i = 0; i < outputs.length; i++)
- {
- RecipeResource output = getResourceFromObject(outputObj[i]);
+ return null;
+ }
- if (input == null || output == null)
- throw new RuntimeException("Resonant Induction tried to add invalid machine recipe: " + input + " => " + output);
+ public void addRecipe(RecipeType machine, RecipeResource[] input, RecipeResource[] output)
+ {
+ this.recipes.get(machine).put(input, output);
+ }
- outputs[i] = output;
- }
+ public void addRecipe(RecipeType machine, Object inputObj, Object... outputObj)
+ {
+ RecipeResource input = getResourceFromObject(inputObj);
+ RecipeResource[] outputs = new RecipeResource[outputObj.length];
- addRecipe(machine, new RecipeResource[] { input }, outputs);
- }
+ for (int i = 0; i < outputs.length; i++)
+ {
+ RecipeResource output = getResourceFromObject(outputObj[i]);
- public void removeRecipe(RecipeType machine, RecipeResource[] input)
- {
- this.recipes.get(machine).remove(input);
- }
+ if (input == null || output == null)
+ throw new RuntimeException("Resonant Induction tried to add invalid machine recipe: " + input + " => " + output);
- public Map getRecipes(RecipeType machine)
- {
- return new HashMap(this.recipes.get(machine));
- }
+ outputs[i] = output;
+ }
- public Map> getRecipes()
- {
- return new HashMap>(this.recipes);
- }
+ addRecipe(machine, new RecipeResource[] { input }, outputs);
+ }
- public RecipeResource[] getOutput(RecipeType machine, RecipeResource... input)
- {
- Iterator> it = this.getRecipes(machine).entrySet().iterator();
+ public void removeRecipe(RecipeType machine, RecipeResource[] input)
+ {
+ this.recipes.get(machine).remove(input);
+ }
- while (it.hasNext())
- {
- Entry entry = it.next();
+ public Map getRecipes(RecipeType machine)
+ {
+ return new HashMap(this.recipes.get(machine));
+ }
- if (Arrays.equals(entry.getKey(), input))
- {
- return entry.getValue();
- }
- }
+ public Map> getRecipes()
+ {
+ return new HashMap>(this.recipes);
+ }
- return new RecipeResource[] {};
- }
+ public RecipeResource[] getOutput(RecipeType machine, RecipeResource... input)
+ {
+ Iterator> it = this.getRecipes(machine).entrySet().iterator();
- public RecipeResource[] getOutput(RecipeType machine, Object... inputs)
- {
- RecipeResource[] resourceInputs = new RecipeResource[inputs.length];
+ while (it.hasNext())
+ {
+ Entry entry = it.next();
- for (int i = 0; i < inputs.length; i++)
- {
- resourceInputs[i] = getResourceFromObject(inputs[i]);
- }
+ if (Arrays.equals(entry.getKey(), input))
+ {
+ return entry.getValue();
+ }
+ }
- return getOutput(machine, resourceInputs);
- }
+ return new RecipeResource[] {};
+ }
+
+ public RecipeResource[] getOutput(RecipeType machine, Object... inputs)
+ {
+ RecipeResource[] resourceInputs = new RecipeResource[inputs.length];
+
+ for (int i = 0; i < inputs.length; i++)
+ {
+ resourceInputs[i] = getResourceFromObject(inputs[i]);
+ }
+
+ return getOutput(machine, resourceInputs);
+ }
}
diff --git a/src/main/java/resonantinduction/core/grid/NodeRegistry.java b/src/main/java/resonantinduction/core/grid/NodeRegistry.java
new file mode 100644
index 000000000..3feed0a37
--- /dev/null
+++ b/src/main/java/resonantinduction/core/grid/NodeRegistry.java
@@ -0,0 +1,35 @@
+package resonantinduction.core.grid;
+
+import java.util.HashMap;
+
+/**
+ * A dynamic node loader for registering different nodes for different node interfaces.
+ *
+ * @author Calclavia
+ *
+ */
+public class NodeRegistry
+{
+ private static final HashMap INTERFACE_NODE_MAP = new HashMap();
+
+ public static void register(Class nodeInterface, Class nodeClass)
+ {
+ INTERFACE_NODE_MAP.put(nodeInterface, nodeClass);
+ }
+
+ public static Class extends N> get(INodeProvider parent, Class nodeInterface)
+ {
+ Class nodeClass = INTERFACE_NODE_MAP.get(nodeInterface);
+
+ try
+ {
+ return (Class extends N>) nodeClass.getConstructor(INodeProvider.class).newInstance(parent);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+
+ return null;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/resonantinduction/core/resource/ItemOreResource.java b/src/main/java/resonantinduction/core/resource/ItemOreResource.java
index 47bf6f49e..41790b502 100644
--- a/src/main/java/resonantinduction/core/resource/ItemOreResource.java
+++ b/src/main/java/resonantinduction/core/resource/ItemOreResource.java
@@ -48,18 +48,18 @@ public class ItemOreResource extends Item
@Override
public String getItemDisplayName(ItemStack is)
{
- String dustName = getMaterialFromStack(is);
+ String material = getMaterialFromStack(is);
- if (dustName != null)
+ if (material != null)
{
- List list = OreDictionary.getOres("ingot" + dustName.substring(0, 1).toUpperCase() + dustName.substring(1));
+ List list = OreDictionary.getOres("ingot" + material.substring(0, 1).toUpperCase() + material.substring(1));
if (list.size() > 0)
{
ItemStack type = list.get(0);
String name = type.getDisplayName().replace(LanguageUtility.getLocal("misc.resonantinduction.ingot"), "").replaceAll("^ ", "").replaceAll(" $", "");
- return (LanguageUtility.getLocal(this.getUnlocalizedName() + ".name")).replace("%v", name).replace(" ", " ");
+ return (LanguageUtility.getLocal(getUnlocalizedName() + ".name")).replace("%v", name).replace(" ", " ");
}
}
diff --git a/src/main/java/resonantinduction/core/resource/ResourceGenerator.java b/src/main/java/resonantinduction/core/resource/ResourceGenerator.java
index 537ed3039..9c6ae8872 100644
--- a/src/main/java/resonantinduction/core/resource/ResourceGenerator.java
+++ b/src/main/java/resonantinduction/core/resource/ResourceGenerator.java
@@ -103,7 +103,11 @@ public class ResourceGenerator implements IVirtualObject
OreDictionary.registerOre("oreGold", Block.oreGold);
OreDictionary.registerOre("oreIron", Block.oreIron);
OreDictionary.registerOre("oreLapis", Block.oreLapis);
+ regenerateOreResources();
+ }
+ public static void regenerateOreResources()
+ {
// Vanilla fluid recipes
MachineRecipes.INSTANCE.addRecipe(RecipeType.SMELTER, new FluidStack(FluidRegistry.LAVA, FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(Block.stone));