the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#pragma once
2#include "..\Minecraft.World\SmoothFloat.h"
3#include "..\Minecraft.World\net.minecraft.world.entity.player.h"
4#include "..\Minecraft.World\Pos.h"
5class Level;
6class User;
7class CompoundTag;
8class FurnaceTileEntity;
9class DispenserTileEntity;
10class SignTileEntity;
11class Container;
12class Input;
13class Stat;
14class Minecraft;
15
16using namespace std;
17
18// Time in seconds before the players presence is update to Idle
19#define PLAYER_IDLE_TIME 300
20
21class LocalPlayer : public Player
22{
23public:
24 static const int SPRINT_DURATION = 20 * 30;
25
26 eINSTANCEOF GetType() { return eTYPE_LOCALPLAYER; }
27
28 Input *input;
29protected:
30 Minecraft *minecraft;
31 int sprintTriggerTime;
32 bool sprintTriggerRegisteredReturn; // 4J added
33 bool twoJumpsRegistered; // 4J added
34
35 unsigned int m_uiInactiveTicks; // To measure time for idle anims
36
37 unsigned long long m_awardedThisSession;
38
39 // 4J - Last time we checked for achievement uunlocks.
40 //long long m_lastAchievementUpdate;
41
42public:
43 int sprintTime;
44
45 float yBob, xBob;
46 float yBobO, xBobO;
47
48 float portalTime;
49 float oPortalTime;
50
51 LocalPlayer(Minecraft *minecraft, Level *level, User *user, int dimension);
52 virtual ~LocalPlayer();
53
54 int m_iScreenSection; // assuming 4player splitscreen for now, or -1 for single player
55 __uint64 ullButtonsPressed; // Stores the button presses, since the inputmanager can be ticked faster than the minecraft
56 // player tick, and a button press and release combo can be missed in the minecraft::tick
57
58 __uint64 ullDpad_last;
59 __uint64 ullDpad_this;
60 __uint64 ullDpad_filtered;
61
62 // 4J-PB - moved these in from the minecraft structure, since they are per player things for splitscreen
63 //int ticks;
64 int missTime;
65 int lastClickTick[2];
66 bool isRaining ;
67 int m_iThirdPersonView;
68
69 bool m_bHasAwardedStayinFrosty;
70
71private:
72 float flyX, flyY, flyZ;
73
74 int jumpRidingTicks;
75 float jumpRidingScale;
76
77protected:
78 // 4J-PB - player's xbox pad
79 int m_iPad;
80
81 bool m_bIsIdle;
82
83private:
84 // local player fly
85 // --------------------------------------------------------------------------
86 // smooth camera settings
87
88 SmoothFloat smoothFlyX;
89 SmoothFloat smoothFlyY;
90 SmoothFloat smoothFlyZ;
91
92 void calculateFlight(float xa, float ya, float za);
93
94public:
95 virtual void serverAiStep();
96
97protected:
98 bool isEffectiveAi();
99
100public:
101 virtual void aiStep();
102 virtual void changeDimension(int i);
103 virtual float getFieldOfViewModifier();
104 virtual void addAdditonalSaveData(CompoundTag *entityTag);
105 virtual void readAdditionalSaveData(CompoundTag *entityTag);
106 virtual void closeContainer();
107 virtual void openTextEdit(shared_ptr<TileEntity> sign);
108 virtual bool openContainer(shared_ptr<Container> container); // 4J added bool return
109 virtual bool openHopper(shared_ptr<HopperTileEntity> container); // 4J added bool return
110 virtual bool openHopper(shared_ptr<MinecartHopper> container); // 4J added bool return
111 virtual bool openHorseInventory(shared_ptr<EntityHorse> horse, shared_ptr<Container> container); // 4J added bool return
112 virtual bool startCrafting(int x, int y, int z); // 4J added bool return
113 virtual bool openFireworks(int x, int y, int z); // 4J added
114 virtual bool startEnchanting(int x, int y, int z, const wstring &name); // 4J added bool return
115 virtual bool startRepairing(int x, int y, int z);
116 virtual bool openFurnace(shared_ptr<FurnaceTileEntity> furnace); // 4J added bool return
117 virtual bool openBrewingStand(shared_ptr<BrewingStandTileEntity> brewingStand); // 4J added bool return
118 virtual bool openBeacon(shared_ptr<BeaconTileEntity> beacon); // 4J added bool return
119 virtual bool openTrap(shared_ptr<DispenserTileEntity> trap); // 4J added bool return
120 virtual bool openTrading(shared_ptr<Merchant> traderTarget, const wstring &name);
121 virtual void crit(shared_ptr<Entity> e);
122 virtual void magicCrit(shared_ptr<Entity> e);
123 virtual void take(shared_ptr<Entity> e, int orgCount);
124 virtual void chat(const wstring& message);
125 virtual bool isSneaking();
126 //virtual bool isIdle();
127 virtual void hurtTo(float newHealth, ETelemetryChallenges damageSource);
128 virtual void respawn();
129 virtual void animateRespawn();
130 virtual void displayClientMessage(int messageId);
131 virtual void awardStat(Stat *stat, byteArray param);
132 virtual int ThirdPersonView() { return m_iThirdPersonView;}
133 // 4J - have changed 3rd person view to be 0 if not enabled, 1 for mode like original, 2 reversed mode
134 virtual void SetThirdPersonView(int val) {m_iThirdPersonView=val;}
135
136 void ResetInactiveTicks() { m_uiInactiveTicks=0;}
137 unsigned int GetInactiveTicks() { return m_uiInactiveTicks;}
138 void IncrementInactiveTicks() { if(m_uiInactiveTicks<255) m_uiInactiveTicks++;}
139
140 void mapPlayerChunk(unsigned int);
141 // 4J-PB - xbox pad for this player
142 void SetXboxPad(int iPad) {m_iPad=iPad;}
143 int GetXboxPad() {return m_iPad;}
144 void SetPlayerRespawned(bool bVal) {m_bPlayerRespawned=bVal;}
145 bool GetPlayerRespawned() {return m_bPlayerRespawned;}
146
147 // 4J-PB - Moved these in here from the minecraft structure since they are local player related
148 void handleMouseDown(int button, bool down);
149 bool handleMouseClick(int button);
150
151 // 4J - added for improved autorepeat
152 bool creativeModeHandleMouseClick(int button, bool buttonPressed);
153 float lastClickX;
154 float lastClickY;
155 float lastClickZ;
156 float lastClickdX;
157 float lastClickdY;
158 float lastClickdZ;
159 enum eLastClickState
160 {
161 lastClick_invalid,
162 lastClick_init,
163 lastClick_moving,
164 lastClick_stopped,
165 lastClick_oldRepeat,
166 lastClick_disabled
167 };
168 float lastClickTolerance;
169 int lastClickState;
170
171 // 4J Stu - Added to allow callback to tutorial to stay within Minecraft.Client
172 virtual void onCrafted(shared_ptr<ItemInstance> item);
173
174 virtual void setAndBroadcastCustomSkin(DWORD skinId);
175 virtual void setAndBroadcastCustomCape(DWORD capeId);
176
177private:
178 bool isSolidBlock(int x, int y, int z);
179 bool m_bPlayerRespawned;
180
181protected:
182 bool checkInTile(double x, double y, double z);
183
184public:
185 void setSprinting(bool value);
186 void setExperienceValues(float experienceProgress, int totalExp, int experienceLevel);
187
188 // virtual void sendMessage(ChatMessageComponent *message); // 4J: removed
189 virtual Pos getCommandSenderWorldPosition();
190 virtual shared_ptr<ItemInstance> getCarriedItem();
191 virtual void playSound(int soundId, float volume, float pitch);
192 bool isRidingJumpable();
193 float getJumpRidingScale();
194
195protected:
196 virtual void sendRidingJump();
197
198public:
199 bool hasPermission(EGameCommand command);
200
201 void updateRichPresence();
202
203 // 4J Stu - Added for telemetry
204 float m_sessionTimeStart;
205 float m_dimensionTimeStart;
206
207 void SetSessionTimerStart(void);
208 float getSessionTimer(void);
209
210 float getAndResetChangeDimensionTimer();
211
212 virtual void handleCollectItem(shared_ptr<ItemInstance> item);
213 void SetPlayerAdditionalModelParts(vector<ModelPart *>pAdditionalModelParts);
214
215private:
216 vector<ModelPart *> m_pAdditionalModelParts;
217};
218
219