From 63be5568909ad4c848ce8de461e99e29fb088570 Mon Sep 17 00:00:00 2001 From: Calclavia Date: Sat, 13 Sep 2014 21:57:24 +0800 Subject: [PATCH] Override multi-inheritance method --- .../core/prefab/part/TPart.scala | 2 + .../electrical/wire/base/TWire.scala | 41 ++++++++++++++++++- .../electrical/wire/flat/PartFlatWire.java | 37 +---------------- 3 files changed, 43 insertions(+), 37 deletions(-) diff --git a/src/main/scala/resonantinduction/core/prefab/part/TPart.scala b/src/main/scala/resonantinduction/core/prefab/part/TPart.scala index 1e3dd7f2f..d9b13993a 100644 --- a/src/main/scala/resonantinduction/core/prefab/part/TPart.scala +++ b/src/main/scala/resonantinduction/core/prefab/part/TPart.scala @@ -56,4 +56,6 @@ trait TPart extends TMultiPart with TraitTicker } return false } + + override def toString: String = "[" + getClass.getSimpleName + "]" + x + "x " + y + "y " + z + "z" } \ No newline at end of file diff --git a/src/main/scala/resonantinduction/electrical/wire/base/TWire.scala b/src/main/scala/resonantinduction/electrical/wire/base/TWire.scala index 229e463f7..50f2c7dfe 100644 --- a/src/main/scala/resonantinduction/electrical/wire/base/TWire.scala +++ b/src/main/scala/resonantinduction/electrical/wire/base/TWire.scala @@ -1,8 +1,11 @@ package resonantinduction.electrical.wire.base +import codechicken.lib.data.{MCDataOutput, MCDataInput} +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} +import resonantinduction.core.prefab.part.{TPart, TColorable, TInsulatable, TMaterial} import resonantinduction.electrical.ElectricalContent import universalelectricity.api.core.grid.INodeProvider import universalelectricity.simulator.dc.DCNode @@ -11,7 +14,7 @@ import universalelectricity.simulator.dc.DCNode * Trait implemented by wires * @author Calclavia */ -abstract class TWire extends TColorable with TMaterial[WireMaterial] with TInsulatable +abstract class TWire extends TMultiPart with TPart with TMaterial[WireMaterial] with TInsulatable with TColorable { override protected val insulationItem: Item = ElectricalContent.itemInsulation @@ -26,6 +29,40 @@ abstract class TWire extends TColorable with TMaterial[WireMaterial] with TInsul override protected def getItem = new ItemStack(ElectricalContent.itemInsulation, getMaterialID) + /** + * Packet Methods + */ + override def readDesc(packet: MCDataInput) + { + super[TMaterial].readDesc(packet) + super[TInsulatable].readDesc(packet) + super[TColorable].readDesc(packet) + } + + override def writeDesc(packet: MCDataOutput) + { + super[TMaterial].writeDesc(packet) + super[TInsulatable].writeDesc(packet) + super[TColorable].writeDesc(packet) + } + + /** + * NBT Methods + */ + override def load(nbt: NBTTagCompound) + { + super[TMaterial].load(nbt) + super[TInsulatable].load(nbt) + super[TColorable].load(nbt) + } + + override def save(nbt: NBTTagCompound) + { + super[TMaterial].save(nbt) + super[TInsulatable].save(nbt) + super[TColorable].save(nbt) + } + /** * Can this conductor connect with another potential wire object? */ diff --git a/src/main/scala/resonantinduction/electrical/wire/flat/PartFlatWire.java b/src/main/scala/resonantinduction/electrical/wire/flat/PartFlatWire.java index 4188eb4d2..0041c9432 100644 --- a/src/main/scala/resonantinduction/electrical/wire/flat/PartFlatWire.java +++ b/src/main/scala/resonantinduction/electrical/wire/flat/PartFlatWire.java @@ -28,6 +28,7 @@ import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import org.lwjgl.opengl.GL11; +import resonantinduction.core.util.MultipartUtil; import resonantinduction.electrical.wire.base.TWire; import resonantinduction.electrical.wire.base.WireMaterial; @@ -81,20 +82,10 @@ public class PartFlatWire extends TWire implements TFacePart, TNormalOcclusion } - public PartFlatWire(int typeID) - { - this(WireMaterial.values()[typeID]); - } - - public PartFlatWire(WireMaterial type) - { - material = type; - } - public void preparePlacement(int side, int meta) { this.side = (byte) (side ^ 1); - this.setMaterial(meta); + setMaterial(meta); } /** @@ -943,28 +934,4 @@ public class PartFlatWire extends TWire implements TFacePart, TNormalOcclusion CCRenderState.reset(); RenderFlatWire.renderBreakingOverlay(renderBlocks.overrideBlockTexture, this); } - - /** - * Utility method to aid in initializing this or subclasses, usually when you need to change the - * wire to another type - * - * @param otherCable the wire to copy from - */ - public void copyFrom(PartFlatWire otherCable) - { - this.isInsulated = otherCable.isInsulated; - this.color = otherCable.color; - this.connections_$eq(otherCable.connections()); - this.material = otherCable.material; - this.side = otherCable.side; - this.connMap = otherCable.connMap; - //this.setNetwork(otherCable.getNetwork()); - //this.getNetwork().setBufferFor(this, otherCable.getNetwork().getBufferOf(otherCable)); - } - - @Override - public String toString() - { - return "[PartFlatWire]" + x() + "x " + y() + "y " + z() + "z " + getSlotMask() + "s "; - } } \ No newline at end of file