the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2#include "ArrowRenderer.h"
3#include "..\Minecraft.World\net.minecraft.world.entity.projectile.h"
4#include "..\Minecraft.World\Mth.h"
5
6ResourceLocation ArrowRenderer::ARROW_LOCATION = ResourceLocation(TN_ITEM_ARROWS);
7
8void ArrowRenderer::render(shared_ptr<Entity> _arrow, double x, double y, double z, float rot, float a)
9{
10 // 4J - original version used generics and thus had an input parameter of type Arrow rather than shared_ptr<Entity> we have here -
11 // do some casting around instead
12 shared_ptr<Arrow> arrow = dynamic_pointer_cast<Arrow>(_arrow);
13 bindTexture(_arrow); // 4J - was L"/item/arrows.png"
14
15 glPushMatrix();
16
17 float yRot = arrow->yRot;
18 float xRot = arrow->xRot;
19 float yRotO = arrow->yRotO;
20 float xRotO = arrow->xRotO;
21 if( ( yRot - yRotO ) > 180.0f ) yRot -= 360.0f;
22 else if( ( yRot - yRotO ) < -180.0f ) yRot += 360.0f;
23 if( ( xRot - xRotO ) > 180.0f ) xRot -= 360.0f;
24 else if( ( xRot - xRotO ) < -180.0f ) xRot += 360.0f;
25
26 glTranslatef((float)x, (float)y, (float)z);
27 glRotatef(yRotO + (yRot - yRotO) * a - 90, 0, 1, 0);
28 glRotatef(xRotO + (xRot - xRotO) * a, 0, 0, 1);
29
30 Tesselator *t = Tesselator::getInstance();
31 int type = 0;
32
33 float u0 = 0 / 32.0f;
34 float u1 = 16 / 32.0f;
35 float v0 = (0 + type * 10) / 32.0f;
36 float v1 = (5 + type * 10) / 32.0f;
37
38 float u02 = 0 / 32.0f;
39 float u12 = 5 / 32.0f;
40 float v02 = (5 + type * 10) / 32.0f;
41 float v12 = (10 + type * 10) / 32.0f;
42 float ss = 0.9f / 16.0f;
43 glEnable(GL_RESCALE_NORMAL);
44 float shake = arrow->shakeTime-a;
45 if (shake>0)
46 {
47 float pow = -Mth::sin(shake*3)*shake;
48 glRotatef(pow, 0, 0, 1);
49 }
50 glRotatef(45, 1, 0, 0);
51 glScalef(ss, ss, ss);
52
53 glTranslatef(-4, 0, 0);
54
55// glNormal3f(ss, 0, 0); // 4J - changed to use tesselator
56 t->begin();
57 t->normal(1,0,0);
58 t->vertexUV((float)(-7), (float)( -2), (float)( -2), (float)( u02), (float)( v02));
59 t->vertexUV((float)(-7), (float)( -2), (float)( +2), (float)( u12), (float)( v02));
60 t->vertexUV((float)(-7), (float)( +2), (float)( +2), (float)( u12), (float)( v12));
61 t->vertexUV((float)(-7), (float)( +2), (float)( -2), (float)( u02), (float)( v12));
62 t->end();
63
64// glNormal3f(-ss, 0, 0); // 4J - changed to use tesselator
65 t->begin();
66 t->normal(-1,0,0);
67 t->vertexUV((float)(-7), (float)( +2), (float)( -2), (float)( u02), (float)( v02));
68 t->vertexUV((float)(-7), (float)( +2), (float)( +2), (float)( u12), (float)( v02));
69 t->vertexUV((float)(-7), (float)( -2), (float)( +2), (float)( u12), (float)( v12));
70 t->vertexUV((float)(-7), (float)( -2), (float)( -2), (float)( u02), (float)( v12));
71 t->end();
72
73 for (int i = 0; i < 4; i++)
74 {
75
76 glRotatef(90, 1, 0, 0);
77// glNormal3f(0, 0, ss); // 4J - changed to use tesselator
78 t->begin();
79 t->normal(0,0,1);
80 t->vertexUV((float)(-8), (float)( -2), (float)( 0), (float)( u0), (float)( v0));
81 t->vertexUV((float)(+8), (float)( -2), (float)( 0), (float)( u1), (float)( v0));
82 t->vertexUV((float)(+8), (float)( +2), (float)( 0), (float)( u1), (float)( v1));
83 t->vertexUV((float)(-8), (float)( +2), (float)( 0), (float)( u0), (float)( v1));
84 t->end();
85 }
86 glDisable(GL_RESCALE_NORMAL);
87 glPopMatrix();
88}
89
90ResourceLocation *ArrowRenderer::getTextureLocation(shared_ptr<Entity> mob)
91{
92 return &ARROW_LOCATION;
93}