Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class TileEntitySpecialRendererSpaceTimeAnomaly : TileEntitySpecialRenderer<TileEntity>() {
- companion object {
- val model = ModelCache.models.get("/assets/timecraft/models/block/spaceTimeAnomaly.obj")
- }
- override fun renderTileEntityAt(te: TileEntity, x: Double, y: Double, z: Double, partialTicks: Float, destroyStage: Int) {
- var teSA = te as TileEntitySpaceTimeAnomaly
- try {
- GlStateManager.pushMatrix()
- GL11.glPushAttrib(GL11.GL_ENABLE_BIT)
- GlStateManager.translate(x, y, z)
- GL11.glTranslatef(0.5f, 0.5f, 0.5f)
- GlStateManager.rotate(teSA.getNextAngularPosition(0.03333).toFloat(), 0f, 1f, 0f)
- GlStateManager.translate(-0.5f, -0.5f, -0.5f)
- val tessellator = Tessellator.getInstance()
- val wr = tessellator.worldRenderer
- GL11.glDepthMask(true)
- this.bindTexture(texture)
- wr.begin(GL11.GL_TRIANGLES, DefaultVertexFormats.POSITION_NORMAL)
- addIcoSphereVertices(wr)
- tessellator.draw()
- } finally {
- GL11.glPopAttrib()
- GlStateManager.popMatrix()
- }
- }
- fun addIcoSphereVertices(wr: WorldRenderer) {
- for (face in model.faces) {
- val n1 = model.normals[face.normal.x.toInt() - 1]
- val v1 = model.vertices[face.vertex.x.toInt() - 1]
- val n2 = model.normals[face.normal.y.toInt() - 1]
- val v2 = model.vertices[face.vertex.y.toInt() - 1]
- val n3 = model.normals[face.normal.z.toInt() - 1]
- val v3 = model.vertices[face.vertex.z.toInt() - 1]
- wr.pos(v1.x.toDouble(), v1.y.toDouble(), v1.z.toDouble()).normal(n1.x, n1.y, n1.z).endVertex()
- wr.pos(v2.x.toDouble(), v2.y.toDouble(), v2.z.toDouble()).normal(n2.x, n2.y, n2.z).endVertex()
- wr.pos(v3.x.toDouble(), v3.y.toDouble(), v3.z.toDouble()).normal(n3.x, n3.y, n3.z).endVertex()
- }
- }
- internal val texture: ResourceLocation = ResourceLocation(Reference.MODID + ":textures/blocks/spaceTimeAnomaly.png")
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement