Error: Some work on DC Grid
This commit is contained in:
parent
214af4fe2a
commit
f01f512acb
3 changed files with 36 additions and 36 deletions
|
@ -2,12 +2,12 @@ package edx.electrical.transformer
|
|||
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import resonant.api.tile.INodeProvider
|
||||
import resonant.lib.grid.electric.NodeDirectCurrent
|
||||
import resonant.lib.grid.electric.NodeDC
|
||||
|
||||
/**
|
||||
* Created by robert on 8/11/2014.
|
||||
*/
|
||||
class ElectricTransformerNode(parent: INodeProvider) extends NodeDirectCurrent(parent: INodeProvider)
|
||||
class ElectricTransformerNode(parent: INodeProvider) extends NodeDC(parent: INodeProvider)
|
||||
{
|
||||
var connectionDirection: ForgeDirection = ForgeDirection.NORTH
|
||||
var input = true
|
||||
|
@ -30,7 +30,7 @@ class ElectricTransformerNode(parent: INodeProvider) extends NodeDirectCurrent(p
|
|||
return 120
|
||||
}
|
||||
|
||||
override def canConnect[B <: NodeDirectCurrent](obj: B, from: ForgeDirection): Boolean =
|
||||
override def canConnect[B <: NodeDC](obj: B, from: ForgeDirection): Boolean =
|
||||
{
|
||||
return obj.isInstanceOf[INodeProvider] && from == connectionDirection
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import net.minecraftforge.common.util.ForgeDirection
|
|||
import org.lwjgl.opengl.GL11
|
||||
import resonant.api.tile.INodeProvider
|
||||
import resonant.lib.grid.UpdateTicker
|
||||
import resonant.lib.grid.electric.NodeDirectCurrent
|
||||
import resonant.lib.grid.electric.NodeDC
|
||||
|
||||
import scala.collection.convert.wrapAll._
|
||||
|
||||
|
@ -223,6 +223,28 @@ class PartFlatWire extends PartAbstract with TWire with TFacePart with TNormalOc
|
|||
super.onChunkLoad()
|
||||
}
|
||||
|
||||
def dropIfCantStay: Boolean =
|
||||
{
|
||||
if (!canStay)
|
||||
{
|
||||
drop
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
def canStay: Boolean =
|
||||
{
|
||||
val pos: BlockCoord = new BlockCoord(tile).offset(side)
|
||||
return MultipartUtil.canPlaceWireOnSide(world, pos.x, pos.y, pos.z, ForgeDirection.getOrientation(side ^ 1), false)
|
||||
}
|
||||
|
||||
def drop
|
||||
{
|
||||
TileMultipart.dropItem(getItem, world, Vector3.fromTileEntityCenter(tile))
|
||||
tile.remPart(this)
|
||||
}
|
||||
|
||||
override def onAdded()
|
||||
{
|
||||
super.onAdded()
|
||||
|
@ -251,28 +273,6 @@ class PartFlatWire extends PartAbstract with TWire with TFacePart with TNormalOc
|
|||
sendPacket(3)
|
||||
}
|
||||
|
||||
def dropIfCantStay: Boolean =
|
||||
{
|
||||
if (!canStay)
|
||||
{
|
||||
drop
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
def canStay: Boolean =
|
||||
{
|
||||
val pos: BlockCoord = new BlockCoord(tile).offset(side)
|
||||
return MultipartUtil.canPlaceWireOnSide(world, pos.x, pos.y, pos.z, ForgeDirection.getOrientation(side ^ 1), false)
|
||||
}
|
||||
|
||||
def drop
|
||||
{
|
||||
TileMultipart.dropItem(getItem, world, Vector3.fromTileEntityCenter(tile))
|
||||
tile.remPart(this)
|
||||
}
|
||||
|
||||
def maskOpen(r: Int): Boolean =
|
||||
{
|
||||
return (connectionMask & 0x1000 << r) != 0
|
||||
|
@ -341,7 +341,7 @@ class PartFlatWire extends PartAbstract with TWire with TFacePart with TNormalOc
|
|||
* TODO: ForgeDirection may NOT be suitable. Integers are better.
|
||||
* @param provider
|
||||
*/
|
||||
class FlatWireNode(provider: INodeProvider) extends NodeDirectCurrent(provider) with TMultipartNode[NodeDirectCurrent]
|
||||
class FlatWireNode(provider: INodeProvider) extends NodeDC(provider) with TMultipartNode[NodeDC]
|
||||
{
|
||||
override def reconstruct()
|
||||
{
|
||||
|
@ -393,7 +393,7 @@ class PartFlatWire extends PartAbstract with TWire with TFacePart with TNormalOc
|
|||
|
||||
if (part != null)
|
||||
{
|
||||
val node = part.asInstanceOf[INodeProvider].getNode(classOf[NodeDirectCurrent], from)
|
||||
val node = part.asInstanceOf[INodeProvider].getNode(classOf[NodeDC], from)
|
||||
|
||||
if (canConnect(node, to))
|
||||
{
|
||||
|
@ -492,7 +492,7 @@ class PartFlatWire extends PartAbstract with TWire with TFacePart with TNormalOc
|
|||
val part = tpCorner.partMap(absDir ^ 1)
|
||||
val absToDir = ForgeDirection.getOrientation(absDir)
|
||||
val absFromDir = ForgeDirection.getOrientation(absDir).getOpposite
|
||||
val node = part.asInstanceOf[INodeProvider].getNode(classOf[NodeDirectCurrent], absFromDir)
|
||||
val node = part.asInstanceOf[INodeProvider].getNode(classOf[NodeDC], absFromDir)
|
||||
|
||||
if (canConnect(node, absFromDir))
|
||||
{
|
||||
|
@ -511,7 +511,7 @@ class PartFlatWire extends PartAbstract with TWire with TFacePart with TNormalOc
|
|||
val facePart = tile.partMap(absDir)
|
||||
val toDir = ForgeDirection.getOrientation(absDir)
|
||||
|
||||
if (facePart != null && (!facePart.isInstanceOf[PartFlatWire] || !canConnect(facePart.asInstanceOf[INodeProvider].getNode(classOf[NodeDirectCurrent], toDir.getOpposite), toDir.getOpposite)))
|
||||
if (facePart != null && (!facePart.isInstanceOf[PartFlatWire] || !canConnect(facePart.asInstanceOf[INodeProvider].getNode(classOf[NodeDC], toDir.getOpposite), toDir.getOpposite)))
|
||||
{
|
||||
return false
|
||||
}
|
||||
|
@ -718,7 +718,7 @@ class PartFlatWire extends PartAbstract with TWire with TFacePart with TNormalOc
|
|||
return false
|
||||
}
|
||||
|
||||
override def canConnect[B <: NodeDirectCurrent](node: B, from: ForgeDirection): Boolean =
|
||||
override def canConnect[B <: NodeDC](node: B, from: ForgeDirection): Boolean =
|
||||
{
|
||||
if (node.isInstanceOf[FlatWireNode])
|
||||
{
|
||||
|
@ -864,10 +864,10 @@ class PartFlatWire extends PartAbstract with TWire with TFacePart with TNormalOc
|
|||
/**
|
||||
* Gets a potential DCNode from an object.
|
||||
*/
|
||||
private def getComponent(obj: AnyRef, from: ForgeDirection): NodeDirectCurrent =
|
||||
private def getComponent(obj: AnyRef, from: ForgeDirection): NodeDC =
|
||||
{
|
||||
if (obj.isInstanceOf[INodeProvider])
|
||||
return obj.asInstanceOf[INodeProvider].getNode(classOf[NodeDirectCurrent], from)
|
||||
return obj.asInstanceOf[INodeProvider].getNode(classOf[NodeDC], from)
|
||||
|
||||
return null
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import edx.electrical.wire.base.TWire
|
|||
import net.minecraft.client.renderer.RenderBlocks
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import resonant.lib.grid.electric.NodeDirectCurrent
|
||||
import resonant.lib.grid.electric.NodeDC
|
||||
import resonant.lib.wrapper.BitmaskWrapper._
|
||||
|
||||
/**
|
||||
|
@ -20,7 +20,7 @@ import resonant.lib.wrapper.BitmaskWrapper._
|
|||
*/
|
||||
class PartFramedWire extends PartFramedNode with TWire
|
||||
{
|
||||
override lazy val node = new NodeDirectCurrent(this) with TMultipartNode[NodeDirectCurrent]
|
||||
override lazy val node = new NodeDC(this) with TMultipartNode[NodeDC]
|
||||
{
|
||||
override def reconstruct()
|
||||
{
|
||||
|
@ -33,7 +33,7 @@ class PartFramedWire extends PartFramedNode with TWire
|
|||
sendPacket(0)
|
||||
}
|
||||
|
||||
override def connect[B <: NodeDirectCurrent](obj: B, dir: ForgeDirection) =
|
||||
override def connect[B <: NodeDC](obj: B, dir: ForgeDirection) =
|
||||
{
|
||||
super.connect(obj, dir)
|
||||
connectionMask = connectionMask.openMask(dir)
|
||||
|
|
Loading…
Reference in a new issue