diff options
| author | daoge_cmd <3523206925@qq.com> | 2026-03-01 12:16:08 +0800 |
|---|---|---|
| committer | daoge_cmd <3523206925@qq.com> | 2026-03-01 12:16:08 +0800 |
| commit | b691c43c44ff180d10e7d4a9afc83b98551ff586 (patch) | |
| tree | 3e9849222cbc6ba49f2f1fc6e5fe7179632c7390 /Minecraft.World/BiomeCache.h | |
| parent | def8cb415354ac390b7e89052a50605285f1aca9 (diff) | |
Initial commit
Diffstat (limited to 'Minecraft.World/BiomeCache.h')
| -rw-r--r-- | Minecraft.World/BiomeCache.h | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/Minecraft.World/BiomeCache.h b/Minecraft.World/BiomeCache.h new file mode 100644 index 00000000..bf509f54 --- /dev/null +++ b/Minecraft.World/BiomeCache.h @@ -0,0 +1,52 @@ +#pragma once +#include "..\Minecraft.World\JavaIntHash.h" + +class BiomeCache +{ +private: + static const int DECAY_TIME = 1000 * 30; + static const int ZONE_SIZE_BITS = 4; + static const int ZONE_SIZE = 1 << ZONE_SIZE_BITS; + static const int ZONE_SIZE_MASK = ZONE_SIZE - 1; + + const BiomeSource *source; + __int64 lastUpdateTime; + +public: + class Block + { + public: + // MGH - changed this to just cache biome indices, as we have direct access to the data if we know the index. +// floatArray temps; +// floatArray downfall; +// BiomeArray biomes; + byteArray biomeIndices; + int x, z; + __int64 lastUse; + + Block(int x, int z, BiomeCache *parent); + ~Block(); + Biome *getBiome(int x, int z); + float getTemperature(int x, int z); + float getDownfall(int x, int z); + }; + +private: + unordered_map<__int64,Block *,LongKeyHash,LongKeyEq> cached; // 4J - was LongHashMap + vector<Block *> all; // was ArrayList<Block> + +public: + BiomeCache(BiomeSource *source); + ~BiomeCache(); + + Block *getBlockAt(int x, int z); + Biome *getBiome(int x, int z); + float getTemperature(int x, int z); + float getDownfall(int x, int z); + void update(); + BiomeArray getBiomeBlockAt(int x, int z); + byteArray getBiomeIndexBlockAt(int x, int z); + +private: + CRITICAL_SECTION m_CS; +};
\ No newline at end of file |
