aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/MultiPlayerChunkCache.h
diff options
context:
space:
mode:
authordaoge_cmd <3523206925@qq.com>2026-03-01 12:16:08 +0800
committerdaoge_cmd <3523206925@qq.com>2026-03-01 12:16:08 +0800
commitb691c43c44ff180d10e7d4a9afc83b98551ff586 (patch)
tree3e9849222cbc6ba49f2f1fc6e5fe7179632c7390 /Minecraft.Client/MultiPlayerChunkCache.h
parentdef8cb415354ac390b7e89052a50605285f1aca9 (diff)
Initial commit
Diffstat (limited to 'Minecraft.Client/MultiPlayerChunkCache.h')
-rw-r--r--Minecraft.Client/MultiPlayerChunkCache.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/Minecraft.Client/MultiPlayerChunkCache.h b/Minecraft.Client/MultiPlayerChunkCache.h
new file mode 100644
index 00000000..8fc427a6
--- /dev/null
+++ b/Minecraft.Client/MultiPlayerChunkCache.h
@@ -0,0 +1,47 @@
+#pragma once
+#include "..\Minecraft.World\net.minecraft.world.level.h"
+#include "..\Minecraft.World\net.minecraft.world.level.chunk.h"
+#include "..\Minecraft.World\RandomLevelSource.h"
+
+using namespace std;
+class ServerChunkCache;
+
+// 4J - various alterations here to make this thread safe, and operate as a fixed sized cache
+class MultiPlayerChunkCache : public ChunkSource
+{
+ friend class LevelRenderer;
+private:
+ LevelChunk *emptyChunk;
+ LevelChunk *waterChunk;
+
+ vector<LevelChunk *> loadedChunkList;
+
+ LevelChunk **cache;
+ // 4J - added for multithreaded support
+ CRITICAL_SECTION m_csLoadCreate;
+ // 4J - size of cache is defined by size of one side - must be even
+ int XZSIZE;
+ int XZOFFSET;
+ bool *hasData;
+
+ Level *level;
+
+public:
+ MultiPlayerChunkCache(Level *level);
+ ~MultiPlayerChunkCache();
+ virtual bool hasChunk(int x, int z);
+ virtual bool reallyHasChunk(int x, int z);
+ virtual void drop(int x, int z);
+ virtual LevelChunk *create(int x, int z);
+ virtual LevelChunk *getChunk(int x, int z);
+ virtual bool save(bool force, ProgressListener *progressListener);
+ virtual bool tick();
+ virtual bool shouldSave();
+ virtual void postProcess(ChunkSource *parent, int x, int z);
+ virtual wstring gatherStats();
+ virtual vector<Biome::MobSpawnerData *> *getMobsAt(MobCategory *mobCategory, int x, int y, int z);
+ virtual TilePos *findNearestMapFeature(Level *level, const wstring &featureName, int x, int y, int z);
+ virtual void dataReceived(int x, int z); // 4J added
+
+ virtual LevelChunk **getCache() { return cache; } // 4J added
+}; \ No newline at end of file