From b5c70a5fb2e74fc7be0b76e650c24afa4e218b80 Mon Sep 17 00:00:00 2001 From: Calclavia Date: Sun, 14 Sep 2014 16:01:21 +0800 Subject: [PATCH] Fixed multipart trait TNodeProvider not registering --- .../core/ResonantPartFactory.scala | 10 +++-- .../electrical/wire/flat/PartFlatWire.scala | 2 +- .../mechanical/Mechanical.java | 10 ++++- .../mechanical/MultipartMechanical.java | 43 ------------------- 4 files changed, 17 insertions(+), 48 deletions(-) delete mode 100644 src/main/scala/resonantinduction/mechanical/MultipartMechanical.java diff --git a/src/main/scala/resonantinduction/core/ResonantPartFactory.scala b/src/main/scala/resonantinduction/core/ResonantPartFactory.scala index dff937aab..c900a2386 100644 --- a/src/main/scala/resonantinduction/core/ResonantPartFactory.scala +++ b/src/main/scala/resonantinduction/core/ResonantPartFactory.scala @@ -1,7 +1,7 @@ package resonantinduction.core import codechicken.multipart.MultiPartRegistry.IPartFactory -import codechicken.multipart.{MultiPartRegistry, TMultiPart} +import codechicken.multipart.{MultipartGenerator, MultiPartRegistry, TMultiPart} import scala.collection.mutable @@ -11,7 +11,6 @@ import scala.collection.mutable object ResonantPartFactory extends IPartFactory { val prefix = Reference.prefix - private val partMap = mutable.Map.empty[String, 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 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() } diff --git a/src/main/scala/resonantinduction/electrical/wire/flat/PartFlatWire.scala b/src/main/scala/resonantinduction/electrical/wire/flat/PartFlatWire.scala index c0d1715e0..a441c6d44 100644 --- a/src/main/scala/resonantinduction/electrical/wire/flat/PartFlatWire.scala +++ b/src/main/scala/resonantinduction/electrical/wire/flat/PartFlatWire.scala @@ -73,11 +73,11 @@ class PartFlatWire extends TWire with TFacePart with TNormalOcclusion override lazy val node = new FlatWireNode(this) - def preparePlacement(side: Int, meta: Int) { this.side = (side ^ 1).toByte setMaterial(meta) + node.setResistance(material.resistance) } def canStay: Boolean = diff --git a/src/main/scala/resonantinduction/mechanical/Mechanical.java b/src/main/scala/resonantinduction/mechanical/Mechanical.java index 4ffea191d..36e451241 100644 --- a/src/main/scala/resonantinduction/mechanical/Mechanical.java +++ b/src/main/scala/resonantinduction/mechanical/Mechanical.java @@ -5,9 +5,14 @@ import net.minecraft.init.Items; import resonant.content.loader.ModManager; import resonant.engine.content.debug.TileCreativeBuilder; import resonant.lib.network.discriminator.PacketAnnotationManager; +import resonantinduction.core.ResonantPartFactory; +import resonantinduction.core.ResonantPartFactory$; import resonantinduction.core.ResonantTab; import resonantinduction.mechanical.energy.grid.MechanicalNode; +import resonantinduction.mechanical.fluid.pipe.PartPipe; import resonantinduction.mechanical.fluid.pipe.PipeMaterials; +import resonantinduction.mechanical.gear.PartGear; +import resonantinduction.mechanical.gearshaft.PartGearShaft; import resonantinduction.mechanical.turbine.*; import resonantinduction.mechanical.fluid.pipe.ItemPipe; import resonantinduction.mechanical.fluid.transport.TilePump; @@ -127,12 +132,15 @@ public class Mechanical PacketAnnotationManager.INSTANCE.register(TileWindTurbine.class); PacketAnnotationManager.INSTANCE.register(TileWaterTurbine.class); + + ResonantPartFactory$.MODULE$.register(PartGear.class); + ResonantPartFactory$.MODULE$.register(PartGearShaft.class); + ResonantPartFactory$.MODULE$.register(PartPipe.class); } @EventHandler public void init(FMLInitializationEvent evt) { - MultipartMechanical.INSTANCE = new MultipartMechanical(); proxy.init(); } diff --git a/src/main/scala/resonantinduction/mechanical/MultipartMechanical.java b/src/main/scala/resonantinduction/mechanical/MultipartMechanical.java deleted file mode 100644 index 1a965202a..000000000 --- a/src/main/scala/resonantinduction/mechanical/MultipartMechanical.java +++ /dev/null @@ -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; - } -}