MinecraftConsoles/Minecraft.World/BiomeCache.h
Riley M. c0da06e4ee
major: Switch to forward slashes(+more) to fix compilation on Linux (#1403)
Notably also adds some metadata files for NixOS 

* add support for linux clang cross compiles

* add linux clang instructions

* un-capitalize Mob.horse.*

* update the description in flake.nix

---------

Co-authored-by: Loki <lokirautio@gmail.com>
2026-04-14 16:47:37 -05:00

52 lines
1.2 KiB
C++

#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_t 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_t 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_t,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;
};