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.h"
3#include "..\Minecraft.World\net.minecraft.world.level.h"
4#include "..\Minecraft.World\net.minecraft.world.level.dimension.h"
5#include "MultiplayerLocalPlayer.h"
6#include "..\Minecraft.World\JavaMath.h"
7#include "Texture.h"
8#include "ClockTexture.h"
9
10ClockTexture::ClockTexture() : StitchedTexture(L"clock", L"clock")
11{
12 rot = rota = 0.0;
13 m_dataTexture = NULL;
14 m_iPad = XUSER_INDEX_ANY;
15}
16
17ClockTexture::ClockTexture(int iPad, ClockTexture *dataTexture) : StitchedTexture(L"clock", L"clock")
18{
19 rot = rota = 0.0;
20 m_dataTexture = dataTexture;
21 m_iPad = iPad;
22}
23
24void ClockTexture::cycleFrames()
25{
26
27 Minecraft *mc = Minecraft::GetInstance();
28
29 double rott = 0;
30 if (m_iPad >= 0 && m_iPad < XUSER_MAX_COUNT && mc->level != NULL && mc->localplayers[m_iPad] != NULL)
31 {
32 float time = mc->localplayers[m_iPad]->level->getTimeOfDay(1);
33 rott = time;
34 if (!mc->localplayers[m_iPad]->level->dimension->isNaturalDimension())
35 {
36 rott = Math::random();
37 }
38 }
39 else
40 {
41 // 4J Stu - For the static version, pretend we are already on a frame other than 0
42 frame = 1;
43 }
44
45 double rotd = rott - rot;
46 while (rotd < -.5)
47 rotd += 1.0;
48 while (rotd >= .5)
49 rotd -= 1.0;
50 if (rotd < -1) rotd = -1;
51 if (rotd > 1) rotd = 1;
52 rota += rotd * 0.1;
53 rota *= 0.8;
54
55 rot += rota;
56
57 // 4J Stu - We share data with another texture
58 if(m_dataTexture != NULL)
59 {
60 int newFrame = (int) ((rot + 1.0) * m_dataTexture->frames->size()) % m_dataTexture->frames->size();
61 while (newFrame < 0)
62 {
63 newFrame = (newFrame + m_dataTexture->frames->size()) % m_dataTexture->frames->size();
64 }
65 if (newFrame != frame)
66 {
67 frame = newFrame;
68 m_dataTexture->source->blit(x, y, m_dataTexture->frames->at(this->frame), rotated);
69 }
70 }
71 else
72 {
73 int newFrame = (int) ((rot + 1.0) * frames->size()) % frames->size();
74 while (newFrame < 0)
75 {
76 newFrame = (newFrame + frames->size()) % frames->size();
77 }
78 if (newFrame != frame)
79 {
80 frame = newFrame;
81 source->blit(x, y, frames->at(this->frame), rotated);
82 }
83 }
84}
85
86int ClockTexture::getSourceWidth() const
87{
88 return source->getWidth();
89}
90
91int ClockTexture::getSourceHeight() const
92{
93 return source->getHeight();
94}
95
96int ClockTexture::getFrames()
97{
98 if(m_dataTexture == NULL)
99 {
100 return StitchedTexture::getFrames();
101 }
102 else
103 {
104 return m_dataTexture->getFrames();
105 }
106}
107
108void ClockTexture::freeFrameTextures()
109{
110 if(m_dataTexture == NULL)
111 {
112 StitchedTexture::freeFrameTextures();
113 }
114}
115
116bool ClockTexture::hasOwnData()
117{
118 return m_dataTexture == NULL;
119}