From af305ec0499fee44da8e4dc1ea54b4e8d16436d5 Mon Sep 17 00:00:00 2001 From: Calclavia Date: Sun, 21 Sep 2014 09:49:31 +0800 Subject: [PATCH] Made TWire a trait and PartAbstract a class --- .../{TPart.scala => PartAbstract.scala} | 13 ++++++++++++- .../prefab/part/connector/PartFramedNode.scala | 9 ++------- .../core/prefab/part/connector/TColorable.scala | 6 +++--- .../prefab/part/connector/TInsulatable.scala | 4 ++-- .../electrical/wire/base/TWire.scala | 16 +++++----------- .../electrical/wire/flat/PartFlatWire.scala | 3 ++- .../electrical/wire/framed/PartFramedWire.scala | 5 ++--- 7 files changed, 28 insertions(+), 28 deletions(-) rename src/main/scala/resonantinduction/core/prefab/part/connector/{TPart.scala => PartAbstract.scala} (85%) diff --git a/src/main/scala/resonantinduction/core/prefab/part/connector/TPart.scala b/src/main/scala/resonantinduction/core/prefab/part/connector/PartAbstract.scala similarity index 85% rename from src/main/scala/resonantinduction/core/prefab/part/connector/TPart.scala rename to src/main/scala/resonantinduction/core/prefab/part/connector/PartAbstract.scala index 55156317d..4d1e6a2de 100644 --- a/src/main/scala/resonantinduction/core/prefab/part/connector/TPart.scala +++ b/src/main/scala/resonantinduction/core/prefab/part/connector/PartAbstract.scala @@ -1,5 +1,6 @@ package resonantinduction.core.prefab.part.connector +import codechicken.lib.data.MCDataInput import codechicken.multipart.{IRedstonePart, TMultiPart} import net.minecraft.item.ItemStack import net.minecraft.util.MovingObjectPosition @@ -9,7 +10,7 @@ import resonantinduction.core.ResonantPartFactory import scala.collection.convert.wrapAll._ import scala.collection.mutable -trait TPart extends TMultiPart with TraitTicker +abstract class PartAbstract extends TMultiPart with TraitTicker { override def update() { @@ -58,6 +59,16 @@ trait TPart extends TMultiPart with TraitTicker return false } + override def read(packet: MCDataInput) + { + read(packet, packet.readUByte) + } + + def read(packet: MCDataInput, packetID: Int) + { + + } + override def toString: String = "[" + getClass.getSimpleName + "]" + x + "x " + y + "y " + z + "z" override def getType: String = ResonantPartFactory.prefix + getClass.getSimpleName diff --git a/src/main/scala/resonantinduction/core/prefab/part/connector/PartFramedNode.scala b/src/main/scala/resonantinduction/core/prefab/part/connector/PartFramedNode.scala index 3b5adf008..5120d36c4 100644 --- a/src/main/scala/resonantinduction/core/prefab/part/connector/PartFramedNode.scala +++ b/src/main/scala/resonantinduction/core/prefab/part/connector/PartFramedNode.scala @@ -41,7 +41,7 @@ object PartFramedNode } } -abstract class PartFramedNode extends TMultiPart with TNodePartConnector with TSlottedPart with TNormalOcclusion with TIconHitEffects +abstract class PartFramedNode extends PartAbstract with TNodePartConnector with TSlottedPart with TNormalOcclusion with TIconHitEffects { /** Bitmask connections */ var connectionMask: Byte = 0x00 @@ -162,12 +162,7 @@ abstract class PartFramedNode extends TMultiPart with TNodePartConnector with TS packet.writeByte(connectionMask) } - override def read(packet: MCDataInput) - { - read(packet, packet.readUByte) - } - - def read(packet: MCDataInput, packetID: Int) + override def read(packet: MCDataInput, packetID: Int) { if (packetID == 0) { diff --git a/src/main/scala/resonantinduction/core/prefab/part/connector/TColorable.scala b/src/main/scala/resonantinduction/core/prefab/part/connector/TColorable.scala index 6184890f5..6d874aad6 100644 --- a/src/main/scala/resonantinduction/core/prefab/part/connector/TColorable.scala +++ b/src/main/scala/resonantinduction/core/prefab/part/connector/TColorable.scala @@ -1,7 +1,6 @@ package resonantinduction.core.prefab.part.connector import codechicken.lib.data.{MCDataInput, MCDataOutput} -import codechicken.multipart.TMultiPart import net.minecraft.entity.player.EntityPlayer import net.minecraft.item.ItemStack import net.minecraft.nbt.NBTTagCompound @@ -16,7 +15,8 @@ object TColorable { val defaultColor = 15 } -trait TColorable extends TMultiPart with TPart + +trait TColorable extends PartAbstract { var colorID = TColorable.defaultColor @@ -73,7 +73,7 @@ trait TColorable extends TMultiPart with TPart packet.writeByte(colorID.toByte) } - def read(packet: MCDataInput, packetID: Int) + override def read(packet: MCDataInput, packetID: Int) { if (packetID == 2) { diff --git a/src/main/scala/resonantinduction/core/prefab/part/connector/TInsulatable.scala b/src/main/scala/resonantinduction/core/prefab/part/connector/TInsulatable.scala index d95636818..7c72de1ad 100644 --- a/src/main/scala/resonantinduction/core/prefab/part/connector/TInsulatable.scala +++ b/src/main/scala/resonantinduction/core/prefab/part/connector/TInsulatable.scala @@ -15,7 +15,7 @@ import scala.collection.mutable * Trait applied to objects that can be insulated/enhanced by a certain item. * @author Calclavia */ -trait TInsulatable extends TMultiPart with TPart +trait TInsulatable extends PartAbstract { /** * The item that is used to insulate this object. @@ -106,7 +106,7 @@ trait TInsulatable extends TMultiPart with TPart _insulated = packet.readBoolean } - def read(packet: MCDataInput, packetID: Int) + override def read(packet: MCDataInput, packetID: Int) { if (packetID == 1) _insulated = packet.readBoolean diff --git a/src/main/scala/resonantinduction/electrical/wire/base/TWire.scala b/src/main/scala/resonantinduction/electrical/wire/base/TWire.scala index 2a1e2ce1b..7dc6e575d 100644 --- a/src/main/scala/resonantinduction/electrical/wire/base/TWire.scala +++ b/src/main/scala/resonantinduction/electrical/wire/base/TWire.scala @@ -1,7 +1,6 @@ package resonantinduction.electrical.wire.base import codechicken.lib.data.{MCDataInput, MCDataOutput} -import codechicken.multipart.TMultiPart import net.minecraft.item.{Item, ItemStack} import net.minecraft.nbt.NBTTagCompound import net.minecraftforge.common.util.ForgeDirection @@ -14,14 +13,14 @@ import universalelectricity.simulator.dc.DCNode * Abstract class extended by both flat and framed wires to handle material, insulation, color and multipart node logic. * * Packets: - * 0 - Desc - * 1 - Material - * 2 - Insulation - * 3 - Color + * 0 - Desc + * 1 - Material + * 2 - Insulation + * 3 - Color * * @author Calclavia */ -abstract class TWire extends TMultiPart with TNodePartConnector with TPart with TMaterial[WireMaterial] with TInsulatable with TColorable +trait TWire extends PartAbstract with TNodePartConnector with TMaterial[WireMaterial] with TInsulatable with TColorable { override protected val insulationItem: Item = ElectricalContent.itemInsulation @@ -53,11 +52,6 @@ abstract class TWire extends TMultiPart with TNodePartConnector with TPart with super[TColorable].readDesc(packet) } - override final def read(packet: MCDataInput) - { - read(packet, packet.readUByte) - } - override def read(packet: MCDataInput, packetID: Int) { super[TInsulatable].read(packet, packetID) diff --git a/src/main/scala/resonantinduction/electrical/wire/flat/PartFlatWire.scala b/src/main/scala/resonantinduction/electrical/wire/flat/PartFlatWire.scala index 099df8442..7a438d28b 100644 --- a/src/main/scala/resonantinduction/electrical/wire/flat/PartFlatWire.scala +++ b/src/main/scala/resonantinduction/electrical/wire/flat/PartFlatWire.scala @@ -17,6 +17,7 @@ import net.minecraftforge.common.util.ForgeDirection import org.lwjgl.opengl.GL11 import resonantinduction.core.prefab.node.TMultipartNode import resonantinduction.core.prefab.part.ChickenBonesWrapper._ +import resonantinduction.core.prefab.part.connector.PartAbstract import resonantinduction.core.util.MultipartUtil import resonantinduction.electrical.wire.base.TWire import universalelectricity.api.core.grid.INodeProvider @@ -53,7 +54,7 @@ object PartFlatWire } } -class PartFlatWire extends TWire with TFacePart with TNormalOcclusion +class PartFlatWire extends PartAbstract with TWire with TFacePart with TNormalOcclusion { /** * The current side the wire is placed on diff --git a/src/main/scala/resonantinduction/electrical/wire/framed/PartFramedWire.scala b/src/main/scala/resonantinduction/electrical/wire/framed/PartFramedWire.scala index 1dd7c692d..f7966e40f 100644 --- a/src/main/scala/resonantinduction/electrical/wire/framed/PartFramedWire.scala +++ b/src/main/scala/resonantinduction/electrical/wire/framed/PartFramedWire.scala @@ -1,17 +1,16 @@ package resonantinduction.electrical.wire.framed +import resonantinduction.core.prefab.part.connector.PartFramedNode import resonantinduction.electrical.wire.base.TWire /** * A framed version of the electrical wire * @author Calclavia */ -class PartFramedWire extends TWire +class PartFramedWire extends PartFramedNode with TWire { def preparePlacement(side: Int, meta: Int) { setMaterial(meta) } - - override def getType = "FramedWire" }