3 #include "../BlockEntities/BlockEntity.h"
92 std::list<std::shared_ptr<cMCAFile>>
m_Files;
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
std::vector< OwnedEntity > cEntityList
unsigned char BLOCKTYPE
The datatype used by blockdata.
std::basic_string_view< std::byte > ContiguousByteBufferView
std::basic_string< std::byte > ContiguousByteBuffer
std::vector< AString > AStringVector
Wraps the chunk coords into a single structure.
HEIGHTTYPE HeightMap[Width *Width]
The type used for any heightmap operations and storage; idx = x + Width * z; Height points to the hig...
EMCSBiome BiomeMap[Width *Width]
The type used for any biomemap operations and storage inside Cuberite, using Cuberite biomes (need no...
Contains the result of a compression or extraction operation.
Contains routines for data compression.
Contains routines for data extraction.
Parses and contains the parsed data Also implements data accessor functions for tree traversal and va...
Implements the Anvil world storage schema.
bool SetChunkData(const cChunkCoords &a_Chunk, ContiguousByteBufferView a_Data)
Sets chunk data into the correct file; locks file CS as needed.
bool LoadMonsterBaseFromNBT(cMonster &a_Monster, const cParsedNBT &a_NBT, int a_TagIdx)
Loads monster common data from the NBT compound; returns true if successful.
void LoadLeashKnotFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadSnowGolemFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadLeashToPosition(cMonster &a_Monster, const cParsedNBT &a_NBT, int a_TagIdx)
Loads the position to where is leashed the monster.
void LoadMinecartRFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadMooshroomFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadPillagerFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadThrownEnderpearlFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
virtual const AString GetName() const override
void LoadVindicatorFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
AString DecodeSignLine(const AString &a_Line)
Decodes the text contained within a sign.
virtual bool SaveChunk(const cChunkCoords &a_Chunk) override
OwnedBlockEntity LoadBedFromNBT(const cParsedNBT &a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos)
void LoadLlamaFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadBlockEntitiesFromNBT(cBlockEntities &a_BlockEntitites, const cParsedNBT &a_NBT, int a_Tag, const ChunkBlockData &a_BlockData)
Loads the chunk's BlockEntities from NBT data (a_Tag is the Level\TileEntities list tag; may be -1)
void LoadTNTFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadZombieVillagerFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadPigFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadArrowFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadSkeletonFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
bool CheckBlockEntityType(const cParsedNBT &a_NBT, int a_TagIdx, const AStringVector &a_ExpectedTypes, Vector3i a_Pos)
Returns true iff the "id" child tag inside the specified tag equals (case-sensitive) any of the speci...
const std::byte * GetSectionData(const cParsedNBT &a_NBT, int a_Tag, const AString &a_ChildName, size_t a_Length)
Copies a_Length bytes of data from the specified NBT Tag's Child into the a_Destination buffer.
bool GetChunkData(const cChunkCoords &a_Chunk, ContiguousByteBuffer &a_Data)
Gets chunk data from the correct file; locks file CS as needed.
void LoadSilverfishFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
OwnedBlockEntity LoadEnderChestFromNBT(const cParsedNBT &a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos)
Compression::Compressor m_Compressor
void LoadSalmonFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadHuskFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadCowFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
std::shared_ptr< cMCAFile > LoadMCAFile(const cChunkCoords &a_Chunk)
Gets the correct MCA file either from cache or from disk, manages the m_MCAFiles cache; assumes m_CS ...
void LoadMuleFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadHorseFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadMinecartFFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
OwnedBlockEntity LoadBlockEntityFromNBT(const cParsedNBT &a_NBT, int a_Tag, Vector3i a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Loads the data for a block entity from the specified NBT tag.
void LoadFallingBlockFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadMinecartHFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadDrownedFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadChickenFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadGiantFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadItemGridFromNBT(cItemGrid &a_ItemGrid, const cParsedNBT &a_NBT, int a_ItemsTagIdx, int s_SlotOffset=0)
Loads contentents of an Items[] list tag into a cItemGrid ItemGrid begins at the specified slot offse...
void LoadGuardianFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadDolphinFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadCreeperFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadBlazeFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadWanderingTraderFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadHoglinFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
OwnedBlockEntity LoadBeaconFromNBT(const cParsedNBT &a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos)
void LoadTraderLlamaFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadZoglinFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadSkeletonHorseFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
bool GetBlockEntityNBTPos(const cParsedNBT &a_NBT, int a_TagIdx, Vector3i &a_AbsPos)
Helper function for extracting the X, Y, and Z int subtags of a NBT compound; returns true if success...
OwnedBlockEntity LoadDropperFromNBT(const cParsedNBT &a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos)
void LoadBatFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadEvokerFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadPickupFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadWitherFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadShulkerFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadPandaFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
bool LoadDoublesListFromNBT(double *a_Doubles, int a_NumDoubles, const cParsedNBT &a_NBT, int a_TagIdx)
Loads an array of doubles of the specified length from the specified NBT list tag a_TagIdx; returns t...
void LoadWitchFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
bool LoadEntityBaseFromNBT(cEntity &a_Entity, const cParsedNBT &a_NBT, int a_TagIdx)
Loads entity common data from the NBT compound; returns true if successful.
void LoadCodFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
OwnedBlockEntity LoadEnchantingTableFromNBT(const cParsedNBT &a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos)
void LoadWolfFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
OwnedBlockEntity LoadCommandBlockFromNBT(const cParsedNBT &a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos)
void LoadPolarBearFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadRavagerFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
OwnedBlockEntity LoadNoteBlockFromNBT(const cParsedNBT &a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos)
OwnedBlockEntity LoadMobSpawnerFromNBT(const cParsedNBT &a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos)
void LoadStriderFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadExpOrbFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadZombieHorseFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadFoxFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadSheepFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadWitherSkeletonFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadCaveSpiderFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadHangingFromNBT(cHangingEntity &a_Hanging, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadZombifiedPiglinFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
std::pair< AString, cUUID > LoadEntityOwner(const cParsedNBT &a_NBT, int a_TagIdx)
Loads the owner name and UUID from the entity at the specified NBT tag.
OwnedBlockEntity LoadFlowerPotFromNBT(const cParsedNBT &a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos)
OwnedBlockEntity LoadBannerFromNBT(const cParsedNBT &a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos)
OwnedBlockEntity LoadBrewingstandFromNBT(const cParsedNBT &a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos)
void LoadItemFrameFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadEnderCrystalFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
virtual bool LoadChunk(const cChunkCoords &a_Chunk) override
OwnedBlockEntity LoadFurnaceFromNBT(const cParsedNBT &a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos)
void LoadEggFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadEndermiteFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
Compression::Extractor m_Extractor
void LoadSquidFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadPiglinBruteFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
cCriticalSection m_CS
Protects m_Files against multithreaded access.
void LoadIllusionerFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadMinecartCFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
Compression::Result SaveChunkToData(const cChunkCoords &a_Chunk)
Saves the chunk into datastream (no locking needed)
OwnedBlockEntity LoadMobHeadFromNBT(const cParsedNBT &a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos)
void LoadSnowballFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadEndermanFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadBoatFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
OwnedBlockEntity LoadSignFromNBT(const cParsedNBT &a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos)
void ChunkLoadFailed(const cChunkCoords a_ChunkCoords, const AString &a_Reason, ContiguousByteBufferView a_ChunkDataToSave)
Reports that the specified chunk failed to load and saves the chunk data to an external file.
std::list< std::shared_ptr< cMCAFile > > m_Files
A MRU cache of MCA files.
void LoadRabbitFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadTropicalFishFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadZombieFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadPaintingFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
bool LoadItemFromNBT(cItem &a_Item, const cParsedNBT &a_NBT, int a_TagIdx)
Loads a cItem contents from the specified NBT tag; returns true if successful.
OwnedBlockEntity LoadHopperFromNBT(const cParsedNBT &a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos)
bool LoadProjectileBaseFromNBT(cProjectileEntity &a_Entity, const cParsedNBT &a_NBT, int a_TagIx)
Loads projectile common data from the NBT compound; returns true if successful.
void LoadTurtleFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadMagmaCubeFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadDonkeyFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
OwnedBlockEntity LoadDispenserFromNBT(const cParsedNBT &a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos)
bool LoadHeightMapFromNBT(cChunkDef::HeightMap &a_HeightMap, const cParsedNBT &a_NBT, int a_TagIdx)
Loads the chunk's height map into a_HeightMap if heights present and valid; returns false otherwise.
bool LoadBiomeMapFromNBT(cChunkDef::BiomeMap &a_BiomeMap, const cParsedNBT &a_NBT, int a_TagIdx)
Loads the chunk's biome map into a_BiomeMap if biomes present and valid; returns false otherwise.
bool LoadChunkFromData(const cChunkCoords &a_Chunk, ContiguousByteBufferView a_Data)
Loads the chunk from the data (no locking needed)
void LoadFireballFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadVillagerFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadParrotFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadVexFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadFireChargeFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadPufferfishFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadEntitiesFromNBT(cEntityList &a_Entitites, const cParsedNBT &a_NBT, int a_Tag)
Loads the chunk's entities from NBT data (a_Tag is the Level\Entities list tag; may be -1)
void LoadElderGuardianFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadMinecartTFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
bool LoadChunkFromNBT(const cChunkCoords &a_Chunk, const cParsedNBT &a_NBT, ContiguousByteBufferView a_RawChunkData)
Loads the chunk from NBT data (no locking needed).
OwnedBlockEntity LoadChestFromNBT(const cParsedNBT &a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos)
void LoadOcelotFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadGhastFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
@ MCA_MAX_CHUNKS
Maximum number of chunks in an MCA file - also the count of the header items.
@ MCA_HEADER_SIZE
The MCA header is 8 KiB.
@ MCA_CHUNK_HEADER_LENGTH
There are 5 bytes of header in front of each chunk.
void LoadSlimeFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadOldMinecartFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadSplashPotionFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
cWSSAnvil(cWorld *a_World, int a_CompressionFactor)
void LoadEnderDragonFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadPhantomFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
OwnedBlockEntity LoadJukeboxFromNBT(const cParsedNBT &a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos)
OwnedBlockEntity LoadEndPortalFromNBT(const cParsedNBT &a_NBT, int a_TagIdx, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, Vector3i a_Pos)
virtual ~cWSSAnvil() override
void LoadStrayFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadSpiderFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadPiglinFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
bool LoadFloatsListFromNBT(float *a_Floats, int a_NumFloats, const cParsedNBT &a_NBT, int a_TagIdx)
Loads an array of floats of the specified length from the specified NBT list tag a_TagIdx; returns tr...
void LoadEntityFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_EntityTagIdx, std::string_view a_EntityName)
void LoadIronGolemFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
void LoadCatFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx)
bool OpenFile(bool a_IsForReading)
Opens a MCA file either for a Read operation (fails if doesn't exist) or for a Write operation (creat...
cWSSAnvil & m_ParentSchema
unsigned m_Header[MCA_MAX_CHUNKS]
unsigned m_TimeStamps[MCA_MAX_CHUNKS]
bool GetChunkData(const cChunkCoords &a_Chunk, ContiguousByteBuffer &a_Data)
const AString & GetFileName() const
cMCAFile(cWSSAnvil &a_ParentSchema, const AString &a_FileName, int a_RegionX, int a_RegionZ)
bool SetChunkData(const cChunkCoords &a_Chunk, ContiguousByteBufferView a_Data)
unsigned FindFreeLocation(int a_LocalX, int a_LocalZ, size_t a_DataSize)
Finds a free location large enough to hold a_Data.
std::unordered_map< size_t, OwnedBlockEntity > cBlockEntities
std::unique_ptr< cBlockEntity > OwnedBlockEntity