Fixed multipart trait TNodeProvider not registering

This commit is contained in:
Calclavia 2014-09-14 16:01:21 +08:00
parent 44208669ef
commit b5c70a5fb2
4 changed files with 17 additions and 48 deletions

View file

@ -1,7 +1,7 @@
package resonantinduction.core package resonantinduction.core
import codechicken.multipart.MultiPartRegistry.IPartFactory import codechicken.multipart.MultiPartRegistry.IPartFactory
import codechicken.multipart.{MultiPartRegistry, TMultiPart} import codechicken.multipart.{MultipartGenerator, MultiPartRegistry, TMultiPart}
import scala.collection.mutable import scala.collection.mutable
@ -11,7 +11,6 @@ import scala.collection.mutable
object ResonantPartFactory extends IPartFactory object ResonantPartFactory extends IPartFactory
{ {
val prefix = Reference.prefix val prefix = Reference.prefix
private val partMap = mutable.Map.empty[String, Class[_ <: TMultiPart]] private val partMap = mutable.Map.empty[String, Class[_ <: TMultiPart]]
def register(part: Class[_ <: TMultiPart]) def register(part: Class[_ <: TMultiPart])
@ -21,7 +20,12 @@ object ResonantPartFactory extends IPartFactory
def create[C <: TMultiPart](part: Class[C]): C = MultiPartRegistry.createPart((partMap map (_.swap)).get(part).get, false).asInstanceOf[C] def create[C <: TMultiPart](part: Class[C]): C = MultiPartRegistry.createPart((partMap map (_.swap)).get(part).get, false).asInstanceOf[C]
def init() = MultiPartRegistry.registerParts(this, partMap.keys.toArray) def init()
{
MultiPartRegistry.registerParts(this, partMap.keys.toArray)
MultipartGenerator.registerTrait("universalelectricity.api.core.grid.INodeProvider", "resonantinduction.core.prefab.TNodeProvider")
}
def createPart(name: String, client: Boolean): TMultiPart = partMap(name).newInstance() def createPart(name: String, client: Boolean): TMultiPart = partMap(name).newInstance()
} }

View file

@ -73,11 +73,11 @@ class PartFlatWire extends TWire with TFacePart with TNormalOcclusion
override lazy val node = new FlatWireNode(this) override lazy val node = new FlatWireNode(this)
def preparePlacement(side: Int, meta: Int) def preparePlacement(side: Int, meta: Int)
{ {
this.side = (side ^ 1).toByte this.side = (side ^ 1).toByte
setMaterial(meta) setMaterial(meta)
node.setResistance(material.resistance)
} }
def canStay: Boolean = def canStay: Boolean =

View file

@ -5,9 +5,14 @@ import net.minecraft.init.Items;
import resonant.content.loader.ModManager; import resonant.content.loader.ModManager;
import resonant.engine.content.debug.TileCreativeBuilder; import resonant.engine.content.debug.TileCreativeBuilder;
import resonant.lib.network.discriminator.PacketAnnotationManager; import resonant.lib.network.discriminator.PacketAnnotationManager;
import resonantinduction.core.ResonantPartFactory;
import resonantinduction.core.ResonantPartFactory$;
import resonantinduction.core.ResonantTab; import resonantinduction.core.ResonantTab;
import resonantinduction.mechanical.energy.grid.MechanicalNode; import resonantinduction.mechanical.energy.grid.MechanicalNode;
import resonantinduction.mechanical.fluid.pipe.PartPipe;
import resonantinduction.mechanical.fluid.pipe.PipeMaterials; import resonantinduction.mechanical.fluid.pipe.PipeMaterials;
import resonantinduction.mechanical.gear.PartGear;
import resonantinduction.mechanical.gearshaft.PartGearShaft;
import resonantinduction.mechanical.turbine.*; import resonantinduction.mechanical.turbine.*;
import resonantinduction.mechanical.fluid.pipe.ItemPipe; import resonantinduction.mechanical.fluid.pipe.ItemPipe;
import resonantinduction.mechanical.fluid.transport.TilePump; import resonantinduction.mechanical.fluid.transport.TilePump;
@ -127,12 +132,15 @@ public class Mechanical
PacketAnnotationManager.INSTANCE.register(TileWindTurbine.class); PacketAnnotationManager.INSTANCE.register(TileWindTurbine.class);
PacketAnnotationManager.INSTANCE.register(TileWaterTurbine.class); PacketAnnotationManager.INSTANCE.register(TileWaterTurbine.class);
ResonantPartFactory$.MODULE$.register(PartGear.class);
ResonantPartFactory$.MODULE$.register(PartGearShaft.class);
ResonantPartFactory$.MODULE$.register(PartPipe.class);
} }
@EventHandler @EventHandler
public void init(FMLInitializationEvent evt) public void init(FMLInitializationEvent evt)
{ {
MultipartMechanical.INSTANCE = new MultipartMechanical();
proxy.init(); proxy.init();
} }

View file

@ -1,43 +0,0 @@
package resonantinduction.mechanical;
import resonantinduction.mechanical.fluid.pipe.PartPipe;
import resonantinduction.mechanical.gear.PartGear;
import resonantinduction.mechanical.gearshaft.PartGearShaft;
import codechicken.multipart.MultiPartRegistry;
import codechicken.multipart.MultiPartRegistry.IPartFactory;
import codechicken.multipart.MultipartGenerator;
import codechicken.multipart.TMultiPart;
public class MultipartMechanical implements IPartFactory
{
public static MultipartMechanical INSTANCE;
public static final String[] PART_TYPES = { "resonant_induction_gear", "resonant_induction_gear_shaft", "resonant_induction_pipe" };
public MultipartMechanical()
{
MultiPartRegistry.registerParts(this, PART_TYPES);
//MultipartGenerator.registerPassThroughInterface("resonantinduction.core.grid.fluid.IPressureNodeProvider");
// TODO: Move to UE
MultipartGenerator.registerTrait("universalelectricity.api.core.grid.INodeProvider", "resonantinduction.core.prefab.TraitNodeProvider");
}
@Override
public TMultiPart createPart(String name, boolean client)
{
if (name.equals("resonant_induction_gear"))
{
return new PartGear();
}
else if (name.equals("resonant_induction_gear_shaft"))
{
return new PartGearShaft();
}
else if (name.equals("resonant_induction_pipe"))
{
return new PartPipe();
}
return null;
}
}