From ce29842fe741bb9b67e9cb254276ed842d9dd3c4 Mon Sep 17 00:00:00 2001 From: Khroki Date: Sun, 24 Aug 2014 12:30:05 -0400 Subject: [PATCH] 1.8 Prerelease Renderer update Added new blocks to the renderer. --- renderer.py | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/renderer.py b/renderer.py index ead5c4d..360354d 100644 --- a/renderer.py +++ b/renderer.py @@ -1815,8 +1815,8 @@ def makeEnchantingVertices(self, facingBlockIndices, blocks, blockMaterials, blo makeVertices = makeEnchantingVertices -class DaylightBlockRenderer(BlockRenderer): #Note: Enderportal frame side sprite has been lowered 1 pixel to use this renderer, will need separate renderer for eye. - blocktypes = [pymclevel.materials.alphaMaterials.DaylightSensor.ID] +class DaylightBlockRenderer(BlockRenderer): + blocktypes = [pymclevel.materials.alphaMaterials.DaylightSensor.ID, pymclevel.materials.alphaMaterials.DaylightSensorOn.ID] def makeDaylightVertices(self, facingBlockIndices, blocks, blockMaterials, blockData, areaBlockLights, texMap): materialIndices = self.getMaterialIndices(blockMaterials) arrays = [] @@ -1954,13 +1954,21 @@ def redstoneVertices(self, facingBlockIndices, blocks, blockMaterials, blockData #BUTTONS GO HERE -class FenceBlockRenderer(BlockRenderer): #This code is a mess, written to only accept one type of material. Rewrite me. - blocktypes = [pymclevel.materials.alphaMaterials.Fence.ID] +class FenceBlockRenderer(BlockRenderer): #This code is written to only accept one texture. Fix me. + blocktypes = [pymclevel.materials.alphaMaterials.Fence.ID, + pymclevel.materials.alphaMaterials.SpruceFence.ID, + pymclevel.materials.alphaMaterials.BirchFence.ID, + pymclevel.materials.alphaMaterials.JungleFence.ID, + pymclevel.materials.alphaMaterials.DarkOakFence.ID, + pymclevel.materials.alphaMaterials.AcaciaFence.ID + ] fenceTemplates = makeVertexTemplates(3 / 8., 0, 3 / 8., 5 / 8., 1, 5 / 8.) def fenceVertices(self, facingBlockIndices, blocks, blockMaterials, blockData, areaBlockLights, texMap): - fenceMask = blocks == [pymclevel.materials.alphaMaterials.Fence.ID] + fenceMask = self.getMaterialIndices(blockMaterials) fenceIndices = fenceMask.nonzero() yield + + tex = texMap(blocks[fenceMask], blockData[fenceMask], 0)[:, numpy.newaxis, 0:2] vertexArray = numpy.zeros((len(fenceIndices[0]), 6, 4, 6), dtype='float32') for indicies in range(3): @@ -1969,8 +1977,8 @@ def fenceVertices(self, facingBlockIndices, blocks, blockMaterials, blockData, a vertexArray[..., indicies] = fenceIndices[dimension][:, numpy.newaxis, numpy.newaxis] # xxx swap z with y using ^ vertexArray[..., 0:5] += self.fenceTemplates[..., 0:5] - vertexArray[_ST] += pymclevel.materials.alphaMaterials.blockTextures[pymclevel.materials.alphaMaterials.Fence.ID, 0, 0] - + vertexArray[_ST] += pymclevel.materials.alphaMaterials.blockTextures[pymclevel.materials.alphaMaterials.Fence.ID, 0, 0] #Offending line + vertexArray.view('uint8')[_RGB] = self.fenceTemplates[..., 5][..., numpy.newaxis] vertexArray.view('uint8')[_A] = 0xFF vertexArray.view('uint8')[_RGB] *= areaBlockLights[1:-1, 1:-1, 1:-1][fenceIndices][..., numpy.newaxis, numpy.newaxis, numpy.newaxis] @@ -1984,7 +1992,7 @@ class NetherFenceBlockRenderer(BlockRenderer): blocktypes = [pymclevel.materials.alphaMaterials.NetherBrickFence.ID] fenceTemplates = makeVertexTemplates(3 / 8., 0, 3 / 8., 5 / 8., 1, 5 / 8.) def fenceVertices(self, facingBlockIndices, blocks, blockMaterials, blockData, areaBlockLights, texMap): - fenceMask = blocks == [pymclevel.materials.alphaMaterials.NetherBrickFence.ID] + fenceMask = self.getMaterialIndices(blockMaterials) fenceIndices = fenceMask.nonzero() yield @@ -1992,7 +2000,7 @@ def fenceVertices(self, facingBlockIndices, blocks, blockMaterials, blockData, a for indicies in range(3): dimension = (0, 2, 1)[indicies] - vertexArray[..., indicies] = fenceIndices[dimension][:, numpy.newaxis, numpy.newaxis] # xxx swap z with y using ^ + vertexArray[..., indicies] = fenceIndices[dimension][:, numpy.newaxis, numpy.newaxis] vertexArray[..., 0:5] += self.fenceTemplates[..., 0:5] vertexArray[_ST] += pymclevel.materials.alphaMaterials.blockTextures[pymclevel.materials.alphaMaterials.NetherBrickFence.ID, 0, 0] @@ -2116,7 +2124,7 @@ def vineFaceVertices(self, direction, blockIndices, exposedFaceIndices, blocks, class SlabBlockRenderer(BlockRenderer): - blocktypes = [44, 126] + blocktypes = [pymclevel.materials.alphaMaterials.OakWoodSlab.ID, pymclevel.materials.alphaMaterials.StoneSlab.ID, pymclevel.materials.alphaMaterials.RedSandstoneSlab.ID] def slabFaceVertices(self, direction, blockIndices, exposedFaceIndices, blocks, blockData, blockLight, facingBlockLight, texMap): if direction != pymclevel.faces.FaceYIncreasing: