Fixed a few parts implementing getType on their own, and make getType final to prevent this in the future

This commit is contained in:
Robert S 2014-10-16 08:13:57 -04:00
parent d7bee7f649
commit 453903bbee
5 changed files with 33 additions and 73 deletions

View file

@ -71,5 +71,5 @@ abstract class PartAbstract extends TMultiPart with TraitTicker
override def toString: String = "[" + getClass.getSimpleName + "]" + x + "x " + y + "y " + z + "z" override def toString: String = "[" + getClass.getSimpleName + "]" + x + "x " + y + "y " + z + "z"
override def getType: String = ResonantPartFactory.prefix + getClass.getSimpleName final override def getType: String = ResonantPartFactory.prefix + getClass.getSimpleName
} }

View file

@ -11,18 +11,18 @@ import net.minecraft.nbt.NBTTagCompound
import net.minecraft.util.MovingObjectPosition import net.minecraft.util.MovingObjectPosition
import net.minecraftforge.common.util.ForgeDirection import net.minecraftforge.common.util.ForgeDirection
import resonant.engine.ResonantEngine import resonant.engine.ResonantEngine
import resonantinduction.core.prefab.part.connector.PartAbstract
import universalelectricity.api.core.grid.{INode, INodeProvider} import universalelectricity.api.core.grid.{INode, INodeProvider}
import universalelectricity.core.transform.vector.VectorWorld import universalelectricity.core.transform.vector.VectorWorld
/** We assume all the force acting on the gear is 90 degrees. /** We assume all the force acting on the gear is 90 degrees.
* *
* @author Calclavia */ * @author Calclavia */
abstract class PartMechanical extends JCuboidPart with JNormalOcclusion with TFacePart with INodeProvider abstract class PartMechanical extends PartAbstract with JNormalOcclusion with TFacePart with INodeProvider
{ {
/** Node that handles resonantinduction.mechanical action of the machine */ /** Node that handles resonantinduction.mechanical action of the machine */
var node: MechanicalNode = null var node: MechanicalNode = null
protected var prevAngularVelocity: Double = .0 protected var prevAngularVelocity: Double = .0
private[mech] var ticks: Int = 0
/** Packets */ /** Packets */
private[mech] var markPacketUpdate: Boolean = false private[mech] var markPacketUpdate: Boolean = false
/** Simple debug external GUI */ /** Simple debug external GUI */
@ -54,11 +54,6 @@ abstract class PartMechanical extends JCuboidPart with JNormalOcclusion with TFa
override def update override def update
{ {
ticks += 1
if (ticks >= java.lang.Long.MAX_VALUE)
{
ticks = 0
}
this.node.update this.node.update
if (!world.isRemote) if (!world.isRemote)
{ {
@ -145,7 +140,7 @@ abstract class PartMechanical extends JCuboidPart with JNormalOcclusion with TFa
read(packet, packet.readUByte) read(packet, packet.readUByte)
} }
def read(packet: MCDataInput, packetID: Int) override def read(packet: MCDataInput, packetID: Int)
{ {
if (packetID == 0) if (packetID == 0)
{ {

View file

@ -1,17 +1,14 @@
package resonantinduction.mechanical.mech.gear package resonantinduction.mechanical.mech.gear
import codechicken.lib.vec.Rotation import codechicken.lib.vec.Rotation
import codechicken.multipart.TMultiPart import codechicken.multipart.{TMultiPart, TileMultipart}
import codechicken.multipart.TileMultipart
import net.minecraft.tileentity.TileEntity import net.minecraft.tileentity.TileEntity
import net.minecraftforge.common.util.ForgeDirection import net.minecraftforge.common.util.ForgeDirection
import resonantinduction.core.interfaces.IMechanicalNode import resonantinduction.core.interfaces.IMechanicalNode
import resonantinduction.mechanical.mech.MechanicalNode import resonantinduction.mechanical.mech.MechanicalNode
import resonantinduction.mechanical.mech.gearshaft.PartGearShaft import resonantinduction.mechanical.mech.gearshaft.PartGearShaft
import universalelectricity.api.core.grid.INodeProvider import universalelectricity.api.core.grid.INodeProvider
import universalelectricity.core.transform.vector.IVectorWorld import universalelectricity.core.transform.vector.{IVectorWorld, Vector3, VectorWorld}
import universalelectricity.core.transform.vector.VectorWorld
import universalelectricity.core.transform.vector.Vector3
/** /**
* Node for the gear * Node for the gear
@ -73,29 +70,21 @@ class GearNode(parent: PartGear) extends MechanicalNode(parent: PartGear)
addConnection(instance, gear.placementSide) addConnection(instance, gear.placementSide)
} }
} }
for (i <- 0 until 6)
{ {
var i: Int = 0 val checkDir: ForgeDirection = ForgeDirection.getOrientation(i)
while (i < 6) var tile: TileEntity = gear.tile
if (gear.getMultiBlock.isConstructed && checkDir != gear.placementSide && checkDir != gear.placementSide.getOpposite)
{ {
tile = new Vector3(gear.tile).add(checkDir).getTileEntity(world)
}
if (tile.isInstanceOf[INodeProvider])
{
val instance: MechanicalNode = (tile.asInstanceOf[INodeProvider]).getNode(classOf[MechanicalNode], if (checkDir eq gear.placementSide.getOpposite) ForgeDirection.UNKNOWN else checkDir).asInstanceOf[MechanicalNode]
if (!connections.containsValue(checkDir) && instance != this && checkDir != gear.placementSide && instance != null && instance.canConnect(checkDir.getOpposite, this))
{ {
val checkDir: ForgeDirection = ForgeDirection.getOrientation(i) addConnection(instance, checkDir)
var tile: TileEntity = gear.tile
if (gear.getMultiBlock.isConstructed && checkDir != gear.placementSide && checkDir != gear.placementSide.getOpposite)
{
tile = new Vector3(gear.tile).add(checkDir).getTileEntity(world)
}
if (tile.isInstanceOf[INodeProvider])
{
val instance: MechanicalNode = (tile.asInstanceOf[INodeProvider]).getNode(classOf[MechanicalNode], if (checkDir eq gear.placementSide.getOpposite) ForgeDirection.UNKNOWN else checkDir).asInstanceOf[MechanicalNode]
if (!connections.containsValue(checkDir) && instance != this && checkDir != gear.placementSide && instance != null && instance.canConnect(checkDir.getOpposite, this))
{
addConnection(instance, checkDir)
}
}
} }
({
i += 1; i - 1
})
} }
} }
var displaceCheck: Int = 1 var displaceCheck: Int = 1
@ -103,25 +92,17 @@ class GearNode(parent: PartGear) extends MechanicalNode(parent: PartGear)
{ {
displaceCheck = 2 displaceCheck = 2
} }
for (i <- 0 until 4)
{ {
var i: Int = 0 val checkDir: ForgeDirection = ForgeDirection.getOrientation(Rotation.rotateSide(gear.placementSide.ordinal, i))
while (i < 4) val checkTile: TileEntity = new Vector3(gear.tile).add(checkDir).getTileEntity(world)
if (!connections.containsValue(checkDir) && checkTile.isInstanceOf[INodeProvider])
{ {
val instance: MechanicalNode = (checkTile.asInstanceOf[INodeProvider]).getNode(classOf[MechanicalNode], gear.placementSide).asInstanceOf[MechanicalNode]
if (instance != null && instance != this && instance.canConnect(checkDir.getOpposite, this) && !(instance.getParent.isInstanceOf[PartGearShaft]))
{ {
val checkDir: ForgeDirection = ForgeDirection.getOrientation(Rotation.rotateSide(gear.placementSide.ordinal, i)) addConnection(instance, checkDir)
val checkTile: TileEntity = new Vector3(gear.tile).add(checkDir).getTileEntity(world)
if (!connections.containsValue(checkDir) && checkTile.isInstanceOf[INodeProvider])
{
val instance: MechanicalNode = (checkTile.asInstanceOf[INodeProvider]).getNode(classOf[MechanicalNode], gear.placementSide).asInstanceOf[MechanicalNode]
if (instance != null && instance != this && instance.canConnect(checkDir.getOpposite, this) && !(instance.getParent.isInstanceOf[PartGearShaft]))
{
addConnection(instance, checkDir)
}
}
} }
({
i += 1; i - 1
})
} }
} }
} }

View file

@ -29,19 +29,13 @@ object PartGear
oBoxes(0)(0) = new Cuboid6(1 / 8D, 0, 0, 7 / 8D, 1 / 8D, 1) oBoxes(0)(0) = new Cuboid6(1 / 8D, 0, 0, 7 / 8D, 1 / 8D, 1)
oBoxes(0)(1) = new Cuboid6(0, 0, 1 / 8D, 1, 1 / 8D, 7 / 8D) oBoxes(0)(1) = new Cuboid6(0, 0, 1 / 8D, 1, 1 / 8D, 7 / 8D)
for(s <- 1 until 6)
{ {
var s: Int = 1 val t: Transformation = Rotation.sideRotations(s).at(Vector3.center)
while (s < 6) oBoxes(s)(0) = oBoxes(0)(0).copy.apply(t)
{ oBoxes(s)(1) = oBoxes(0)(1).copy.apply(t)
{
val t: Transformation = Rotation.sideRotations(s).at(Vector3.center)
oBoxes(s)(0) = oBoxes(0)(0).copy.apply(t)
oBoxes(s)(1) = oBoxes(0)(1).copy.apply(t)
}
({
s += 1; s - 1
})
}
} }
} }
@ -109,7 +103,7 @@ class PartGear extends PartMechanical with IMultiBlockStructure[PartGear]
/** Is this gear block the one in the center-edge of the multiblock that can interact with other /** Is this gear block the one in the center-edge of the multiblock that can interact with other
* gears? * gears?
* *
* @return*/ * @return */
def isCenterMultiBlock: Boolean = def isCenterMultiBlock: Boolean =
{ {
if (!getMultiBlock.isConstructed) if (!getMultiBlock.isConstructed)
@ -145,11 +139,6 @@ class PartGear extends PartMechanical with IMultiBlockStructure[PartGear]
} }
} }
def getType: String =
{
return "resonant_induction_gear"
}
override def load(nbt: NBTTagCompound) override def load(nbt: NBTTagCompound)
{ {
super.load(nbt) super.load(nbt)
@ -165,7 +154,7 @@ class PartGear extends PartMechanical with IMultiBlockStructure[PartGear]
override def getMultiBlockVectors: java.util.List[universalelectricity.core.transform.vector.Vector3] = override def getMultiBlockVectors: java.util.List[universalelectricity.core.transform.vector.Vector3] =
{ {
val vec = new universalelectricity.core.transform.vector.Vector3(this.x, this.y, this.z) val vec = new universalelectricity.core.transform.vector.Vector3(this.x, this.y, this.z)
var array : java.util.List[universalelectricity.core.transform.vector.Vector3] = vec.getAround(this.world, placementSide, 1) var array: java.util.List[universalelectricity.core.transform.vector.Vector3] = vec.getAround(this.world, placementSide, 1)
return array return array
} }
@ -202,7 +191,7 @@ class PartGear extends PartMechanical with IMultiBlockStructure[PartGear]
def getOcclusionBoxes: java.lang.Iterable[Cuboid6] = def getOcclusionBoxes: java.lang.Iterable[Cuboid6] =
{ {
val list: java.util.List[Cuboid6] = new util.ArrayList[Cuboid6]; val list: java.util.List[Cuboid6] = new util.ArrayList[Cuboid6];
for(v <- PartGear.oBoxes(this.placementSide.ordinal)) for (v <- PartGear.oBoxes(this.placementSide.ordinal))
{ {
list.add(v) list.add(v)
} }

View file

@ -58,11 +58,6 @@ class PartGearShaft extends PartMechanical
} }
} }
def getType: String =
{
return "resonant_induction_gear_shaft"
}
/** /**
* Multipart Bounds * Multipart Bounds
*/ */