mirror of
https://github.com/GTNewHorizons/ForgeMultipart.git
synced 2026-11-22 05:02:32 +00:00
More cleaning and generalisation of microblock classes
This commit is contained in:
1 parent
89f560ca8d
commit
734615e78b
9 files changed
+44
-74
No files matched your search
@@ -96,10 +96,10 @@ trait MicroblockClient extends Microblock with TIconHitEffects with IMicroMateri
|
||||
override def getRenderBounds = getBounds
|
||||
}
|
||||
|
||||
abstract class Microblock(var shape:Byte = 0, var material:Int = 0) extends TCuboidPart
|
||||
abstract class Microblock(var material:Int = 0) extends TCuboidPart
|
||||
{
|
||||
def this(size:Int, shape:Int, material:Int) = this((size<<4|shape).toByte, material)
|
||||
|
||||
var shape:Byte = 0
|
||||
|
||||
override def getStrength(hit:MovingObjectPosition, player:EntityPlayer) = getIMaterial match {
|
||||
case null => super.getStrength(hit, player)
|
||||
case mat => mat.getStrength(player)
|
||||
@@ -111,6 +111,8 @@ abstract class Microblock(var shape:Byte = 0, var material:Int = 0) extends TCub
|
||||
|
||||
def getShape = shape&0xF
|
||||
|
||||
def setShape(size:Int, slot:Int) = shape = (size<<4|shape).toByte
|
||||
|
||||
def getMaterial = material
|
||||
|
||||
def getIMaterial = MicroMaterialRegistry.getMaterial(material)
|
||||
@@ -190,12 +192,12 @@ trait CommonMicroblockClient extends CommonMicroblock with MicroblockClient with
|
||||
}
|
||||
}
|
||||
|
||||
abstract class CommonMicroblock(shape$:Byte = 0, material$:Int = 0) extends Microblock(shape$, material$) with JPartialOcclusion with TMicroOcclusion with TSlottedPart
|
||||
abstract class CommonMicroblock(material$:Int) extends Microblock(material$) with JPartialOcclusion with TMicroOcclusion with TSlottedPart
|
||||
{
|
||||
def microClass:MicroblockClass
|
||||
|
||||
def getType = microClass.getName
|
||||
|
||||
|
||||
def getSlot = getShape
|
||||
|
||||
def getSlotMask = 1<<getSlot
|
||||
|
||||
@@ -36,26 +36,20 @@ object CornerMicroClass extends MicroblockClass
|
||||
|
||||
def getName = "mcr_cnr"
|
||||
|
||||
def create(client:Boolean) =
|
||||
def create(client:Boolean, material:Int) =
|
||||
if(client)
|
||||
new CornerMicroblock with CommonMicroblockClient
|
||||
new CornerMicroblock(material)with CommonMicroblockClient
|
||||
else
|
||||
new CornerMicroblock
|
||||
|
||||
def create(size:Int, slot:Int, material:Int, client:Boolean) =
|
||||
if(client)
|
||||
new CornerMicroblock(size, slot, material)with CommonMicroblockClient
|
||||
else
|
||||
new CornerMicroblock(size, slot, material)
|
||||
new CornerMicroblock(material)
|
||||
|
||||
def placementProperties = CornerPlacement
|
||||
|
||||
def getResistanceFactor = 1
|
||||
}
|
||||
|
||||
class CornerMicroblock(shape$:Byte = 0, material$:Int = 0) extends CommonMicroblock(shape$, material$)
|
||||
class CornerMicroblock(material$:Int = 0) extends CommonMicroblock(material$)
|
||||
{
|
||||
def this(size:Int, slot:Int, material:Int) = this((size<<4|(slot-7)).toByte, material)
|
||||
override def setShape(size: Int, slot: Int) = shape = (size<<4|(slot-7)).toByte
|
||||
|
||||
def microClass = CornerMicroClass
|
||||
|
||||
|
||||
@@ -40,7 +40,8 @@ object EdgePlacement extends PlacementProperties
|
||||
{
|
||||
if(pmt.size%2 == 1) return null
|
||||
|
||||
val part = PostMicroClass.create(pmt.size, pmt.hit.sideHit>>1, pmt.material, pmt.world.isRemote)
|
||||
val part = PostMicroClass.create(pmt.world.isRemote, pmt.material)
|
||||
part.setShape(pmt.size, pmt.hit.sideHit>>1)
|
||||
if(pmt.doExpand)
|
||||
{
|
||||
val hpart = pmt.htile.partList(ExtendedMOP.getData[(Int, _)](pmt.hit)._1)
|
||||
@@ -86,27 +87,21 @@ object EdgeMicroClass extends MicroblockClass
|
||||
|
||||
def getName = "mcr_edge"
|
||||
|
||||
def create(client:Boolean) =
|
||||
def create(client:Boolean, material:Int) =
|
||||
if(client)
|
||||
new EdgeMicroblock with CommonMicroblockClient
|
||||
new EdgeMicroblock(material) with CommonMicroblockClient
|
||||
else
|
||||
new EdgeMicroblock
|
||||
|
||||
def create(size:Int, slot:Int, material:Int, client:Boolean) =
|
||||
if(client)
|
||||
new EdgeMicroblock(size, slot, material) with CommonMicroblockClient
|
||||
else
|
||||
new EdgeMicroblock(size, slot, material)
|
||||
new EdgeMicroblock(material)
|
||||
|
||||
def placementProperties = EdgePlacement
|
||||
|
||||
def getResistanceFactor = 0.5F
|
||||
}
|
||||
|
||||
class EdgeMicroblock(shape$:Byte = 0, material$:Int = 0) extends CommonMicroblock(shape$, material$) with TEdgePart
|
||||
class EdgeMicroblock(material$:Int = 0) extends CommonMicroblock(material$) with TEdgePart
|
||||
{
|
||||
def this(size:Int, slot:Int, material:Int) = this((size<<4|(slot-15)).toByte, material)
|
||||
|
||||
override def setShape(size: Int, slot: Int) = shape = (size<<4|(slot-15)).toByte
|
||||
|
||||
def microClass = EdgeMicroClass
|
||||
|
||||
def getBounds = EdgeMicroClass.aBounds(shape)
|
||||
@@ -131,19 +126,13 @@ object PostMicroClass
|
||||
|
||||
def getName = "mcr_post"
|
||||
|
||||
def create(client:Boolean) =
|
||||
def create(client:Boolean, material:Int) =
|
||||
if(client)
|
||||
new PostMicroblock with PostMicroblockClient
|
||||
new PostMicroblock(material) with PostMicroblockClient
|
||||
else
|
||||
new PostMicroblock
|
||||
new PostMicroblock(material)
|
||||
|
||||
def create(size:Int, slot:Int, material:Int, client:Boolean) =
|
||||
if(client)
|
||||
new PostMicroblock(size, slot, material) with PostMicroblockClient
|
||||
else
|
||||
new PostMicroblock(size, slot, material)
|
||||
|
||||
def register() = MultiPartRegistry.registerParts((_, c:Boolean) => create(c), getName)
|
||||
def register() = MultiPartRegistry.registerParts((_, c:Boolean) => create(c, 0), getName)
|
||||
|
||||
def getResistanceFactor = 0.5F
|
||||
}
|
||||
@@ -225,12 +214,10 @@ trait PostMicroblockClient extends PostMicroblock with MicroblockClient
|
||||
}
|
||||
}
|
||||
|
||||
class PostMicroblock(shape$:Byte = 0, material$:Int = 0) extends Microblock(shape$, material$) with JPartialOcclusion with TNormalOcclusion
|
||||
class PostMicroblock(material$:Int = 0) extends Microblock(material$) with JPartialOcclusion with TNormalOcclusion
|
||||
{
|
||||
def this(size:Int, orient:Int, material:Int) = this((size<<4|orient).toByte, material)
|
||||
|
||||
override def getType = PostMicroClass.getName
|
||||
|
||||
|
||||
def getBounds = PostMicroClass.aBounds(shape)
|
||||
|
||||
def getOcclusionBoxes = Seq(getBounds)
|
||||
|
||||
@@ -38,17 +38,11 @@ object FaceMicroClass extends MicroblockClass
|
||||
|
||||
def getName = "mcr_face"
|
||||
|
||||
def create(client:Boolean) =
|
||||
def create(client:Boolean, material:Int) =
|
||||
if(client)
|
||||
new FaceMicroblock with FaceMicroblockClient
|
||||
new FaceMicroblock(material) with FaceMicroblockClient
|
||||
else
|
||||
new FaceMicroblock
|
||||
|
||||
def create(size:Int, slot:Int, material:Int, client:Boolean) =
|
||||
if(client)
|
||||
new FaceMicroblock(size, slot, material) with FaceMicroblockClient
|
||||
else
|
||||
new FaceMicroblock(size, slot, material)
|
||||
new FaceMicroblock(material)
|
||||
|
||||
def placementProperties = FacePlacement
|
||||
|
||||
@@ -70,10 +64,8 @@ trait FaceMicroblockClient extends CommonMicroblockClient
|
||||
}
|
||||
}
|
||||
|
||||
class FaceMicroblock(shape$:Byte = 0, material$:Int = 0) extends CommonMicroblock(shape$, material$) with TFacePart
|
||||
class FaceMicroblock(material$:Int = 0) extends CommonMicroblock(material$) with TFacePart
|
||||
{
|
||||
def this(size:Int, shape:Int, material:Int) = this((size<<4|shape).toByte, material)
|
||||
|
||||
def microClass = FaceMicroClass
|
||||
|
||||
def getBounds = FaceMicroClass.aBounds(shape)
|
||||
|
||||
@@ -54,17 +54,11 @@ object HollowMicroClass extends MicroblockClass
|
||||
|
||||
def getName = "mcr_hllw"
|
||||
|
||||
def create(client: Boolean) =
|
||||
if (client)
|
||||
new HollowMicroblock with HollowMicroblockClient
|
||||
def create(client:Boolean, material:Int) =
|
||||
if(client)
|
||||
new HollowMicroblock(material) with HollowMicroblockClient
|
||||
else
|
||||
new HollowMicroblock
|
||||
|
||||
def create(size: Int, slot: Int, material: Int, client: Boolean) =
|
||||
if (client)
|
||||
new HollowMicroblock(size, slot, material) with HollowMicroblockClient
|
||||
else
|
||||
new HollowMicroblock(size, slot, material)
|
||||
new HollowMicroblock(material)
|
||||
|
||||
def placementProperties = HollowPlacement
|
||||
|
||||
@@ -178,10 +172,8 @@ trait HollowMicroblockClient extends HollowMicroblock with CommonMicroblockClien
|
||||
}
|
||||
}
|
||||
|
||||
class HollowMicroblock(shape$: Byte = 0, material$: Int = 0) extends CommonMicroblock(shape$, material$) with TFacePart with TNormalOcclusion
|
||||
class HollowMicroblock(material$: Int = 0) extends CommonMicroblock(material$) with TFacePart with TNormalOcclusion
|
||||
{
|
||||
def this(size: Int, shape: Int, material: Int) = this((size << 4 | shape).toByte, material)
|
||||
|
||||
def microClass = HollowMicroClass
|
||||
|
||||
def getBounds: Cuboid6 = FaceMicroClass.aBounds(shape)
|
||||
|
||||
@@ -150,7 +150,8 @@ object ItemMicroPartRenderer extends IItemRenderer
|
||||
CCRenderState.useNormals = true
|
||||
CCRenderState.pullLightmap()
|
||||
CCRenderState.startDrawing()
|
||||
val part = mcrClass.create(size, mcrClass.itemSlot, getMaterialID(item), true).asInstanceOf[MicroblockClient]
|
||||
val part = mcrClass.create(true, getMaterialID(item)).asInstanceOf[MicroblockClient]
|
||||
part.setShape(size, mcrClass.itemSlot)
|
||||
part.render(new Vector3(0.5, 0.5, 0.5).subtract(part.getBounds.center), -1)
|
||||
CCRenderState.draw()
|
||||
GL11.glPopMatrix()
|
||||
|
||||
@@ -8,9 +8,7 @@ trait MicroblockClass
|
||||
|
||||
def getName:String
|
||||
|
||||
def create(client:Boolean):CommonMicroblock
|
||||
|
||||
def create(size:Int, slot:Int, material:Int, client:Boolean):CommonMicroblock
|
||||
def create(client:Boolean, material:Int):CommonMicroblock
|
||||
|
||||
def placementProperties:PlacementProperties
|
||||
|
||||
|
||||
@@ -15,6 +15,6 @@ object MicroblockClassRegistry
|
||||
|
||||
classes(id) = mcrClass
|
||||
mcrClass.classID = id
|
||||
MultiPartRegistry.registerParts((_, c:Boolean) => mcrClass.create(c), mcrClass.getName)
|
||||
MultiPartRegistry.registerParts((_, c:Boolean) => mcrClass.create(c, 0), mcrClass.getName)
|
||||
}
|
||||
}
|
||||
@@ -159,5 +159,9 @@ class MicroblockPlacement(val player:EntityPlayer, val hit:MovingObjectPosition,
|
||||
def getHitDepth(vhit:Vector3, side:Int):Double =
|
||||
vhit.copy.scalarProject(Rotation.axes(side)) + (side%2^1)
|
||||
|
||||
def create(size:Int, slot:Int, material:Int) = mcrClass.create(size, slot, material, world.isRemote)
|
||||
def create(size:Int, slot:Int, material:Int) = {
|
||||
val part = mcrClass.create(world.isRemote, material)
|
||||
part.setShape(size, slot)
|
||||
part
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user