the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 115 lines 3.7 kB view raw
1#include "stdafx.h" 2#include "FireballRenderer.h" 3#include "EntityRenderDispatcher.h" 4#include "TextureAtlas.h" 5#include "..\Minecraft.World\net.minecraft.world.entity.projectile.h" 6#include "..\Minecraft.World\net.minecraft.world.item.h" 7#include "..\Minecraft.World\net.minecraft.world.level.tile.h" 8#include "..\Minecraft.World\net.minecraft.world.phys.h" 9#include "..\Minecraft.World\net.minecraft.world.h" 10 11FireballRenderer::FireballRenderer(float scale) 12{ 13 this->scale = scale; 14} 15 16void FireballRenderer::render(shared_ptr<Entity> _fireball, double x, double y, double z, float rot, float a) 17{ 18 // 4J - dynamic cast required because we aren't using templates/generics in our version 19 shared_ptr<Fireball> fireball = dynamic_pointer_cast<Fireball>(_fireball); 20 21 glPushMatrix(); 22 23 glTranslatef((float) x, (float) y, (float) z); 24 glEnable(GL_RESCALE_NORMAL); 25 float s = scale; 26 glScalef(s / 1.0f, s / 1.0f, s / 1.0f); 27 Icon *icon = Item::fireball->getIcon(fireball->GetType()==eTYPE_DRAGON_FIREBALL?1:0);//14 + 2 * 16; 28 MemSect(31); 29 bindTexture(fireball); 30 MemSect(0); 31 Tesselator *t = Tesselator::getInstance(); 32 33 float u0 = icon->getU0(); 34 float u1 = icon->getU1(); 35 float v0 = icon->getV0(); 36 float v1 = icon->getV1(); 37 38 float r = 1.0f; 39 float xo = 0.5f; 40 float yo = 0.25f; 41 42 glRotatef(180 - entityRenderDispatcher->playerRotY, 0, 1, 0); 43 glRotatef(-entityRenderDispatcher->playerRotX, 1, 0, 0); 44 t->begin(); 45 t->normal(0, 1, 0); 46 t->vertexUV((float)(0 - xo), (float)( 0 - yo), (float)( 0), (float)( u0), (float)( v1)); 47 t->vertexUV((float)(r - xo), (float)( 0 - yo), (float)( 0), (float)( u1), (float)( v1)); 48 t->vertexUV((float)(r - xo), (float)( 1 - yo), (float)( 0), (float)( u1), (float)( v0)); 49 t->vertexUV((float)(0 - xo), (float)( 1 - yo), (float)( 0), (float)( u0), (float)( v0)); 50 t->end(); 51 52 glDisable(GL_RESCALE_NORMAL); 53 glPopMatrix(); 54 55} 56 57// 4J Added override. Based on EntityRenderer::renderFlame 58void FireballRenderer::renderFlame(shared_ptr<Entity> e, double x, double y, double z, float a) 59{ 60 glDisable(GL_LIGHTING); 61 Icon *tex = Tile::fire->getTextureLayer(0); 62 63 glPushMatrix(); 64 glTranslatef((float) x, (float) y, (float) z); 65 66 float s = e->bbWidth * 1.4f; 67 glScalef(s, s, s); 68 MemSect(31); 69 bindTexture(&TextureAtlas::LOCATION_BLOCKS); 70 MemSect(0); 71 Tesselator *t = Tesselator::getInstance(); 72 73 float r = 1.0f; 74 float xo = 0.5f; 75// float yo = 0.0f; 76 77 float h = e->bbHeight / s; 78 float yo = (float) (e->y - e->bb->y0); 79 80 //glRotatef(-entityRenderDispatcher->playerRotY, 0, 1, 0); 81 82 83 glRotatef(180 - entityRenderDispatcher->playerRotY, 0, 1, 0); 84 glRotatef(-entityRenderDispatcher->playerRotX, 1, 0, 0); 85 glTranslatef(0,0,0.1f); 86 //glTranslatef(0, 0, -0.3f + ((int) h) * 0.02f); 87 glColor4f(1, 1, 1, 1); 88 // glRotatef(-playerRotX, 1, 0, 0); 89 float zo = 0; 90 t->begin(); 91 t->normal(0, 1, 0); 92 93 float u0 = tex->getU0(); 94 float v0 = tex->getV0(); 95 float u1 = tex->getU1(); 96 float v1 = tex->getV1(); 97 98 float tmp = u1; 99 u1 = u0; 100 u0 = tmp; 101 102 t->vertexUV((float)(0 - xo), (float)( 0 - yo), (float)( 0), (float)( u1), (float)( v1)); 103 t->vertexUV((float)(r - xo), (float)( 0 - yo), (float)( 0), (float)( u0), (float)( v1)); 104 t->vertexUV((float)(r - xo), (float)( 1.4f - yo), (float)( 0), (float)( u0), (float)( v0)); 105 t->vertexUV((float)(0 - xo), (float)( 1.4f - yo), (float)( 0), (float)( u1), (float)( v0)); 106 107 t->end(); 108 glPopMatrix(); 109 glEnable(GL_LIGHTING); 110} 111 112ResourceLocation *FireballRenderer::getTextureLocation(shared_ptr<Entity> mob) 113{ 114 return &TextureAtlas::LOCATION_ITEMS; 115}