the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 108 lines 4.2 kB view raw
1#include "stdafx.h" 2#include "FishingHookRenderer.h" 3#include "EntityRenderDispatcher.h" 4#include "Options.h" 5#include "..\Minecraft.World\net.minecraft.world.entity.projectile.h" 6#include "..\Minecraft.World\net.minecraft.world.entity.player.h" 7#include "..\Minecraft.World\Vec3.h" 8#include "..\Minecraft.World\Mth.h" 9#include "MultiPlayerLocalPlayer.h" 10 11ResourceLocation FishingHookRenderer::PARTICLE_LOCATION = ResourceLocation(TN_PARTICLES); 12 13void FishingHookRenderer::render(shared_ptr<Entity> _hook, double x, double y, double z, float rot, float a) 14{ 15 // 4J - dynamic cast required because we aren't using templates/generics in our version 16 shared_ptr<FishingHook> hook = dynamic_pointer_cast<FishingHook>(_hook); 17 18 glPushMatrix(); 19 20 glTranslatef((float) x, (float) y, (float) z); 21 glEnable(GL_RESCALE_NORMAL); 22 glScalef(1 / 2.0f, 1 / 2.0f, 1 / 2.0f); 23 int xi = 1; 24 int yi = 2; 25 bindTexture(hook); // 4J was L"/particles.png" 26 Tesselator *t = Tesselator::getInstance(); 27 28 float u0 = (xi * 8 + 0) / 128.0f; 29 float u1 = (xi * 8 + 8) / 128.0f; 30 float v0 = (yi * 8 + 0) / 128.0f; 31 float v1 = (yi * 8 + 8) / 128.0f; 32 33 34 float r = 1.0f; 35 float xo = 0.5f; 36 float yo = 0.5f; 37 38 glRotatef(180 - entityRenderDispatcher->playerRotY, 0, 1, 0); 39 glRotatef(-entityRenderDispatcher->playerRotX, 1, 0, 0); 40 t->begin(); 41 t->normal(0, 1, 0); 42 t->vertexUV((float)(0 - xo), (float)( 0 - yo), (float)( 0), (float)( u0), (float)( v1)); 43 t->vertexUV((float)(r - xo), (float)( 0 - yo), (float)( 0), (float)( u1), (float)( v1)); 44 t->vertexUV((float)(r - xo), (float)( 1 - yo), (float)( 0), (float)( u1), (float)( v0)); 45 t->vertexUV((float)(0 - xo), (float)( 1 - yo), (float)( 0), (float)( u0), (float)( v0)); 46 t->end(); 47 48 glDisable(GL_RESCALE_NORMAL); 49 glPopMatrix(); 50 51 52 if (hook->owner != NULL) 53 { 54 float swing = hook->owner->getAttackAnim(a); 55 float swing2 = (float) Mth::sin(sqrt(swing) * PI); 56 57 58 Vec3 *vv = Vec3::newTemp(-0.5, 0.03, 0.8); 59 vv->xRot(-(hook->owner->xRotO + (hook->owner->xRot - hook->owner->xRotO) * a) * PI / 180); 60 vv->yRot(-(hook->owner->yRotO + (hook->owner->yRot - hook->owner->yRotO) * a) * PI / 180); 61 vv->yRot(swing2 * 0.5f); 62 vv->xRot(-swing2 * 0.7f); 63 64 double xp = hook->owner->xo + (hook->owner->x - hook->owner->xo) * a + vv->x; 65 double yp = hook->owner->yo + (hook->owner->y - hook->owner->yo) * a + vv->y; 66 double zp = hook->owner->zo + (hook->owner->z - hook->owner->zo) * a + vv->z; 67 double yOffset = hook->owner == dynamic_pointer_cast<Player>(Minecraft::GetInstance()->player) ? 0 : hook->owner->getHeadHeight(); 68 69 // 4J-PB - changing this to be per player 70 //if (this->entityRenderDispatcher->options->thirdPersonView) 71 if (hook->owner->ThirdPersonView() > 0) 72 { 73 float rr = (float) (hook->owner->yBodyRotO + (hook->owner->yBodyRot - hook->owner->yBodyRotO) * a) * PI / 180; 74 double ss = Mth::sin((float) rr); 75 double cc = Mth::cos((float) rr); 76 xp = hook->owner->xo + (hook->owner->x - hook->owner->xo) * a - cc * 0.35 - ss * 0.85; 77 yp = hook->owner->yo + yOffset + (hook->owner->y - hook->owner->yo) * a - 0.45; 78 zp = hook->owner->zo + (hook->owner->z - hook->owner->zo) * a - ss * 0.35 + cc * 0.85; 79 } 80 81 double xh = hook->xo + (hook->x - hook->xo) * a; 82 double yh = hook->yo + (hook->y - hook->yo) * a + 4 / 16.0f; 83 double zh = hook->zo + (hook->z - hook->zo) * a; 84 85 double xa = (float) (xp - xh); 86 double ya = (float) (yp - yh); 87 double za = (float) (zp - zh); 88 89 glDisable(GL_TEXTURE_2D); 90 glDisable(GL_LIGHTING); 91 t->begin(GL_LINE_STRIP); 92 t->color(0x000000); 93 int steps = 16; 94 for (int i = 0; i <= steps; i++) 95 { 96 float aa = i / (float) steps; 97 t->vertex((float)(x + xa * aa), (float)( y + ya * (aa * aa + aa) * 0.5 + 4 / 16.0f), (float)( z + za * aa)); 98 } 99 t->end(); 100 glEnable(GL_LIGHTING); 101 glEnable(GL_TEXTURE_2D); 102 } 103} 104 105ResourceLocation *FishingHookRenderer::getTextureLocation(shared_ptr<Entity> mob) 106{ 107 return &PARTICLE_LOCATION; 108}