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 "..\Minecraft.World\net.minecraft.world.level.tile.entity.h"
3#include "..\Minecraft.World\net.minecraft.world.level.h"
4#include "BeaconRenderer.h"
5#include "Tesselator.h"
6
7ResourceLocation BeaconRenderer::BEAM_LOCATION = ResourceLocation(TN_MISC_BEACON_BEAM);
8
9void BeaconRenderer::render(shared_ptr<TileEntity> _beacon, double x, double y, double z, float a, bool setColor, float alpha, bool useCompiled)
10{
11 shared_ptr<BeaconTileEntity> beacon = dynamic_pointer_cast<BeaconTileEntity>(_beacon);
12
13 float scale = beacon->getAndUpdateClientSideScale();
14
15 if (scale > 0)
16 {
17 Tesselator *t = Tesselator::getInstance();
18
19 bindTexture(&BEAM_LOCATION);
20
21 // TODO: 4J: Put this back in
22 //assert(0);
23 //glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
24 //glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
25
26 glDisable(GL_LIGHTING);
27 glDisable(GL_CULL_FACE);
28 glDisable(GL_BLEND);
29 glDepthMask(true);
30 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
31
32 float tt = beacon->getLevel()->getGameTime() + a;
33 float texVOff = -tt * .20f - floor(-tt * .10f);
34
35 {
36 int r = 1;
37
38 double rot = tt * .025 * (1 - (r & 1) * 2.5);
39
40 t->begin();
41 t->color(255, 255, 255, 32);
42
43 double rr1 = r * 0.2;
44
45 double wnx = .5 + cos(rot + PI * .75) * rr1;
46 double wnz = .5 + sin(rot + PI * .75) * rr1;
47 double enx = .5 + cos(rot + PI * .25) * rr1;
48 double enz = .5 + sin(rot + PI * .25) * rr1;
49
50 double wsx = .5 + cos(rot + PI * 1.25) * rr1;
51 double wsz = .5 + sin(rot + PI * 1.25) * rr1;
52 double esx = .5 + cos(rot + PI * 1.75) * rr1;
53 double esz = .5 + sin(rot + PI * 1.75) * rr1;
54
55 double top = 256 * scale;
56
57 double uu1 = 0;
58 double uu2 = 1;
59 double vv2 = -1 + texVOff;
60 double vv1 = 256 * scale * (.5 / rr1) + vv2;
61
62 t->vertexUV(x + wnx, y + top, z + wnz, uu2, vv1);
63 t->vertexUV(x + wnx, y, z + wnz, uu2, vv2);
64 t->vertexUV(x + enx, y, z + enz, uu1, vv2);
65 t->vertexUV(x + enx, y + top, z + enz, uu1, vv1);
66
67 t->vertexUV(x + esx, y + top, z + esz, uu2, vv1);
68 t->vertexUV(x + esx, y, z + esz, uu2, vv2);
69 t->vertexUV(x + wsx, y, z + wsz, uu1, vv2);
70 t->vertexUV(x + wsx, y + top, z + wsz, uu1, vv1);
71
72 t->vertexUV(x + enx, y + top, z + enz, uu2, vv1);
73 t->vertexUV(x + enx, y, z + enz, uu2, vv2);
74 t->vertexUV(x + esx, y, z + esz, uu1, vv2);
75 t->vertexUV(x + esx, y + top, z + esz, uu1, vv1);
76
77 t->vertexUV(x + wsx, y + top, z + wsz, uu2, vv1);
78 t->vertexUV(x + wsx, y, z + wsz, uu2, vv2);
79 t->vertexUV(x + wnx, y, z + wnz, uu1, vv2);
80 t->vertexUV(x + wnx, y + top, z + wnz, uu1, vv1);
81
82 t->end();
83 }
84
85 glEnable(GL_BLEND);
86 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
87 glDepthMask(false);
88
89 {
90 t->begin();
91 t->color(255, 255, 255, 32);
92
93 double wnx = .2;
94 double wnz = .2;
95 double enx = .8;
96 double enz = .2;
97
98 double wsx = .2;
99 double wsz = .8;
100 double esx = .8;
101 double esz = .8;
102
103 double top = 256 * scale;
104
105 double uu1 = 0;
106 double uu2 = 1;
107 double vv2 = -1 + texVOff;
108 double vv1 = 256 * scale + vv2;
109
110 t->vertexUV(x + wnx, y + top, z + wnz, uu2, vv1);
111 t->vertexUV(x + wnx, y, z + wnz, uu2, vv2);
112 t->vertexUV(x + enx, y, z + enz, uu1, vv2);
113 t->vertexUV(x + enx, y + top, z + enz, uu1, vv1);
114
115 t->vertexUV(x + esx, y + top, z + esz, uu2, vv1);
116 t->vertexUV(x + esx, y, z + esz, uu2, vv2);
117 t->vertexUV(x + wsx, y, z + wsz, uu1, vv2);
118 t->vertexUV(x + wsx, y + top, z + wsz, uu1, vv1);
119
120 t->vertexUV(x + enx, y + top, z + enz, uu2, vv1);
121 t->vertexUV(x + enx, y, z + enz, uu2, vv2);
122 t->vertexUV(x + esx, y, z + esz, uu1, vv2);
123 t->vertexUV(x + esx, y + top, z + esz, uu1, vv1);
124
125 t->vertexUV(x + wsx, y + top, z + wsz, uu2, vv1);
126 t->vertexUV(x + wsx, y, z + wsz, uu2, vv2);
127 t->vertexUV(x + wnx, y, z + wnz, uu1, vv2);
128 t->vertexUV(x + wnx, y + top, z + wnz, uu1, vv1);
129
130 t->end();
131 }
132
133 glEnable(GL_LIGHTING);
134 glEnable(GL_TEXTURE_2D);
135
136 glDepthMask(true);
137 }
138}