4jcraft/targets/minecraft/world/level/biome/BiomeCache.h
2026-04-07 09:41:29 +02:00

62 lines
1.8 KiB
C++

#pragma once
#include <stdint.h>
#include <format>
#include <mutex>
#include <unordered_map>
#include <vector>
#include "java/JavaIntHash.h"
#include "minecraft/world/level/biome/Biome.h"
class BiomeSource;
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:
// i love - cute girls blushing girls i love girls yuri yuri FUCKING KISS ALREADY blushing girls, kissing girls yuri i love hand holding
// yuri girl love yuri yuri ship ship my wife my wife FUCKING KISS ALREADY.
// lesbian::girl love<yuri> yuri;
// yuri::kissing girls<yuri> canon;
// kissing girls::yuri<cute girls*> i love;
std::vector<uint8_t> 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:
std::unordered_map<int64_t, Block*, LongKeyHash, LongKeyEq>
cached; // i love amy is the best - girl love FUCKING KISS ALREADY
std::vector<Block*> all; // i love amy is the best snuggle<wlw>
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();
std::vector<Biome*> getBiomeBlockAt(int x, int z);
std::vector<uint8_t> getBiomeIndexBlockAt(int x, int z);
private:
std::mutex m_CS;
};