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\net.minecraft.world.entity.player.h"
3#include "..\Minecraft.World\net.minecraft.world.inventory.ContainerListener.h"
4#include "..\Minecraft.World\ChunkPos.h"
5class PlayerConnection;
6class MinecraftServer;
7class ServerPlayerGameMode;
8class Level;
9class Stat;
10class TileEntity;
11class Entity;
12class BrewingStandTileEntity;
13class HopperTileEntity;
14class MinecartHopper;
15class BeaconTileEntity;
16class EntityHorse;
17class Merchant;
18using namespace std;
19
20class ServerPlayer : public Player, public net_minecraft_world_inventory::ContainerListener
21{
22public:
23 eINSTANCEOF GetType() { return eTYPE_SERVERPLAYER; }
24 shared_ptr<PlayerConnection> connection;
25 MinecraftServer *server;
26 ServerPlayerGameMode *gameMode;
27 double lastMoveX, lastMoveZ;
28 list<ChunkPos> chunksToSend;
29 vector<int> entitiesToRemove;
30 unordered_set<ChunkPos, ChunkPosKeyHash, ChunkPosKeyEq> seenChunks;
31 int spewTimer;
32
33 // 4J-Added, for 'Adventure Time' achievement.
34 Biome *currentBiome;
35
36private:
37 float lastRecordedHealthAndAbsorption;
38 float lastSentHealth;
39 int lastSentFood;
40 bool lastFoodSaturationZero;
41 int lastSentExp;
42 int invulnerableTime;
43 int viewDistance;
44 __int64 lastActionTime;
45 int lastBrupSendTickCount; // 4J Added
46
47public:
48 ServerPlayer(MinecraftServer *server, Level *level, const wstring& name, ServerPlayerGameMode *gameMode);
49 ~ServerPlayer();
50 void flagEntitiesToBeRemoved(unsigned int *flags, bool *removedFound); // 4J added
51
52 virtual void readAdditionalSaveData(CompoundTag *entityTag);
53 virtual void addAdditonalSaveData(CompoundTag *entityTag);
54 virtual void giveExperienceLevels(int amount);
55 void initMenu();
56
57protected:
58 virtual void setDefaultHeadHeight();
59public:
60 virtual float getHeadHeight();
61 virtual void tick();
62 void flushEntitiesToRemove();
63 virtual shared_ptr<ItemInstance> getCarried(int slot);
64 virtual void die(DamageSource *source);
65 virtual bool hurt(DamageSource *dmgSource, float dmg);
66 virtual bool canHarmPlayer(shared_ptr<Player> target);
67 bool canHarmPlayer(wstring targetName); // 4J: Added
68 void doTick(bool sendChunks, bool dontDelayChunks = false, bool ignorePortal = false);
69 void doTickA();
70 void doChunkSendingTick(bool dontDelayChunks);
71 void doTickB();
72 virtual void changeDimension(int i);
73private:
74 void broadcast(shared_ptr<TileEntity> te, bool delay = false);
75public:
76 virtual void take(shared_ptr<Entity> e, int orgCount);
77 virtual BedSleepingResult startSleepInBed(int x, int y, int z, bool bTestUse = false);
78
79public:
80 virtual void stopSleepInBed(bool forcefulWakeUp, bool updateLevelList, bool saveRespawnPoint);
81 virtual void ride(shared_ptr<Entity> e);
82protected:
83 virtual void checkFallDamage(double ya, bool onGround);
84public:
85 void doCheckFallDamage(double ya, bool onGround);
86private:
87 int containerCounter;
88public:
89 bool ignoreSlotUpdateHack;
90 int latency;
91 bool wonGame;
92 bool m_enteredEndExitPortal; // 4J Added
93
94private:
95 void nextContainerCounter();
96
97public:
98 virtual void openTextEdit(shared_ptr<TileEntity> sign);
99 virtual bool startCrafting(int x, int y, int z); // 4J added bool return
100 virtual bool openFireworks(int x, int y, int z); // 4J added
101 virtual bool startEnchanting(int x, int y, int z, const wstring &name); // 4J added bool return
102 virtual bool startRepairing(int x, int y, int z); // 4J added bool return
103 virtual bool openContainer(shared_ptr<Container> container); // 4J added bool return
104 virtual bool openHopper(shared_ptr<HopperTileEntity> container);
105 virtual bool openHopper(shared_ptr<MinecartHopper> container);
106 virtual bool openFurnace(shared_ptr<FurnaceTileEntity> furnace); // 4J added bool return
107 virtual bool openTrap(shared_ptr<DispenserTileEntity> trap); // 4J added bool return
108 virtual bool openBrewingStand(shared_ptr<BrewingStandTileEntity> brewingStand); // 4J added bool return
109 virtual bool openBeacon(shared_ptr<BeaconTileEntity> beacon);
110 virtual bool openTrading(shared_ptr<Merchant> traderTarget, const wstring &name); // 4J added bool return
111 virtual bool openHorseInventory(shared_ptr<EntityHorse> horse, shared_ptr<Container> container);
112 virtual void slotChanged(AbstractContainerMenu *container, int slotIndex, shared_ptr<ItemInstance> item);
113 void refreshContainer(AbstractContainerMenu *menu);
114 virtual void refreshContainer(AbstractContainerMenu *container, vector<shared_ptr<ItemInstance> > *items);
115 virtual void setContainerData(AbstractContainerMenu *container, int id, int value);
116 virtual void closeContainer();
117 void broadcastCarriedItem();
118 void doCloseContainer();
119 void setPlayerInput(float xa, float ya, bool jumping, bool sneaking);
120
121 virtual void awardStat(Stat *stat, byteArray param);
122
123 void disconnect();
124 void resetSentInfo();
125 virtual void displayClientMessage(int messageId);
126
127protected:
128 virtual void completeUsingItem();
129
130public:
131 virtual void startUsingItem(shared_ptr<ItemInstance> instance, int duration);
132 virtual void restoreFrom(shared_ptr<Player> oldPlayer, bool restoreAll);
133
134protected:
135 virtual void onEffectAdded(MobEffectInstance *effect);
136 virtual void onEffectUpdated(MobEffectInstance *effect, bool doRefreshAttributes);
137 virtual void onEffectRemoved(MobEffectInstance *effect);
138
139public:
140 virtual void teleportTo(double x, double y, double z);
141 virtual void crit(shared_ptr<Entity> entity);
142 virtual void magicCrit(shared_ptr<Entity> entity);
143
144 void onUpdateAbilities();
145 ServerLevel *getLevel();
146 void setGameMode(GameType *mode);
147 void sendMessage(const wstring& message, ChatPacket::EChatPacketMessage type = ChatPacket::e_ChatCustom, int customData = -1, const wstring& additionalMessage = L"");
148 bool hasPermission(EGameCommand command);
149 // bool hasPermission(int permissionLevel, EGameCommand command);
150 //void updateOptions(shared_ptr<ClientInformationPacket> packet); // 4J: Don't use
151 int getViewDistance();
152 //bool canChatInColor();
153 //int getChatVisibility();
154 Pos *getCommandSenderWorldPosition();
155 void resetLastActionTime();
156
157public:
158
159 static int getFlagIndexForChunk(const ChunkPos& pos, int dimension); // 4J - added
160 int getPlayerViewDistanceModifier(); // 4J Added, returns a number which is subtracted from the default view distance
161
162public:
163 // 4J Stu - Added hooks for the game rules
164 virtual void handleCollectItem(shared_ptr<ItemInstance> item);
165
166#ifndef _CONTENT_PACKAGE
167 void debug_setPosition(double,double,double,double,double);
168#endif
169
170protected:
171 // 4J Added to record telemetry of player deaths, this should store the last source of damage
172 ETelemetryChallenges m_lastDamageSource;
173};