the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#pragma once
2using namespace std;
3#include "..\Minecraft.World\HashExtension.h"
4#include "..\Minecraft.World\net.minecraft.world.level.h"
5#include "..\Minecraft.World\net.minecraft.world.entity.h"
6#include "..\Minecraft.World\JavaIntHash.h"
7
8class ClientConnection;
9class MultiPlayerChunkCache;
10
11using namespace std;
12
13class MultiPlayerLevel : public Level
14{
15private:
16 static const int TICKS_BEFORE_RESET = 20 * 4;
17
18 class ResetInfo
19 {
20 public:
21 int x, y, z, ticks, tile, data;
22 ResetInfo(int x, int y, int z, int tile, int data);
23 };
24
25 vector<ResetInfo> updatesToReset; // 4J - was linked list but vector seems more appropriate
26 bool m_bEnableResetChanges; // 4J Added
27public:
28 void unshareChunkAt(int x, int z); // 4J - added
29 void shareChunkAt(int x, int z); // 4J - added
30
31 void enableResetChanges(bool enable) { m_bEnableResetChanges = enable; } // 4J Added
32private:
33 int unshareCheckX; // 4J - added
34 int unshareCheckZ; // 4J - added
35 int compressCheckX; // 4J - added
36 int compressCheckZ; // 4J - added
37 vector<ClientConnection *> connections; // 4J Stu - Made this a vector as we can have more than one local connection
38 MultiPlayerChunkCache *chunkCache;
39 Minecraft *minecraft;
40 Scoreboard *scoreboard;
41
42public:
43 MultiPlayerLevel(ClientConnection *connection, LevelSettings *levelSettings, int dimension, int difficulty);
44 virtual ~MultiPlayerLevel();
45 virtual void tick() ;
46
47 void clearResetRegion(int x0, int y0, int z0, int x1, int y1, int z1);
48protected:
49 ChunkSource *createChunkSource(); // 4J - was virtual, but was called from parent ctor
50public:
51 virtual void validateSpawn();
52protected:
53 virtual void tickTiles();
54public:
55 void setChunkVisible(int x, int z, bool visible);
56
57private:
58 unordered_map<int, shared_ptr<Entity>, IntKeyHash2, IntKeyEq> entitiesById; // 4J - was IntHashMap
59 unordered_set<shared_ptr<Entity> > forced;
60 unordered_set<shared_ptr<Entity> > reEntries;
61
62public:
63 virtual bool addEntity(shared_ptr<Entity> e);
64 virtual void removeEntity(shared_ptr<Entity> e);
65protected:
66 virtual void entityAdded(shared_ptr<Entity> e);
67 virtual void entityRemoved(shared_ptr<Entity> e);
68public:
69 void putEntity(int id, shared_ptr<Entity> e);
70 shared_ptr<Entity> getEntity(int id);
71 shared_ptr<Entity> removeEntity(int id);
72 virtual void removeEntities(vector<shared_ptr<Entity> > *list); // 4J Added override
73 virtual bool setData(int x, int y, int z, int data, int updateFlags, bool forceUpdate =false );
74 virtual bool setTileAndData(int x, int y, int z, int tile, int data, int updateFlags);
75 bool doSetTileAndData(int x, int y, int z, int tile, int data);
76 virtual void disconnect(bool sendDisconnect = true);
77 void animateTick(int xt, int yt, int zt);
78protected:
79 virtual Tickable *makeSoundUpdater(shared_ptr<Minecart> minecart);
80 virtual void tickWeather();
81
82 static const int ANIMATE_TICK_MAX_PARTICLES = 500;
83
84public:
85 void animateTickDoWork(); // 4J added
86 unordered_set<int> chunksToAnimate; // 4J added
87
88public:
89 void removeAllPendingEntityRemovals();
90
91 virtual void playSound(shared_ptr<Entity> entity, int iSound, float volume, float pitch);
92
93 virtual void playLocalSound(double x, double y, double z, int iSound, float volume, float pitch, bool distanceDelay = false, float fClipSoundDist = 16.0f);
94
95 virtual void createFireworks(double x, double y, double z, double xd, double yd, double zd, CompoundTag *infoTag);
96 virtual void setScoreboard(Scoreboard *scoreboard);
97 virtual void setDayTime(__int64 newTime);
98
99 // 4J Stu - Added so we can have multiple local connections
100 void addClientConnection(ClientConnection *c) { connections.push_back( c ); }
101 void removeClientConnection(ClientConnection *c, bool sendDisconnect);
102
103 void tickAllConnections();
104
105 void dataReceivedForChunk(int x, int z); // 4J added
106 void removeUnusedTileEntitiesInRegion(int x0, int y0, int z0, int x1, int y1, int z1); // 4J added
107};