aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/NbtSlotFile.h
blob: c717c6572206514009288a0e3fac1ee2af43521c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#pragma once
#include "CompoundTag.h"
#include "ZonedChunkStorage.h"
#include "com.mojang.nbt.h"

class NbtSlotFile
{
private:
    static byteArray READ_BUFFER;

    static const int FILE_HEADER_SIZE = 1024;
    static const int MAGIC_NUMBER = 0x13737001;

    static const int FILE_SLOT_HEADER_SIZE = 12;
    static const int FILE_SLOT_SIZE = 500;

    HANDLE raf;
    vector<int> **fileSlotMap;
	int fileSlotMapLength;
    vector<int> freeFileSlots;
    int totalFileSlots;
    static int64_t largest;

public:
    NbtSlotFile(File file);

private:
    void readHeader();
    void writeHeader();
    void seekSlotHeader(int fileSlot);
    void seekSlot(int fileSlot);

public:
    vector<CompoundTag *> *readAll(int slot);

private:
    vector<int> *toReplace;

    int getFreeSlot();

public:
    void replaceSlot(int slot, vector<CompoundTag *> *tags);
    void close();
};