2013-07-29 07:13:03 -04:00
|
|
|
|
|
|
|
// NBTChunkSerializer.h
|
|
|
|
|
|
|
|
// Declares the cNBTChunkSerializer class that is used for saving individual chunks into NBT format used by Anvil
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2014-05-18 10:10:12 -04:00
|
|
|
#include "ChunkDataCallback.h"
|
2013-07-29 07:13:03 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// fwd:
|
|
|
|
class cFastNBTWriter;
|
|
|
|
class cEntity;
|
|
|
|
class cBlockEntity;
|
2013-09-07 19:14:57 -04:00
|
|
|
class cBoat;
|
2014-07-30 16:50:34 -04:00
|
|
|
class cBeaconEntity;
|
2013-07-29 07:13:03 -04:00
|
|
|
class cChestEntity;
|
2014-01-18 08:40:47 -05:00
|
|
|
class cCommandBlockEntity;
|
2013-07-29 07:13:03 -04:00
|
|
|
class cDispenserEntity;
|
|
|
|
class cDropperEntity;
|
2014-03-25 14:59:33 -04:00
|
|
|
class cEnderCrystal;
|
2013-07-29 07:13:03 -04:00
|
|
|
class cFurnaceEntity;
|
|
|
|
class cHopperEntity;
|
|
|
|
class cJukeboxEntity;
|
|
|
|
class cNoteEntity;
|
|
|
|
class cSignEntity;
|
2014-02-19 08:45:09 -05:00
|
|
|
class cMobHeadEntity;
|
2014-09-19 17:00:54 -04:00
|
|
|
class cMobSpawnerEntity;
|
2014-03-06 19:30:34 -05:00
|
|
|
class cFlowerPotEntity;
|
2013-07-29 07:13:03 -04:00
|
|
|
class cFallingBlock;
|
|
|
|
class cMinecart;
|
|
|
|
class cMinecartWithChest;
|
|
|
|
class cMinecartWithFurnace;
|
2013-08-16 06:23:24 -04:00
|
|
|
class cMinecartWithTNT;
|
|
|
|
class cMinecartWithHopper;
|
2013-07-29 07:13:03 -04:00
|
|
|
class cMonster;
|
|
|
|
class cPickup;
|
|
|
|
class cItemGrid;
|
2013-08-22 16:31:38 -04:00
|
|
|
class cProjectileEntity;
|
2014-03-08 04:25:46 -05:00
|
|
|
class cTNTEntity;
|
2014-03-14 19:32:49 -04:00
|
|
|
class cExpOrb;
|
2014-03-14 21:45:25 -04:00
|
|
|
class cHangingEntity;
|
|
|
|
class cItemFrame;
|
2014-07-11 21:58:11 -04:00
|
|
|
class cEntityEffect;
|
2013-07-29 07:13:03 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class cNBTChunkSerializer :
|
|
|
|
public cChunkDataSeparateCollector
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
cChunkDef::BiomeMap m_Biomes;
|
|
|
|
unsigned char m_VanillaBiomes[cChunkDef::Width * cChunkDef::Width];
|
2014-09-23 13:16:17 -04:00
|
|
|
int m_VanillaHeightMap[cChunkDef::Width * cChunkDef::Width];
|
2013-07-29 07:13:03 -04:00
|
|
|
bool m_BiomesAreValid;
|
|
|
|
|
|
|
|
|
|
|
|
cNBTChunkSerializer(cFastNBTWriter & a_Writer);
|
|
|
|
|
|
|
|
/// Close NBT tags that we've opened
|
|
|
|
void Finish(void);
|
|
|
|
|
|
|
|
bool IsLightValid(void) const {return m_IsLightValid; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
/* From cChunkDataSeparateCollector we inherit:
|
|
|
|
- m_BlockTypes[]
|
|
|
|
- m_BlockMetas[]
|
|
|
|
- m_BlockLight[]
|
|
|
|
- m_BlockSkyLight[]
|
|
|
|
*/
|
|
|
|
|
|
|
|
cFastNBTWriter & m_Writer;
|
|
|
|
|
|
|
|
bool m_IsTagOpen; // True if a tag has been opened in the callbacks and not yet closed.
|
|
|
|
bool m_HasHadEntity; // True if any Entity has already been received and processed
|
|
|
|
bool m_HasHadBlockEntity; // True if any BlockEntity has already been received and processed
|
|
|
|
bool m_IsLightValid; // True if the chunk lighting is valid
|
|
|
|
|
|
|
|
|
|
|
|
/// Writes an item into the writer, if slot >= 0, adds the Slot tag. The compound is named as requested.
|
|
|
|
void AddItem(const cItem & a_Item, int a_Slot, const AString & a_CompoundName = "");
|
|
|
|
|
|
|
|
/// Writes an item grid into the writer; begins the stored slot numbers with a_BeginSlotNum. Note that it doesn't begin nor end the list tag
|
|
|
|
void AddItemGrid(const cItemGrid & a_Grid, int a_BeginSlotNum = 0);
|
|
|
|
|
|
|
|
// Block entities:
|
2014-09-19 17:00:54 -04:00
|
|
|
void AddBasicTileEntity (cBlockEntity * a_Entity, const char * a_EntityTypeID);
|
|
|
|
void AddBeaconEntity (cBeaconEntity * a_Entity);
|
|
|
|
void AddChestEntity (cChestEntity * a_Entity, BLOCKTYPE a_ChestType);
|
|
|
|
void AddDispenserEntity (cDispenserEntity * a_Entity);
|
|
|
|
void AddDropperEntity (cDropperEntity * a_Entity);
|
|
|
|
void AddFurnaceEntity (cFurnaceEntity * a_Furnace);
|
|
|
|
void AddHopperEntity (cHopperEntity * a_Entity);
|
|
|
|
void AddJukeboxEntity (cJukeboxEntity * a_Jukebox);
|
|
|
|
void AddMobSpawnerEntity (cMobSpawnerEntity * a_MobSpawner);
|
|
|
|
void AddNoteEntity (cNoteEntity * a_Note);
|
|
|
|
void AddSignEntity (cSignEntity * a_Sign);
|
|
|
|
void AddMobHeadEntity (cMobHeadEntity * a_MobHead);
|
2014-01-18 08:40:47 -05:00
|
|
|
void AddCommandBlockEntity(cCommandBlockEntity * a_CmdBlock);
|
2014-09-19 17:00:54 -04:00
|
|
|
void AddFlowerPotEntity (cFlowerPotEntity * a_FlowerPot);
|
2013-07-29 07:13:03 -04:00
|
|
|
|
|
|
|
// Entities:
|
|
|
|
void AddBasicEntity (cEntity * a_Entity, const AString & a_ClassName);
|
2013-09-07 19:14:57 -04:00
|
|
|
void AddBoatEntity (cBoat * a_Boat);
|
2014-03-25 14:59:33 -04:00
|
|
|
void AddEnderCrystalEntity(cEnderCrystal * a_EnderCrystal);
|
2013-07-29 07:13:03 -04:00
|
|
|
void AddFallingBlockEntity(cFallingBlock * a_FallingBlock);
|
|
|
|
void AddMinecartEntity (cMinecart * a_Minecart);
|
|
|
|
void AddMonsterEntity (cMonster * a_Monster);
|
|
|
|
void AddPickupEntity (cPickup * a_Pickup);
|
2013-08-22 16:31:38 -04:00
|
|
|
void AddProjectileEntity (cProjectileEntity * a_Projectile);
|
2014-03-14 21:45:25 -04:00
|
|
|
void AddHangingEntity (cHangingEntity * a_Hanging);
|
2014-03-08 04:25:46 -05:00
|
|
|
void AddTNTEntity (cTNTEntity * a_TNT);
|
2014-03-14 19:32:49 -04:00
|
|
|
void AddExpOrbEntity (cExpOrb * a_ExpOrb);
|
2014-03-14 21:45:25 -04:00
|
|
|
void AddItemFrameEntity (cItemFrame * a_ItemFrame);
|
2013-07-29 07:13:03 -04:00
|
|
|
|
|
|
|
void AddMinecartChestContents(cMinecartWithChest * a_Minecart);
|
|
|
|
|
|
|
|
// cChunkDataSeparateCollector overrides:
|
2014-04-26 13:50:23 -04:00
|
|
|
virtual void LightIsValid(bool a_IsLightValid) override;
|
2014-09-23 13:16:17 -04:00
|
|
|
virtual void HeightMap(const cChunkDef::HeightMap * a_HeightMap) override;
|
2013-07-29 07:13:03 -04:00
|
|
|
virtual void BiomeData(const cChunkDef::BiomeMap * a_BiomeMap) override;
|
|
|
|
virtual void Entity(cEntity * a_Entity) override;
|
|
|
|
virtual void BlockEntity(cBlockEntity * a_Entity) override;
|
|
|
|
} ; // class cNBTChunkSerializer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|