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 "BookModel.h"
3#include "..\Minecraft.World\net.minecraft.world.level.tile.entity.h"
4#include "..\Minecraft.World\Mth.h"
5#include "EnchantTableRenderer.h"
6
7ResourceLocation EnchantTableRenderer::BOOK_LOCATION = ResourceLocation(TN_ITEM_BOOK);
8
9EnchantTableRenderer::EnchantTableRenderer()
10{
11 bookModel = new BookModel();
12}
13
14EnchantTableRenderer::~EnchantTableRenderer()
15{
16 delete bookModel;
17}
18
19void EnchantTableRenderer::render(shared_ptr<TileEntity> _table, double x, double y, double z, float a, bool setColor, float alpha, bool useCompiled)
20{
21 // 4J Convert as we aren't using a templated class
22 shared_ptr<EnchantmentTableEntity> table = dynamic_pointer_cast<EnchantmentTableEntity>(_table);
23
24#ifdef __PSVITA__
25 // AP - the book pages are made with 0 depth so the front and back polys are at the same location. This can cause z-fighting if culling is disabled which can sometimes happen
26 // depending on what object was last seen so make sure culling is always enabled. Should this be a problem for other platforms?
27 glEnable(GL_CULL_FACE);
28#endif
29
30 glPushMatrix();
31 glTranslatef((float) x + 0.5f, (float) y + 12 / 16.0f, (float) z + 0.5f);
32
33 float tt = table->time + a;
34
35 glTranslatef(0, 0.1f + sin(tt * 0.1f) * 0.01f, 0);
36 float orot = (table->rot - table->oRot);
37 while (orot >= PI)
38 orot -= PI * 2;
39 while (orot < -PI)
40 orot += PI * 2;
41
42 float yRot = table->oRot + orot * a;
43
44 glRotatef(-yRot * 180 / PI, 0, 1, 0);
45 glRotatef(80, 0, 0, 1);
46 bindTexture(&BOOK_LOCATION); // 4J was "/item/book.png"
47
48 float ff1 = table->oFlip + (table->flip - table->oFlip) * a + 0.25f;
49 float ff2 = table->oFlip + (table->flip - table->oFlip) * a + 0.75f;
50 ff1 = (ff1 - Mth::fastFloor(ff1)) * 1.6f - 0.3f;
51 ff2 = (ff2 - Mth::fastFloor(ff2)) * 1.6f - 0.3f;
52
53 if (ff1 < 0) ff1 = 0;
54 if (ff2 < 0) ff2 = 0;
55 if (ff1 > 1) ff1 = 1;
56 if (ff2 > 1) ff2 = 1;
57
58 float o = table->oOpen + (table->open - table->oOpen) * a;
59 glEnable(GL_CULL_FACE);
60 bookModel->render(nullptr, tt, ff1, ff2, o, 0, 1 / 16.0f,true);
61 glPopMatrix();
62}