Flat wires now have basic render
This commit is contained in:
parent
4598f78b60
commit
fc12296e5d
6 changed files with 73 additions and 73 deletions
|
@ -36,7 +36,7 @@ trait TColorable extends TMultiPart with TPart
|
|||
|
||||
def sendColorUpdate()
|
||||
{
|
||||
tile.getWriteStream(this).writeByte(2).writeInt(this.colorID)
|
||||
//tile.getWriteStream(this).writeByte(2).writeInt(this.colorID)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -51,7 +51,7 @@ trait TInsulatable extends TMultiPart with TPart
|
|||
|
||||
def sendInsulationUpdate()
|
||||
{
|
||||
tile.getWriteStream(this).writeByte(1).writeBoolean(this._insulated)
|
||||
// tile.getWriteStream(this).writeByte(1).writeBoolean(this._insulated)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -96,20 +96,20 @@ trait TInsulatable extends TMultiPart with TPart
|
|||
drops += new ItemStack(insulationItem)
|
||||
}
|
||||
|
||||
override def readDesc(packet: MCDataInput)
|
||||
{
|
||||
insulated = packet.readBoolean
|
||||
}
|
||||
|
||||
override def writeDesc(packet: MCDataOutput)
|
||||
{
|
||||
packet.writeBoolean(insulated)
|
||||
}
|
||||
|
||||
override def readDesc(packet: MCDataInput)
|
||||
{
|
||||
_insulated = packet.readBoolean
|
||||
}
|
||||
|
||||
def read(packet: MCDataInput, packetID: Int)
|
||||
{
|
||||
if (packetID == 1)
|
||||
insulated = packet.readBoolean
|
||||
_insulated = packet.readBoolean
|
||||
}
|
||||
|
||||
override def save(nbt: NBTTagCompound)
|
||||
|
|
|
@ -10,9 +10,15 @@ import net.minecraftforge.oredict.OreDictionary
|
|||
object ResonantUtil
|
||||
{
|
||||
val dyes = Array("dyeBlack", "dyeRed", "dyeGreen", "dyeBrown", "dyeBlue", "dyePurple", "dyeCyan", "dyeLightGray", "dyeGray", "dyePink", "dyeLime", "dyeYellow", "dyeLightBlue", "dyeMagenta", "dyeOrange", "dyeWhite")
|
||||
val dyeColors = Array[Int](1973019, 11743532, 3887386, 5320730, 2437522, 8073150, 2651799, 11250603, 4408131, 14188952, 4312372, 14602026, 6719955, 12801229, 15435844, 15790320)
|
||||
|
||||
def isDye(is: ItemStack): Int =
|
||||
{
|
||||
return (0 until dyes.size) find (i => OreDictionary.getOreID(is) != -1 && (OreDictionary.getOreName(OreDictionary.getOreID(is)) == dyes(i))) getOrElse (-1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the color hex code from the color's ID
|
||||
*/
|
||||
def getColorHex(id: Int): Int = dyeColors(id)
|
||||
}
|
||||
|
|
|
@ -7,11 +7,18 @@ import net.minecraft.nbt.NBTTagCompound
|
|||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import resonantinduction.core.prefab.part.connector._
|
||||
import resonantinduction.electrical.ElectricalContent
|
||||
import universalelectricity.api.core.grid.{INode, INodeProvider}
|
||||
import universalelectricity.api.core.grid.INodeProvider
|
||||
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
|
||||
*
|
||||
* @author Calclavia
|
||||
*/
|
||||
abstract class TWire extends TMultiPart with TNodePartConnector with TPart with TMaterial[WireMaterial] with TInsulatable with TColorable
|
||||
|
@ -32,6 +39,13 @@ abstract class TWire extends TMultiPart with TNodePartConnector with TPart with
|
|||
/**
|
||||
* Packet Methods
|
||||
*/
|
||||
override def writeDesc(packet: MCDataOutput)
|
||||
{
|
||||
super[TMaterial].writeDesc(packet)
|
||||
super[TInsulatable].writeDesc(packet)
|
||||
super[TColorable].writeDesc(packet)
|
||||
}
|
||||
|
||||
override def readDesc(packet: MCDataInput)
|
||||
{
|
||||
super[TMaterial].readDesc(packet)
|
||||
|
@ -39,11 +53,15 @@ abstract class TWire extends TMultiPart with TNodePartConnector with TPart with
|
|||
super[TColorable].readDesc(packet)
|
||||
}
|
||||
|
||||
override def writeDesc(packet: MCDataOutput)
|
||||
override final def read(packet: MCDataInput)
|
||||
{
|
||||
super[TMaterial].writeDesc(packet)
|
||||
super[TInsulatable].writeDesc(packet)
|
||||
super[TColorable].writeDesc(packet)
|
||||
read(packet, packet.readUByte)
|
||||
}
|
||||
|
||||
override def read(packet: MCDataInput, packetID: Int)
|
||||
{
|
||||
super[TInsulatable].read(packet, packetID)
|
||||
super[TColorable].read(packet, packetID)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,17 +81,6 @@ abstract class TWire extends TMultiPart with TNodePartConnector with TPart with
|
|||
super[TColorable].save(nbt)
|
||||
}
|
||||
|
||||
override def read(packet: MCDataInput)
|
||||
{
|
||||
read(packet, packet.readUByte)
|
||||
}
|
||||
|
||||
override def read(packet: MCDataInput, packetID: Int): Unit =
|
||||
{
|
||||
super[TInsulatable].read(packet,packetID)
|
||||
super[TColorable].read(packet,packetID)
|
||||
}
|
||||
|
||||
/**
|
||||
* Can this conductor connect with another potential wire object?
|
||||
*/
|
||||
|
|
|
@ -37,12 +37,15 @@ object PartFlatWire
|
|||
{
|
||||
var selectionBounds = Array.ofDim[Cuboid6](3, 6)
|
||||
var occlusionBounds = Array.ofDim[Cuboid6](3, 6)
|
||||
init()
|
||||
|
||||
for (t <- 0 until 3)
|
||||
def init()
|
||||
{
|
||||
lazy val selection: Cuboid6 = new Cuboid6(0, 0, 0, 1, (t + 2) / 16D, 1).expand(-0.005)
|
||||
lazy val occlusion: Cuboid6 = new Cuboid6(2 / 8D, 0, 2 / 8D, 6 / 8D, (t + 2) / 16D, 6 / 8D)
|
||||
for (t <- 0 until 3)
|
||||
{
|
||||
val selection = new Cuboid6(0, 0, 0, 1, (t + 2) / 16D, 1).expand(-0.005)
|
||||
val occlusion = new Cuboid6(2 / 8D, 0, 2 / 8D, 6 / 8D, (t + 2) / 16D, 6 / 8D)
|
||||
|
||||
for (s <- 0 until 6)
|
||||
{
|
||||
selectionBounds(t)(s) = selection.copy.apply(Rotation.sideRotations(s).at(Vector3.center))
|
||||
|
@ -135,13 +138,6 @@ class PartFlatWire extends TWire with TFacePart with TNormalOcclusion
|
|||
tag.setInteger("connMap", this.connMap)
|
||||
}
|
||||
|
||||
override def readDesc(packet: MCDataInput)
|
||||
{
|
||||
super.readDesc(packet)
|
||||
side = packet.readByte
|
||||
connMap = packet.readInt
|
||||
}
|
||||
|
||||
override def writeDesc(packet: MCDataOutput)
|
||||
{
|
||||
super.writeDesc(packet)
|
||||
|
@ -149,20 +145,27 @@ class PartFlatWire extends TWire with TFacePart with TNormalOcclusion
|
|||
packet.writeInt(connMap)
|
||||
}
|
||||
|
||||
override def readDesc(packet: MCDataInput)
|
||||
{
|
||||
super.readDesc(packet)
|
||||
side = packet.readByte
|
||||
connMap = packet.readInt
|
||||
}
|
||||
|
||||
override def read(packet: MCDataInput, packetID: Int)
|
||||
{
|
||||
super.read(packet, packetID)
|
||||
|
||||
if (packetID == 0)
|
||||
{
|
||||
connMap = packet.readInt
|
||||
tile.markRender
|
||||
}
|
||||
/*
|
||||
if (packetID == 3)
|
||||
{
|
||||
connMap = packet.readInt
|
||||
tile.markRender
|
||||
}*/
|
||||
}
|
||||
|
||||
def sendConnUpdate()
|
||||
{
|
||||
tile.getWriteStream(this).writeByte(0).writeInt(this.connMap)
|
||||
//tile.getWriteStream(this).writeByte(3).writeInt(this.connMap)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -201,7 +204,7 @@ class PartFlatWire extends TWire with TFacePart with TNormalOcclusion
|
|||
super.onChunkLoad()
|
||||
}
|
||||
|
||||
override def onAdded
|
||||
override def onAdded()
|
||||
{
|
||||
super.onAdded()
|
||||
|
||||
|
@ -221,7 +224,7 @@ class PartFlatWire extends TWire with TFacePart with TNormalOcclusion
|
|||
super.onPartChanged(part)
|
||||
}
|
||||
|
||||
override def onNeighborChanged
|
||||
override def onNeighborChanged()
|
||||
{
|
||||
if (!world.isRemote)
|
||||
if (dropIfCantStay)
|
||||
|
@ -262,19 +265,13 @@ class PartFlatWire extends TWire with TFacePart with TNormalOcclusion
|
|||
return 4
|
||||
}
|
||||
|
||||
def getSlotMask: Int =
|
||||
{
|
||||
return 1 << this.side
|
||||
}
|
||||
def getSlotMask: Int = 1 << side
|
||||
|
||||
override def getSubParts: JIterable[IndexedCuboid6] = Seq(new IndexedCuboid6(0, PartFlatWire.selectionBounds(getThickness)(side)))
|
||||
|
||||
def getOcclusionBoxes: JIterable[Cuboid6] = Seq(PartFlatWire.occlusionBounds(getThickness)(side))
|
||||
|
||||
def getThickness: Int =
|
||||
{
|
||||
return if (insulated) 2 else 1
|
||||
}
|
||||
def getThickness: Int = if (insulated) 2 else 1
|
||||
|
||||
override def solid(arg0: Int) = false
|
||||
|
||||
|
@ -287,18 +284,6 @@ class PartFlatWire extends TWire with TFacePart with TNormalOcclusion
|
|||
return RenderFlatWire.flatWireTexture
|
||||
}
|
||||
|
||||
def getColour: Colour =
|
||||
{
|
||||
if (insulated)
|
||||
{
|
||||
val color: Colour = new ColourARGB(ItemDye.field_150922_c(colorID))
|
||||
color.a = 255.asInstanceOf[Byte]
|
||||
return color
|
||||
}
|
||||
|
||||
return new ColourARGB(material.color)
|
||||
}
|
||||
|
||||
def useStaticRenderer: Boolean = true
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
|
|
@ -8,9 +8,19 @@ import codechicken.lib.render._
|
|||
import codechicken.lib.render.uv._
|
||||
import codechicken.lib.vec.{Cuboid6, Rotation, Transformation, Translation, Vector3}
|
||||
import net.minecraft.util.IIcon
|
||||
import resonantinduction.core.util.ResonantUtil
|
||||
|
||||
object RenderFlatWire
|
||||
{
|
||||
var flatWireTexture: IIcon = null
|
||||
var reorientSide: Array[Int] = Array[Int](0, 3, 3, 0, 0, 3)
|
||||
/**
|
||||
* Array of all built models. These will be generated on demand.
|
||||
*/
|
||||
var wireModels: Array[CCModel] = new Array[CCModel](3 * 6 * 256)
|
||||
var invModels: Array[CCModel] = new Array[CCModel](3)
|
||||
val gen_inst = new WireModelGenerator
|
||||
|
||||
/**
|
||||
* Puts verts into model m starting at index k
|
||||
*/
|
||||
|
@ -79,9 +89,9 @@ object RenderFlatWire
|
|||
|
||||
def render(wire: PartFlatWire, pos: Vector3)
|
||||
{
|
||||
val colorCode = wire.getColour.pack
|
||||
val colorCode = ResonantUtil.getColorHex(wire.getColor)
|
||||
val operation = if (colorCode == -1) ColourMultiplier.instance(0xFFFFFF) else new ColourMultiplier(colorCode)
|
||||
val model: CCModel = getOrGenerateModel(modelKey(wire))
|
||||
val model = getOrGenerateModel(modelKey(wire))
|
||||
model.render(new Translation(pos), new IconTransformation(wire.getIcon), operation)
|
||||
}
|
||||
|
||||
|
@ -128,14 +138,6 @@ object RenderFlatWire
|
|||
}
|
||||
}
|
||||
|
||||
var flatWireTexture: IIcon = null
|
||||
var reorientSide: Array[Int] = Array[Int](0, 3, 3, 0, 0, 3)
|
||||
/**
|
||||
* Array of all built models. These will be generated on demand.
|
||||
*/
|
||||
var wireModels: Array[CCModel] = new Array[CCModel](3 * 6 * 256)
|
||||
var invModels: Array[CCModel] = new Array[CCModel](3)
|
||||
val gen_inst = new WireModelGenerator
|
||||
|
||||
class UVT(t: Transformation) extends UVTransformation
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue