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 "InventoryScreen.h"
3#include "MultiplayerLocalPlayer.h"
4#include "Font.h"
5#include "EntityRenderDispatcher.h"
6#include "Lighting.h"
7#include "Textures.h"
8#include "Button.h"
9#include "AchievementScreen.h"
10#include "StatsScreen.h"
11#include "..\Minecraft.World\net.minecraft.stats.h"
12
13InventoryScreen::InventoryScreen(shared_ptr<Player> player) : AbstractContainerScreen(player->inventoryMenu)
14{
15 xMouse = yMouse = 0.0f; // 4J added
16
17 this->passEvents = true;
18 player->awardStat(GenericStats::openInventory(), GenericStats::param_noArgs());
19}
20
21void InventoryScreen::init()
22{
23 buttons.clear();
24}
25
26void InventoryScreen::renderLabels()
27{
28 font->draw(L"Crafting", 84 + 2, 8 * 2, 0x404040);
29}
30
31void InventoryScreen::render(int xm, int ym, float a)
32{
33 AbstractContainerScreen::render(xm, ym, a);
34 this->xMouse = (float)xm;
35 this->yMouse = (float)ym;
36}
37
38void InventoryScreen::renderBg(float a)
39{
40 // 4J Unused
41#if 0
42 int tex = minecraft->textures->loadTexture(L"/gui/inventory.png");
43 glColor4f(1, 1, 1, 1);
44 minecraft->textures->bind(tex);
45 int xo = (width - imageWidth) / 2;
46 int yo = (height - imageHeight) / 2;
47 this->blit(xo, yo, 0, 0, imageWidth, imageHeight);
48
49 glEnable(GL_RESCALE_NORMAL);
50 glEnable(GL_COLOR_MATERIAL);
51
52 glPushMatrix();
53 glTranslatef((float)xo + 51, (float)yo + 75, 50);
54 float ss = 30;
55 glScalef(-ss, ss, ss);
56 glRotatef(180, 0, 0, 1);
57
58 float oybr = minecraft->player->yBodyRot;
59 float oyr = minecraft->player->yRot;
60 float oxr = minecraft->player->xRot;
61
62 float xd = (xo + 51) - xMouse;
63 float yd = (yo + 75 - 50) - yMouse;
64
65 glRotatef(45 + 90, 0, 1, 0);
66 Lighting::turnOn();
67 glRotatef(-45 - 90, 0, 1, 0);
68
69 glRotatef(-(float) atan(yd / 40.0f) * 20, 1, 0, 0);
70
71 minecraft->player->yBodyRot = (float) atan(xd / 40.0f) * 20;
72 minecraft->player->yRot = (float) atan(xd / 40.0f) * 40;
73 minecraft->player->xRot = -(float) atan(yd / 40.0f) * 20;
74 glTranslatef(0, minecraft->player->heightOffset, 0);
75 EntityRenderDispatcher::instance->playerRotY = 180;
76 EntityRenderDispatcher::instance->render(minecraft->player, 0, 0, 0, 0, 1);
77 minecraft->player->yBodyRot = oybr;
78 minecraft->player->yRot = oyr;
79 minecraft->player->xRot = oxr;
80 glPopMatrix();
81 Lighting::turnOff();
82 glDisable(GL_RESCALE_NORMAL);
83#endif
84}
85
86void InventoryScreen::buttonClicked(Button *button)
87{
88 if (button->id == 0)
89 {
90 minecraft->setScreen(new AchievementScreen(minecraft->stats[minecraft->player->GetXboxPad()]));
91 }
92 if (button->id == 1)
93 {
94 minecraft->setScreen(new StatsScreen(this, minecraft->stats[minecraft->player->GetXboxPad()]));
95 }
96}