diff --git a/codechicken/microblock/BlockMicroMaterial.scala b/codechicken/microblock/BlockMicroMaterial.scala index 7ec7ec5..78e28cf 100644 --- a/codechicken/microblock/BlockMicroMaterial.scala +++ b/codechicken/microblock/BlockMicroMaterial.scala @@ -48,9 +48,9 @@ class BlockMicroMaterial(val block:Block, val meta:Int = 0) extends IMicroMateri def getRenderPass = if(block.canRenderInPass(1)) 1 else 0 - def renderMicroFace(verts:Array[Vertex5], side:Int, pos:Vector3, lightMatrix:LightMatrix, part:Microblock) + def renderMicroFace(verts:Array[Vertex5], side:Int, pos:Vector3, lightMatrix:LightMatrix, part:IMicroMaterialRender) { - renderMicroFace(verts, side, pos, lightMatrix, getColour(part.tile), icont) + renderMicroFace(verts, side, pos, lightMatrix, getColour(part), icont) } def renderMicroFace(verts:Array[Vertex5], side:Int, pos:Vector3, lightMatrix:LightMatrix, colour:Int, uvt:IUVTransformation) @@ -84,11 +84,11 @@ class BlockMicroMaterial(val block:Block, val meta:Int = 0) extends IMicroMateri } } - def getColour(tile:TileEntity) = - if(tile == null) + def getColour(part:IMicroMaterialRender) = + if(part.world == null) block.getBlockColor<<8|0xFF else - block.colorMultiplier(tile.worldObj, tile.xCoord, tile.yCoord, tile.zCoord)<<8|0xFF + block.colorMultiplier(part.world, part.x, part.y, part.z)<<8|0xFF @SideOnly(Side.CLIENT) def getBreakingIcon(side:Int) = block.getIcon(side, meta) diff --git a/codechicken/microblock/CommonMicroblock.scala b/codechicken/microblock/CommonMicroblock.scala index a0d638f..443e455 100644 --- a/codechicken/microblock/CommonMicroblock.scala +++ b/codechicken/microblock/CommonMicroblock.scala @@ -63,7 +63,23 @@ object CommonMicroblock } } -trait MicroblockClient extends Microblock with TIconHitEffects +object JMicroblockClient +{ + def renderCuboid(pos:Vector3, olm:LazyLightMatrix, mat:IMicroMaterial, c:Cuboid6, sideMask:Int, part:IMicroMaterialRender) + { + var lightMatrix:LightMatrix = null + if(olm != null) + lightMatrix = olm.lightMatrix + + RenderUtils.renderBlock(c, sideMask, new IFaceRenderer() + { + def renderFace(face:Array[Vertex5], side:Int) = + mat.renderMicroFace(face, side, pos, lightMatrix, part) + }) + } +} + +trait MicroblockClient extends Microblock with TIconHitEffects with IMicroMaterialRender { import CommonMicroblock._ @@ -75,23 +91,13 @@ import CommonMicroblock._ return Block.stone.getIcon(0, 0) } - def render(pos:Vector3, olm:LazyLightMatrix, mat:IMicroMaterial, c:Cuboid6, sideMask:Int) - { + def render(pos:Vector3, olm:LazyLightMatrix, mat:IMicroMaterial, c:Cuboid6, sideMask:Int) = renderCuboid(pos, olm, mat, c, sideMask) - } - def renderCuboid(pos:Vector3, olm:LazyLightMatrix, mat:IMicroMaterial, c:Cuboid6, sideMask:Int) - { - var lightMatrix:LightMatrix = null - if(olm != null) - lightMatrix = olm.lightMatrix - - RenderUtils.renderBlock(c, sideMask, new IFaceRenderer() - { - def renderFace(face:Array[Vertex5], side:Int) = - mat.renderMicroFace(face, side, pos, lightMatrix, MicroblockClient.this) - }) - } + def renderCuboid(pos:Vector3, olm:LazyLightMatrix, mat:IMicroMaterial, c:Cuboid6, sideMask:Int) = + JMicroblockClient.renderCuboid(pos, olm, mat, c, sideMask, this) + + def getRenderBounds = getBounds } abstract class Microblock(var shape:Byte = 0, var material:Int = 0) extends TCuboidPart diff --git a/codechicken/microblock/GrassMicroMaterial.scala b/codechicken/microblock/GrassMicroMaterial.scala index 2424191..8eacb6f 100644 --- a/codechicken/microblock/GrassMicroMaterial.scala +++ b/codechicken/microblock/GrassMicroMaterial.scala @@ -31,25 +31,25 @@ class GrassMicroMaterial extends BlockMicroMaterial(Block.grass, 0) sideIconT = new IconTransformation(BlockGrass.getIconSideOverlay) } - override def renderMicroFace(verts:Array[Vertex5], side:Int, pos:Vector3, lightMatrix:LightMatrix, part:Microblock) + override def renderMicroFace(verts:Array[Vertex5], side:Int, pos:Vector3, lightMatrix:LightMatrix, part:IMicroMaterialRender) { - val colour = getColour(part.tile) + val colour = getColour(part) if(side%6 == 1) renderMicroFace(verts, side, pos, lightMatrix, colour, icont) else renderMicroFace(verts, side, pos, lightMatrix, -1, icont) if(side%6 > 1 && side%6 < 6) - renderMicroFace(verts, side, pos, lightMatrix, colour, new TopIconTransformation(part.getBounds.max.y, sideIconT)) + renderMicroFace(verts, side, pos, lightMatrix, colour, new TopIconTransformation(part.getRenderBounds.max.y, sideIconT)) } } class TopMicroMaterial($block:Block, $meta:Int = 0) extends BlockMicroMaterial($block, $meta) { - override def renderMicroFace(verts:Array[Vertex5], side:Int, pos:Vector3, lightMatrix:LightMatrix, part:Microblock) + override def renderMicroFace(verts:Array[Vertex5], side:Int, pos:Vector3, lightMatrix:LightMatrix, part:IMicroMaterialRender) { if(side%6 > 1 && side%6 < 6) - renderMicroFace(verts, side, pos, lightMatrix, getColour(part.tile), new TopIconTransformation(part.getBounds.max.y, icont)) + renderMicroFace(verts, side, pos, lightMatrix, getColour(part), new TopIconTransformation(part.getRenderBounds.max.y, icont)) else super.renderMicroFace(verts, side, pos, lightMatrix, part) } diff --git a/codechicken/microblock/HolloMicroblock.scala b/codechicken/microblock/HolloMicroblock.scala index 029b7e6..5bd04ee 100644 --- a/codechicken/microblock/HolloMicroblock.scala +++ b/codechicken/microblock/HolloMicroblock.scala @@ -84,9 +84,9 @@ class HollowMicroblockClient(shape$:Byte = 0, material$:Int = 0) extends HollowM def this(size:Int, shape:Int, material:Int) = this((size<<4|shape).toByte, material) - override def onPartChanged(part:TMultiPart) + override def recalcBounds() { - super.onPartChanged(part) + super.recalcBounds() renderMask = renderMask&0xFF | getHollowSize<<8 } @@ -216,7 +216,7 @@ class HollowMicroblock(shape$:Byte = 0, material$:Int = 0) extends CommonMicrobl case null => 8 case _ => tile.partMap(6) match { - case part:IHollowConnect => part.getSize + case part:IHollowConnect => part.getHollowSize case _ => 8 } } diff --git a/codechicken/microblock/IHollowConnect.scala b/codechicken/microblock/IHollowConnect.scala index 9e88a85..26e7fe6 100644 --- a/codechicken/microblock/IHollowConnect.scala +++ b/codechicken/microblock/IHollowConnect.scala @@ -8,5 +8,5 @@ trait IHollowConnect /** * @return The size (width and height) of the connection in pixels. Must be be less than 12 and more than 0 */ - def getSize:Int + def getHollowSize:Int } diff --git a/codechicken/microblock/IMicroMaterialRender.scala b/codechicken/microblock/IMicroMaterialRender.scala new file mode 100644 index 0000000..7f28f76 --- /dev/null +++ b/codechicken/microblock/IMicroMaterialRender.scala @@ -0,0 +1,19 @@ +package codechicken.microblock + +import codechicken.lib.vec.Cuboid6 +import net.minecraft.world.World + +trait IMicroMaterialRender { + /** + * May be null for inventory rendering. + */ + def world():World + def x():Int + def y():Int + def z():Int + + /** + * Return the bounds of the part for texture mapping side decals like grass + */ + def getRenderBounds():Cuboid6 +} \ No newline at end of file diff --git a/codechicken/microblock/MicroMaterialRegistry.scala b/codechicken/microblock/MicroMaterialRegistry.scala index 3581a31..9a964ca 100644 --- a/codechicken/microblock/MicroMaterialRegistry.scala +++ b/codechicken/microblock/MicroMaterialRegistry.scala @@ -30,7 +30,7 @@ object MicroMaterialRegistry def loadIcons(){} @SideOnly(Side.CLIENT) - def renderMicroFace(verts:Array[Vertex5], side:Int, pos:Vector3, lightMatrix:LightMatrix, part:Microblock) + def renderMicroFace(verts:Array[Vertex5], side:Int, pos:Vector3, lightMatrix:LightMatrix, part:IMicroMaterialRender) @SideOnly(Side.CLIENT) def getRenderPass():Int diff --git a/codechicken/multipart/IRedstonePart.scala b/codechicken/multipart/IRedstonePart.scala index d526522..c346075 100644 --- a/codechicken/multipart/IRedstonePart.scala +++ b/codechicken/multipart/IRedstonePart.scala @@ -23,6 +23,14 @@ trait IFaceRedstonePart extends IRedstonePart def getFace():Int } +/** + * For parts that want to define their own connection masks (like center-center parts) + */ +trait IMaskedRedstonePart extends IRedstonePart +{ + def getConnectionMask(side:Int):Int +} + /** * Internal interface for TileMultipart instances hosting IRedstonePart */ @@ -110,6 +118,10 @@ object RedstoneInteractions return 1<