Actually use scala traits how they deserve to be used in microblocks

This commit is contained in:
Chicken-Bones committed 2015-04-01 22:36:57 +10:00
1 parent 8f17874412
commit 89f560ca8d
4 files changed
+13 -29

No files matched your search

@@ -38,13 +38,13 @@ object CornerMicroClass extends MicroblockClass
def create(client:Boolean) =
if(client)
new CornerMicroblockClient
new CornerMicroblock with CommonMicroblockClient
else
new CornerMicroblock
def create(size:Int, slot:Int, material:Int, client:Boolean) =
if(client)
new CornerMicroblockClient(size, slot, material)
new CornerMicroblock(size, slot, material)with CommonMicroblockClient
else
new CornerMicroblock(size, slot, material)
@@ -53,11 +53,6 @@ object CornerMicroClass extends MicroblockClass
def getResistanceFactor = 1
}
class CornerMicroblockClient(shape$:Byte = 0, material$:Int = 0) extends CornerMicroblock(shape$, material$) with CommonMicroblockClient
{
def this(size:Int, slot:Int, material:Int) = this((size<<4|(slot-7)).toByte, material)
}
class CornerMicroblock(shape$:Byte = 0, material$:Int = 0) extends CommonMicroblock(shape$, material$)
{
def this(size:Int, slot:Int, material:Int) = this((size<<4|(slot-7)).toByte, material)
@@ -88,13 +88,13 @@ object EdgeMicroClass extends MicroblockClass
def create(client:Boolean) =
if(client)
new EdgeMicroblockClient
new EdgeMicroblock with CommonMicroblockClient
else
new EdgeMicroblock
def create(size:Int, slot:Int, material:Int, client:Boolean) =
if(client)
new EdgeMicroblockClient(size, slot, material)
new EdgeMicroblock(size, slot, material) with CommonMicroblockClient
else
new EdgeMicroblock(size, slot, material)
@@ -114,11 +114,6 @@ class EdgeMicroblock(shape$:Byte = 0, material$:Int = 0) extends CommonMicrobloc
override def getSlot = getShape+15
}
class EdgeMicroblockClient(shape$:Byte = 0, material$:Int = 0) extends EdgeMicroblock(shape$, material$) with CommonMicroblockClient
{
def this(size:Int, slot:Int, material:Int) = this((size<<4|(slot-15)).toByte, material)
}
object PostMicroClass
{
var aBounds:Array[Cuboid6] = new Array(256)
@@ -138,13 +133,13 @@ object PostMicroClass
def create(client:Boolean) =
if(client)
new PostMicroblockClient
new PostMicroblock with PostMicroblockClient
else
new PostMicroblock
def create(size:Int, slot:Int, material:Int, client:Boolean) =
if(client)
new PostMicroblockClient(size, slot, material)
new PostMicroblock(size, slot, material) with PostMicroblockClient
else
new PostMicroblock(size, slot, material)
@@ -153,13 +148,11 @@ object PostMicroClass
def getResistanceFactor = 0.5F
}
class PostMicroblockClient(shape$:Byte = 0, material$:Int = 0) extends PostMicroblock(shape$, material$) with MicroblockClient
trait PostMicroblockClient extends PostMicroblock with MicroblockClient
{
var renderBounds1:Cuboid6 = _
var renderBounds2:Cuboid6 = _
def this(size:Int, orient:Int, material:Int) = this((size<<4|orient).toByte, material)
override def render(pos:Vector3, pass:Int)
{
val mat = getIMaterial
@@ -40,13 +40,13 @@ object FaceMicroClass extends MicroblockClass
def create(client:Boolean) =
if(client)
new FaceMicroblockClient
new FaceMicroblock with FaceMicroblockClient
else
new FaceMicroblock
def create(size:Int, slot:Int, material:Int, client:Boolean) =
if(client)
new FaceMicroblockClient(size, slot, material)
new FaceMicroblock(size, slot, material) with FaceMicroblockClient
else
new FaceMicroblock(size, slot, material)
@@ -55,10 +55,8 @@ object FaceMicroClass extends MicroblockClass
def getResistanceFactor = 1
}
class FaceMicroblockClient(shape$:Byte = 0, material$:Int = 0) extends FaceMicroblock(shape$, material$) with CommonMicroblockClient
trait FaceMicroblockClient extends CommonMicroblockClient
{
def this(size:Int, shape:Int, material:Int) = this((size<<4|shape).toByte, material)
override def render(pos:Vector3, pass:Int) {
if(pass < 0)
MicroblockRender.renderCuboid(pos, getIMaterial, pass, getBounds, 0)
@@ -56,13 +56,13 @@ object HollowMicroClass extends MicroblockClass
def create(client: Boolean) =
if (client)
new HollowMicroblockClient
new HollowMicroblock with HollowMicroblockClient
else
new HollowMicroblock
def create(size: Int, slot: Int, material: Int, client: Boolean) =
if (client)
new HollowMicroblockClient(size, slot, material)
new HollowMicroblock(size, slot, material) with HollowMicroblockClient
else
new HollowMicroblock(size, slot, material)
@@ -71,12 +71,10 @@ object HollowMicroClass extends MicroblockClass
def getResistanceFactor = 1
}
class HollowMicroblockClient(shape$: Byte = 0, material$: Int = 0) extends HollowMicroblock(shape$, material$) with CommonMicroblockClient
trait HollowMicroblockClient extends HollowMicroblock with CommonMicroblockClient
{
renderMask |= 8 << 8
def this(size: Int, shape: Int, material: Int) = this((size << 4 | shape).toByte, material)
override def recalcBounds() {
super.recalcBounds()
renderMask = renderMask & 0xFF | getHollowSize << 8