the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 97 lines 2.9 kB view raw
1#include "stdafx.h" 2#include "LightningBoltRenderer.h" 3#include "Tesselator.h" 4#include "..\Minecraft.World\net.minecraft.world.entity.global.h" 5 6void LightningBoltRenderer::render(shared_ptr<Entity> _bolt, double x, double y, double z, float rot, float a) 7{ 8 // 4J - dynamic cast required because we aren't using templates/generics in our version 9 shared_ptr<LightningBolt> bolt = dynamic_pointer_cast<LightningBolt>(_bolt); 10 11 Tesselator *t = Tesselator::getInstance(); 12 13 glDisable(GL_TEXTURE_2D); 14 glDisable(GL_LIGHTING); 15 glEnable(GL_BLEND); 16 glBlendFunc(GL_SRC_ALPHA, GL_ONE); 17 18 19 double xOffs[8]; 20 double zOffs[8]; 21 double xOff = 0; 22 double zOff = 0; 23 { 24 Random *random = new Random(bolt->seed); 25 for (int h = 7; h >= 0; h--) 26 { 27 xOffs[h] = xOff; 28 zOffs[h] = zOff; 29 xOff += random->nextInt(11) - 5; 30 zOff += random->nextInt(11) - 5; 31 } 32 } 33 34 for (int r = 0; r < 4; r++) 35 { 36 Random *random = new Random(bolt->seed); 37 for (int p = 0; p < 3; p++) 38 { 39 int hs = 7; 40 int ht = 0; 41 if (p > 0) hs = 7 - p; 42 if (p > 0) ht = hs - 2; 43 double xo0 = xOffs[hs] - xOff; 44 double zo0 = zOffs[hs] - zOff; 45 for (int h = hs; h >= ht; h--) 46 { 47 double xo1 = xo0; 48 double zo1 = zo0; 49 if (p == 0) 50 { 51 xo0 += random->nextInt(11) - 5; 52 zo0 += random->nextInt(11) - 5; 53 } 54 else 55 { 56 xo0 += random->nextInt(31) - 15; 57 zo0 += random->nextInt(31) - 15; 58 } 59 60 t->begin(GL_TRIANGLE_STRIP); 61 float br = 0.5f; 62 t->color(0.9f * br, 0.9f * br, 1 * br, 0.3f); 63 64 double rr1 = (0.1 + r * 0.2); 65 if (p == 0) rr1 *= (h * 0.1 + 1); 66 67 double rr2 = (0.1 + r * 0.2); 68 if (p == 0) rr2 *= ((h-1) * 0.1 + 1); 69 70 for (int i = 0; i < 5; i++) 71 { 72 double xx1 = x + 0.5 - rr1; 73 double zz1 = z + 0.5 - rr1; 74 if (i == 1 || i == 2) xx1 += rr1 * 2; 75 if (i == 2 || i == 3) zz1 += rr1 * 2; 76 77 double xx2 = x + 0.5 - rr2; 78 double zz2 = z + 0.5 - rr2; 79 if (i == 1 || i == 2) xx2 += rr2 * 2; 80 if (i == 2 || i == 3) zz2 += rr2 * 2; 81 82 t->vertex((float)(xx2 + xo0), (float)( y + (h) * 16), (float)( zz2 + zo0)); 83 t->vertex((float)(xx1 + xo1), (float)( y + (h + 1) * 16), (float)( zz1 + zo1)); 84 85 } 86 87 t->end(); 88 } 89 } 90 } 91 92 93 glDisable(GL_BLEND); 94 glEnable(GL_LIGHTING); 95 glEnable(GL_TEXTURE_2D); 96 97}