9 #include "../ChunkDataCallback.h"
10 #include "../ItemGrid.h"
11 #include "../StringCompression.h"
15 #include "../BlockEntities/BannerEntity.h"
16 #include "../BlockEntities/BeaconEntity.h"
17 #include "../BlockEntities/BedEntity.h"
18 #include "../BlockEntities/BrewingstandEntity.h"
19 #include "../BlockEntities/ChestEntity.h"
20 #include "../BlockEntities/CommandBlockEntity.h"
21 #include "../BlockEntities/DispenserEntity.h"
22 #include "../BlockEntities/DropperEntity.h"
23 #include "../BlockEntities/EnchantingTableEntity.h"
24 #include "../BlockEntities/EnderChestEntity.h"
25 #include "../BlockEntities/EndPortalEntity.h"
26 #include "../BlockEntities/FurnaceEntity.h"
27 #include "../BlockEntities/HopperEntity.h"
28 #include "../BlockEntities/JukeboxEntity.h"
29 #include "../BlockEntities/MobSpawnerEntity.h"
30 #include "../BlockEntities/NoteEntity.h"
31 #include "../BlockEntities/SignEntity.h"
32 #include "../BlockEntities/MobHeadEntity.h"
33 #include "../BlockEntities/FlowerPotEntity.h"
35 #include "../Entities/Entity.h"
36 #include "../Entities/EnderCrystal.h"
37 #include "../Entities/FallingBlock.h"
38 #include "../Entities/Boat.h"
39 #include "../Entities/Minecart.h"
40 #include "../Entities/Pickup.h"
41 #include "../Entities/ArrowEntity.h"
42 #include "../Entities/SplashPotionEntity.h"
43 #include "../Entities/TNTEntity.h"
44 #include "../Entities/ExpOrb.h"
45 #include "../Entities/HangingEntity.h"
46 #include "../Entities/ItemFrame.h"
47 #include "../Entities/LeashKnot.h"
48 #include "../Entities/Painting.h"
50 #include "../Mobs/IncludeAllMonsters.h"
126 if (a_BiomeMap[i] < 255)
134 ASSERT(!
"Unimplemented MCS-specific biome");
180 ASSERT(!
"Unhandled entity type is being saved");
237 ASSERT(!
"Unhandled block entity saved into Anvil");
347 for (
int i = 0; i < NumSlots; i++)
792 const Vector3d * LeashedToPos =
nullptr;
803 if (LeashedToPos !=
nullptr)
836 const cHorse *Horse =
static_cast<const cHorse *
>(a_Monster);
855 const auto *Ocelot =
static_cast<const cOcelot *
>(a_Monster);
856 if (!Ocelot->GetOwnerName().empty())
860 if (!Ocelot->GetOwnerUUID().IsNil())
884 const cSheep *Sheep =
static_cast<const cSheep *
>(a_Monster);
912 const cWolf *Wolf =
static_cast<const cWolf *
>(a_Monster);
1009 ASSERT(!
"NBTChunkSerializer::SerializerCollector::AddMonsterEntity: Recieved mob of invalid type");
1077 ASSERT(!
"Unsaved projectile entity!");
1198 [[maybe_unused]]
const bool Result = aWorld.
GetChunkData(aCoords, serializer);
1212 aWriter.BeginCompound(
"");
1214 if (Blocks != nullptr)
1216 aWriter.AddByteArray(
"Blocks", reinterpret_cast<const char *>(Blocks->data()), Blocks->size());
1220 aWriter.AddByteArray(
"Blocks", ChunkBlockData::SectionBlockCount, ChunkBlockData::DefaultValue);
1223 if (Metas !=
nullptr)
1225 aWriter.
AddByteArray(
"Data",
reinterpret_cast<const char *
>(Metas->data()), Metas->size());
1232 if (BlockLights !=
nullptr)
1234 aWriter.
AddByteArray(
"BlockLight",
reinterpret_cast<const char *
>(BlockLights->data()), BlockLights->size());
1241 if (SkyLights !=
nullptr)
1243 aWriter.
AddByteArray(
"SkyLight",
reinterpret_cast<const char *
>(SkyLights->data()), SkyLights->size());
1250 aWriter.
AddByte(
"Y",
static_cast<unsigned char>(Y));
1257 if (serializer.mIsLightValid)
1259 aWriter.AddByte(
"MCSIsLightValid", 1);
1263 aWriter.AddLong(
"LastUpdate", aWorld.GetWorldAge().count());
1266 aWriter.AddByte(
"TerrainPopulated", 1);
1268 aWriter.EndCompound();
@ E_BLOCK_STANDING_BANNER
@ E_BLOCK_ENCHANTMENT_TABLE
#define ChunkDef_ForEachSection(BlockData, LightData, Callback)
Invokes the callback functor for every chunk section containing at least one present block or light s...
unsigned char BLOCKTYPE
The datatype used by blockdata.
#define ARRAYCOUNT(X)
Evaluates to the number of elements in an array (compile-time!)
std::enable_if< std::is_arithmetic< T >::value, C >::type FloorC(T a_Value)
Floors a value, then casts it to C (an int by default).
void WriteToNBTCompound(const cEnchantments &a_Enchantments, cFastNBTWriter &a_Writer, const AString &a_ListTagName)
Writes the enchantments into the specified NBT writer; begins with the LIST tag of the specified name...
std::string_view From(CustomStatistic a_ID)
unsigned char GetBaseColor() const
const AString & GetCustomName() const
cEntityEffect::eType GetPrimaryEffect(void) const
char GetBeaconLevel(void) const
Returns the beacon level.
cEntityEffect::eType GetSecondaryEffect(void) const
short GetColor(void) const
Returns the color of the bed.
BLOCKTYPE GetBlockType() const
cItemGrid & GetContents(void)
Returns the ItemGrid used for storing the contents.
short GetTimeBrewed(void)
Returns the time that the current items has been brewing, in ticks.
short GetRemainingFuel(void)
Returns the remaining fuel that is left.
const AString & GetLastOutput(void) const
Retrieves the last line of output generated by the command block.
NIBBLETYPE GetResult(void) const
Retrieves the result (signal strength) of the last operation.
const AString & GetCommand(void) const
Retrieves stored command.
const AString & GetCustomName() const
cItem GetItem(void) const
Get the item in the flower pot.
int GetFuelBurnTimeLeft(void) const
Returns the time until the current fuel is depleted, in ticks.
int GetTimeCooked(void) const
Returns the time that the current item has been cooking, in ticks.
eMobHeadRotation GetRotation(void) const
Returns the rotation of the mob head.
AString GetOwnerTexture(void) const
Returns the texture of the mob head.
AString GetOwnerName(void) const
Returns the player name of the mob head.
AString GetOwnerTextureSignature(void) const
Returns the texture signature of the mob head.
eMobHeadType GetType(void) const
Returns the type of the mob head.
cUUID GetOwnerUUID(void) const
Returns the player UUID of the mob head.
short GetSpawnDelay(void) const
short GetRequiredPlayerRange(void) const
short GetMaxSpawnDelay(void) const
short GetSpawnRange(void) const
short GetMinSpawnDelay(void) const
short GetSpawnCount(void) const
eMonsterType GetEntity(void) const
short GetMaxNearbyEntities(void) const
unsigned char GetNote(void)
AString GetLine(size_t a_Index) const
Retrieves individual line (zero-based index)
static constexpr NIBBLETYPE DefaultMetaValue
static constexpr size_t SectionMetaCount
static constexpr NIBBLETYPE DefaultSkyLightValue
static constexpr NIBBLETYPE DefaultBlockLightValue
static constexpr size_t SectionLightCount
A simple implementation of the cChunkDataCallback interface that just copies the cChunkData.
ChunkBlockData m_BlockData
ChunkLightData m_LightData
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...
static HEIGHTTYPE GetHeight(const HeightMap &a_HeightMap, int a_X, int a_Z)
EMCSBiome BiomeMap[Width *Width]
The type used for any biomemap operations and storage inside Cuberite, using Cuberite biomes (need no...
bool IsEmpty(void) const
Returns true if there are no enchantments.
static AString MaterialToString(const eMaterial a_Material)
Returns the eMaterial as string.
eMaterial GetMaterial(void) const
Returns the eMaterial of the boat.
Vector3i GetBeamTarget() const
bool DisplaysBeam() const
If the EnderCrystal should send it's beam to the client and save it.
double GetSpeedZ(void) const
double GetSpeedY(void) const
double GetPosX(void) const
double GetPosZ(void) const
eEntityType GetEntityType(void) const
double GetPitch(void) const
bool IsLeashKnot(void) const
double GetPosY(void) const
double GetYaw(void) const
float GetHealth(void) const
Returns the health of this entity.
const Vector3d & GetPosition(void) const
Exported in ManualBindings.
double GetSpeedX(void) const
int GetReward(void) const
Get the exp amount.
int GetAge(void) const
Returns the number of ticks that this entity has existed.
NIBBLETYPE GetBlockMeta(void) const
BLOCKTYPE GetBlockType(void) const
Byte GetProtocolFacing() const
Returns the direction in which the entity is facing.
Byte GetItemRotation(void) const
Returns the rotation from the item in the frame.
const cItem & GetItem(void) const
Returns the item in the frame.
ePayload GetPayload(void) const
const cItem & GetSlot(int a_Idx) const
const AString & GetName(void) const
Returns the protocol name of the painting.
int GetAge(void) const
Returns the number of ticks that this entity has existed.
bool IsInGround(void) const
Returns true if the projectile has hit the ground and is stuck there.
AString GetCreatorName(void) const
Returns the name of the player that created the projectile Will be empty for non-player creators.
AString GetMCAClassName(void) const
Returns the string that is used as the entity type (class name) in MCA files.
eKind GetProjectileKind(void) const
Returns the kind of the projectile (fast class identification)
unsigned GetFuseTicks(void) const
Returns the fuse ticks until the tnt will explode.
cEnchantments m_Enchantments
AStringVector m_LoreTable
cFireworkItem m_FireworkItem
const cItem & GetSlot(int a_X, int a_Y) const
int GetNumSlots(void) const
BLOCKTYPE GetCarriedBlock(void) const
NIBBLETYPE GetCarriedMeta(void) const
bool IsTame(void) const override
bool IsEating(void) const
bool IsChested(void) const
int GetHorseArmour(void) const
bool IsSaddled(void) const
int GetHorseType(void) const
int GetHorseStyle(void) const
int GetHorseColor(void) const
const AString & GetCustomName(void) const
Gets the custom name of the monster.
float GetDropChanceChestplate()
float GetDropChanceHelmet()
Vector3d * GetLeashToPos() const
Gets entity position to where mob should be leashed.
bool IsCustomNameAlwaysVisible(void) const
Is the custom name of this monster always visible? If not, you only see the name when you sight the m...
bool IsLeashed() const
Returns whether the monster is leashed to an entity.
float GetDropChanceWeapon()
eMonsterType GetMobType(void) const
cEntity * GetLeashedTo() const
Returns the entity to where this mob is leashed, returns nullptr if it's not leashed.
float GetDropChanceBoots()
float GetDropChanceLeggings()
bool IsSheared(void) const
int GetFurColor(void) const
int GetVilType(void) const
cItemGrid & GetInventory(void)
Returns the villager hidden inventory (8 slots).
cUUID GetOwnerUUID(void) const
AString GetOwnerName(void) const
bool IsSitting(void) const override
int GetCollarColor(void) const
cVillager::eVillagerType GetProfession(void) const
int ConversionTime(void) const
AString ToShortString() const
Converts the UUID to a short form string (i.e without dashes).
bool IsNil() const
Returns true if this contains the "nil" UUID with all bits set to 0.
bool GetChunkData(cChunkCoords a_Coords, cChunkDataCallback &a_Callback) const
Calls the callback with the chunk's data, if available (with ChunkCS locked).
void AddByteArray(const AString &a_Name, const char *a_Value, size_t a_NumElements)
void AddByte(const AString &a_Name, unsigned char a_Value)
void AddDouble(const AString &a_Name, double a_Value)
void AddShort(const AString &a_Name, Int16 a_Value)
void AddInt(const AString &a_Name, Int32 a_Value)
void AddString(const AString &a_Name, std::string_view a_Value)
void BeginList(const AString &a_Name, eTagType a_ChildrenType)
void AddFloat(const AString &a_Name, float a_Value)
void AddIntArray(const AString &a_Name, const Int32 *a_Value, size_t a_NumElements)
void BeginCompound(const AString &a_Name)
static void WriteToNBTCompound(const cFireworkItem &a_FireworkItem, cFastNBTWriter &a_Writer, const ENUM_ITEM_TYPE a_Type)
Writes firework NBT data to a Writer object.
Collects and stores the chunk data via the cChunkDataCallback interface.
void AddItemFrameEntity(cItemFrame *a_ItemFrame)
void AddEnderCrystalEntity(cEnderCrystal *a_EnderCrystal)
void AddCommandBlockEntity(cCommandBlockEntity *a_CmdBlock)
bool mIsTagOpen
True if a tag has been opened in the callbacks and not yet closed.
void AddPickupEntity(cPickup *a_Pickup)
void AddMinecartEntity(cMinecart *a_Minecart)
void AddBeaconEntity(cBeaconEntity *a_Entity)
void AddFallingBlockEntity(cFallingBlock *a_FallingBlock)
void AddBrewingstandEntity(cBrewingstandEntity *a_Brewingstand)
virtual void Entity(cEntity *a_Entity) override
void AddEnderchestEntity(cEnderChestEntity *a_Entity)
void AddNoteEntity(cNoteEntity *a_Note)
void AddChestEntity(cChestEntity *a_Entity, BLOCKTYPE a_ChestType)
void AddPaintingEntity(cPainting *a_Painting)
void AddMinecartChestContents(cMinecartWithChest *a_Minecart)
void AddLeashKnotEntity(cLeashKnot *a_LeashKnot)
void AddFlowerPotEntity(cFlowerPotEntity *a_FlowerPot)
void AddDispenserEntity(cDispenserEntity *a_Entity)
void AddJukeboxEntity(cJukeboxEntity *a_Jukebox)
void AddBedEntity(cBedEntity *a_Entity)
void AddTNTEntity(cTNTEntity *a_TNT)
bool mIsLightValid
True if the chunk lighting is valid.
void AddDropperEntity(cDropperEntity *a_Entity)
void AddItem(const cItem &a_Item, int a_Slot, const AString &a_CompoundName=AString())
Writes an item into the writer.
void AddBasicTileEntity(cBlockEntity *a_Entity, const char *a_EntityTypeID)
bool mHasHadBlockEntity
True if any BlockEntity has already been received and processed.
int Heights[cChunkDef::Width *cChunkDef::Width]
virtual void BiomeMap(const cChunkDef::BiomeMap &a_BiomeMap) override
void AddMobSpawnerEntity(cMobSpawnerEntity *a_MobSpawner)
void AddItemGrid(const cItemGrid &a_Grid, int a_BeginSlotNum=0)
Writes an item grid into the writer.
void AddBasicEntity(cEntity *a_Entity, const std::string_view a_ClassName)
void AddHangingEntity(cHangingEntity *a_Hanging)
void AddMonsterEntity(cMonster *a_Monster)
cFastNBTWriter & mWriter
The NBT writer used to store the data.
virtual void HeightMap(const cChunkDef::HeightMap &a_HeightMap) override
void AddMobHeadEntity(cMobHeadEntity *a_MobHead)
void AddFurnaceEntity(cFurnaceEntity *a_Furnace)
void AddProjectileEntity(cProjectileEntity *a_Projectile)
void AddBoatEntity(cBoat *a_Boat)
void AddSignEntity(cSignEntity *a_Sign)
UInt8 Biomes[cChunkDef::Width *cChunkDef::Width]
void AddExpOrbEntity(cExpOrb *a_ExpOrb)
void AddHopperEntity(cHopperEntity *a_Entity)
void AddBannerEntity(cBannerEntity *a_Entity)
void AddEnchantingTableEntity(cEnchantingTableEntity *a_Entity)
bool mHasHadEntity
True if any Entity has already been received and processed.
virtual void LightIsValid(bool a_IsLightValid) override
void AddEndPortalEntity(cEndPortalEntity *a_Entity)
virtual void BlockEntity(cBlockEntity *a_Entity) override
SerializerCollector(cFastNBTWriter &aWriter)
static void Serialize(const cWorld &aWorld, cChunkCoords aCoords, cFastNBTWriter &aWriter)
Serializes the chunk into the specified writer.