Added helper create method in Resonant

This commit is contained in:
Calclavia 2014-09-14 14:40:19 +08:00
parent 0b8230f4b1
commit fa255a469b
11 changed files with 26 additions and 26 deletions

View file

@ -12,13 +12,15 @@ object ResonantPartFactory extends IPartFactory
{
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])
{
partMap.put(prefix + part.getClass.getSimpleName, part)
partMap += (prefix + part.getSimpleName -> part)
}
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 createPart(name: String, client: Boolean): TMultiPart = partMap(name).newInstance()

View file

@ -1,4 +1,4 @@
package resonantinduction.core.prefab.part
package resonantinduction.core.prefab.part.connector
import java.util
import java.util.{Collection, HashSet, Set}

View file

@ -1,4 +1,4 @@
package resonantinduction.core.prefab.part
package resonantinduction.core.prefab.part.connector
import codechicken.lib.data.{MCDataInput, MCDataOutput}
import codechicken.multipart.TMultiPart

View file

@ -1,4 +1,4 @@
package resonantinduction.core.prefab.part
package resonantinduction.core.prefab.part.connector
import codechicken.lib.data.{MCDataInput, MCDataOutput}
import codechicken.multipart.TMultiPart

View file

@ -1,8 +1,7 @@
package resonantinduction.core.prefab.part
package resonantinduction.core.prefab.part.connector
import codechicken.lib.data.{MCDataInput, MCDataOutput}
import codechicken.multipart.TMultiPart
import net.minecraft.item.Item
import net.minecraft.nbt.NBTTagCompound
/**

View file

@ -1,4 +1,4 @@
package resonantinduction.core.prefab.part
package resonantinduction.core.prefab.part.connector
import codechicken.multipart.{IRedstonePart, TMultiPart}
import net.minecraft.item.ItemStack

View file

@ -113,7 +113,8 @@ object Electrical
modproxies.preInit()
}
@EventHandler def init(evt: FMLInitializationEvent)
@EventHandler
def init(evt: FMLInitializationEvent)
{
Electrical.proxy.init
modproxies.init()

View file

@ -15,13 +15,13 @@ import net.minecraftforge.common.util.ForgeDirection
import org.lwjgl.input.Keyboard
import resonant.lib.render.EnumColor
import resonant.lib.utility.LanguageUtility
import resonant.lib.wrapper.WrapList._
import resonantinduction.core.util.MultipartUtil
import resonantinduction.core.{Reference, ResonantTab}
import resonantinduction.electrical.wire.base.{WireMaterial, TWire}
import resonantinduction.core.{Reference, ResonantPartFactory, ResonantTab}
import resonantinduction.electrical.wire.base.WireMaterial
import resonantinduction.electrical.wire.flat.{PartFlatWire, RenderFlatWire}
import resonantinduction.electrical.wire.framed.PartFramedWire
import universalelectricity.api.UnitDisplay
import resonant.lib.wrapper.WrapList._
class ItemWire extends TItemMultiPart
{
@ -40,7 +40,7 @@ class ItemWire extends TItemMultiPart
return null
}
val wire = (if(ControlKeyHandler.isPressed) MultiPartRegistry.createPart("resonant_induction_framed_wire", false) else MultiPartRegistry.createPart("resonant_induction_flat_wire", false)).asInstanceOf[TWire]
val wire = if (ControlKeyHandler.isPressed) ResonantPartFactory.create(classOf[PartFramedWire]) else ResonantPartFactory.create(classOf[PartFlatWire])
if (wire != null)
{

View file

@ -5,13 +5,13 @@ import codechicken.multipart.TMultiPart
import net.minecraft.item.{Item, ItemStack}
import net.minecraft.nbt.NBTTagCompound
import net.minecraftforge.common.util.ForgeDirection
import resonantinduction.core.prefab.part.{TColorable, TInsulatable, TMaterial, TPart}
import resonantinduction.core.prefab.part.connector.{TColorable, TInsulatable, TMaterial, TPart}
import resonantinduction.electrical.ElectricalContent
import universalelectricity.api.core.grid.INodeProvider
import universalelectricity.simulator.dc.DCNode
/**
* Trait implemented by wires
* Class extended by wires
* @author Calclavia
*/
abstract class TWire extends TMultiPart with TPart with TMaterial[WireMaterial] with TInsulatable with TColorable

View file

@ -2,7 +2,7 @@ package resonantinduction.mechanical.fluid.pipe
import codechicken.lib.data.MCDataInput
import codechicken.lib.render.CCRenderState
import codechicken.lib.vec.{Cuboid6, Vector3}
import codechicken.lib.vec.Vector3
import codechicken.multipart.{TNormalOcclusion, TSlottedPart}
import cpw.mods.fml.relauncher.{Side, SideOnly}
import net.minecraft.client.renderer.RenderBlocks
@ -11,7 +11,7 @@ import net.minecraft.nbt.NBTTagCompound
import net.minecraftforge.common.util.ForgeDirection
import net.minecraftforge.fluids._
import resonant.lib.`type`.EvictingList
import resonantinduction.core.prefab.part.{PartFramedNode, TColorable, TMaterial}
import resonantinduction.core.prefab.part.connector.{PartFramedNode, TColorable, TMaterial}
import resonantinduction.mechanical.Mechanical
import resonantinduction.mechanical.fluid.pipe.PipeMaterials.PipeMaterial
@ -32,7 +32,7 @@ class PartPipe extends PartFramedNode with TMaterial[PipeMaterial] with TColorab
setNode(new PipePressureNode(this))
def preparePlacement(meta:Int)
def preparePlacement(meta: Int)
{
setMaterial(meta)
}
@ -44,7 +44,6 @@ class PartPipe extends PartFramedNode with TMaterial[PipeMaterial] with TColorab
def getMaterialID: Int = material.id
override def update()
{
super.update()

View file

@ -5,8 +5,7 @@ import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.IFluidHandler;
import resonant.lib.utility.WorldUtility;
import resonantinduction.core.prefab.node.NodePressure;
import resonantinduction.core.prefab.part.TColorable;
import resonantinduction.core.prefab.part.TColorable$;
import resonantinduction.core.prefab.part.connector.TColorable$;
import universalelectricity.api.core.grid.INode;
import universalelectricity.api.core.grid.INodeProvider;