Added ResonantPartFactory
This commit is contained in:
parent
20b118158b
commit
362b00865d
5 changed files with 46 additions and 36 deletions
|
@ -69,6 +69,7 @@ object ResonantInduction
|
|||
ResonantInduction.metadata.autogenerated = false
|
||||
}
|
||||
|
||||
ResonantPartFactory.init()
|
||||
ResonantEngine.resourceFactory.generateAll();
|
||||
proxy.init()
|
||||
}
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
package resonantinduction.core
|
||||
|
||||
import codechicken.multipart.MultiPartRegistry.IPartFactory
|
||||
import codechicken.multipart.{MultiPartRegistry, TMultiPart}
|
||||
|
||||
import scala.collection.mutable
|
||||
|
||||
/**
|
||||
* @author Calclavia
|
||||
*/
|
||||
object ResonantPartFactory extends IPartFactory
|
||||
{
|
||||
val prefix = Reference.prefix
|
||||
|
||||
private val partMap = mutable.Map.empty[String, Class[_<:TMultiPart]]
|
||||
|
||||
def register(part: Class[_<:TMultiPart])
|
||||
{
|
||||
partMap.put(prefix + part.getClass.getSimpleName, part)
|
||||
}
|
||||
|
||||
def init() = MultiPartRegistry.registerParts(this, partMap.keys.toArray)
|
||||
|
||||
def createPart(name: String, client: Boolean): TMultiPart = partMap(name).newInstance()
|
||||
}
|
|
@ -4,6 +4,7 @@ import codechicken.multipart.{IRedstonePart, TMultiPart}
|
|||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.util.MovingObjectPosition
|
||||
import resonant.content.spatial.block.TraitTicker
|
||||
import resonantinduction.core.ResonantPartFactory
|
||||
|
||||
import scala.collection.convert.wrapAll._
|
||||
import scala.collection.mutable
|
||||
|
@ -59,5 +60,5 @@ trait TPart extends TMultiPart with TraitTicker
|
|||
|
||||
override def toString: String = "[" + getClass.getSimpleName + "]" + x + "x " + y + "y " + z + "z"
|
||||
|
||||
override def getType: String = "ResonantInduction:" + getClass.getSimpleName
|
||||
override def getType: String = ResonantPartFactory.prefix + getClass.getSimpleName
|
||||
}
|
|
@ -12,8 +12,8 @@ import net.minecraftforge.event.entity.EntityJoinWorldEvent
|
|||
import net.minecraftforge.oredict.OreDictionary
|
||||
import resonant.content.loader.ModManager
|
||||
import resonant.lib.loadable.LoadableHandler
|
||||
import resonantinduction.atomic.gate.ItemQuantumGlyph
|
||||
import resonantinduction.core.{Reference, ResonantTab, Settings}
|
||||
import resonantinduction.atomic.gate.{PartQuantumGlyph, ItemQuantumGlyph}
|
||||
import resonantinduction.core.{ResonantPartFactory, Reference, ResonantTab, Settings}
|
||||
import resonantinduction.electrical.battery.{ItemBlockBattery, TileBattery}
|
||||
import resonantinduction.electrical.generator.{TileMotor, TileSolarPanel, TileThermopile}
|
||||
import resonantinduction.electrical.laser.emitter.{BlockLaserEmitter, TileLaserEmitter}
|
||||
|
@ -21,12 +21,14 @@ import resonantinduction.electrical.laser.focus.ItemFocusingMatrix
|
|||
import resonantinduction.electrical.laser.focus.crystal.{BlockFocusCrystal, TileFocusCrystal}
|
||||
import resonantinduction.electrical.laser.focus.mirror.{BlockMirror, TileMirror}
|
||||
import resonantinduction.electrical.laser.receiver.{BlockLaserReceiver, TileLaserReceiver}
|
||||
import resonantinduction.electrical.levitator.ItemLevitator
|
||||
import resonantinduction.electrical.multimeter.ItemMultimeter
|
||||
import resonantinduction.electrical.levitator.{PartLevitator, ItemLevitator}
|
||||
import resonantinduction.electrical.multimeter.{PartMultimeter, ItemMultimeter}
|
||||
import resonantinduction.electrical.tesla.TileTesla
|
||||
import resonantinduction.electrical.transformer.ItemElectricTransformer
|
||||
import resonantinduction.electrical.transformer.{PartElectricTransformer, ItemElectricTransformer}
|
||||
import resonantinduction.electrical.wire.ItemWire
|
||||
import resonantinduction.electrical.wire.base.WireMaterial
|
||||
import resonantinduction.electrical.wire.flat.PartFlatWire
|
||||
import resonantinduction.electrical.wire.framed.PartFramedWire
|
||||
|
||||
/** Resonant Induction Electrical Module
|
||||
*
|
||||
|
@ -96,13 +98,23 @@ object Electrical
|
|||
OreDictionary.registerOre("batteryBox", ItemBlockBattery.setTier(new ItemStack(ElectricalContent.blockBattery, 1, 0), 0.asInstanceOf[Byte]))
|
||||
ResonantTab.itemStack(new ItemStack(ElectricalContent.itemTransformer))
|
||||
|
||||
|
||||
/**
|
||||
* Register all parts
|
||||
*/
|
||||
ResonantPartFactory.register(classOf[PartFramedWire])
|
||||
ResonantPartFactory.register(classOf[PartFlatWire])
|
||||
ResonantPartFactory.register(classOf[PartMultimeter])
|
||||
ResonantPartFactory.register(classOf[PartElectricTransformer])
|
||||
ResonantPartFactory.register(classOf[PartLevitator])
|
||||
ResonantPartFactory.register(classOf[PartQuantumGlyph])
|
||||
|
||||
Electrical.proxy.preInit
|
||||
modproxies.preInit()
|
||||
}
|
||||
|
||||
@EventHandler def init(evt: FMLInitializationEvent)
|
||||
{
|
||||
ElectricalPartFactory.register()
|
||||
Electrical.proxy.init
|
||||
modproxies.init()
|
||||
}
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
package resonantinduction.electrical
|
||||
|
||||
import codechicken.multipart.MultiPartRegistry.IPartFactory
|
||||
import codechicken.multipart.{MultiPartRegistry, TMultiPart}
|
||||
import resonantinduction.atomic.gate.PartQuantumGlyph
|
||||
import resonantinduction.electrical.levitator.PartLevitator
|
||||
import resonantinduction.electrical.multimeter.PartMultimeter
|
||||
import resonantinduction.electrical.transformer.PartElectricTransformer
|
||||
import resonantinduction.electrical.wire.flat.PartFlatWire
|
||||
import resonantinduction.electrical.wire.framed.PartFramedWire
|
||||
|
||||
object ElectricalPartFactory extends IPartFactory
|
||||
{
|
||||
def register() = MultiPartRegistry.registerParts(this, Array("resonant_induction_flat_wire", "resonant_induction_framed_wire", "resonant_induction_multimeter", "resonant_induction_transformer", "resonant_induction_charger", "resonant_induction_levitator"))
|
||||
|
||||
def createPart(name: String, client: Boolean): TMultiPart =
|
||||
{
|
||||
name match
|
||||
{
|
||||
case "resonant_induction_framed_wire" => new PartFramedWire
|
||||
case "resonant_induction_flat_wire" => new PartFlatWire
|
||||
case "resonant_induction_multimeter" => new PartMultimeter
|
||||
case "resonant_induction_transformer" => new PartElectricTransformer
|
||||
case "resonant_induction_levitator" => new PartLevitator
|
||||
case "resonant_induction_quantum_glyph" => new PartQuantumGlyph
|
||||
case _ => null
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue