diff options
author | 12xx12 <44411062+12xx12@users.noreply.github.com> | 2020-11-23 00:41:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-23 00:41:13 +0100 |
commit | e35519ec8ab1b958408ab2a90b88dffc1bcc7fb2 (patch) | |
tree | 3ed498478eabe7aa01b54f85d8ec9c2bc821fe66 /src | |
parent | Add coloured glass pane recipes (#5032) (diff) | |
download | cuberite-e35519ec8ab1b958408ab2a90b88dffc1bcc7fb2.tar cuberite-e35519ec8ab1b958408ab2a90b88dffc1bcc7fb2.tar.gz cuberite-e35519ec8ab1b958408ab2a90b88dffc1bcc7fb2.tar.bz2 cuberite-e35519ec8ab1b958408ab2a90b88dffc1bcc7fb2.tar.lz cuberite-e35519ec8ab1b958408ab2a90b88dffc1bcc7fb2.tar.xz cuberite-e35519ec8ab1b958408ab2a90b88dffc1bcc7fb2.tar.zst cuberite-e35519ec8ab1b958408ab2a90b88dffc1bcc7fb2.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/Mobs/Monster.cpp | 102 | ||||
-rw-r--r-- | src/Mobs/MonsterTypes.h | 41 | ||||
-rw-r--r-- | src/Protocol/Protocol_1_10.cpp | 62 | ||||
-rw-r--r-- | src/Protocol/Protocol_1_10.h | 1 | ||||
-rw-r--r-- | src/Protocol/Protocol_1_11.cpp | 91 | ||||
-rw-r--r-- | src/Protocol/Protocol_1_12.cpp | 62 | ||||
-rw-r--r-- | src/Protocol/Protocol_1_12.h | 1 | ||||
-rw-r--r-- | src/Protocol/Protocol_1_13.cpp | 86 | ||||
-rw-r--r-- | src/Protocol/Protocol_1_8.cpp | 75 | ||||
-rw-r--r-- | src/Protocol/Protocol_1_9.cpp | 79 | ||||
-rw-r--r-- | src/Protocol/Protocol_1_9.h | 3 | ||||
-rw-r--r-- | src/WorldStorage/NBTChunkSerializer.cpp | 92 | ||||
-rw-r--r-- | src/WorldStorage/NamespaceSerializer.cpp | 740 | ||||
-rw-r--r-- | src/WorldStorage/NamespaceSerializer.h | 7 | ||||
-rw-r--r-- | src/WorldStorage/StatSerializer.cpp | 2 | ||||
-rw-r--r-- | src/WorldStorage/WSSAnvil.cpp | 518 | ||||
-rwxr-xr-x | src/WorldStorage/WSSAnvil.h | 38 |
17 files changed, 1553 insertions, 447 deletions
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 740223bfa..9a51f79d2 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -1064,39 +1064,75 @@ cMonster::eFamily cMonster::FamilyFromType(eMonsterType a_Type) switch (a_Type) { - case mtBat: return mfAmbient; - case mtBlaze: return mfHostile; - case mtCaveSpider: return mfHostile; - case mtChicken: return mfPassive; - case mtCow: return mfPassive; - case mtCreeper: return mfHostile; - case mtEnderDragon: return mfNoSpawn; - case mtEnderman: return mfHostile; - case mtGhast: return mfHostile; - case mtGiant: return mfNoSpawn; - case mtGuardian: return mfWater; // Just because they have special spawning conditions. If Watertemples have been added, this needs to be edited! - case mtHorse: return mfPassive; - case mtIronGolem: return mfPassive; - case mtMagmaCube: return mfHostile; - case mtMooshroom: return mfPassive; - case mtOcelot: return mfPassive; - case mtPig: return mfPassive; - case mtRabbit: return mfPassive; - case mtSheep: return mfPassive; - case mtSilverfish: return mfHostile; - case mtSkeleton: return mfHostile; - case mtSlime: return mfHostile; - case mtSnowGolem: return mfNoSpawn; - case mtSpider: return mfHostile; - case mtSquid: return mfWater; - case mtVillager: return mfPassive; - case mtWitch: return mfHostile; - case mtWither: return mfNoSpawn; - case mtWitherSkeleton: return mfHostile; - case mtWolf: return mfPassive; - case mtZombie: return mfHostile; - case mtZombiePigman: return mfHostile; - case mtZombieVillager: return mfHostile; + case mtBat: return mfAmbient; + case mtBlaze: return mfHostile; + case mtCat: return mfPassive; + case mtCaveSpider: return mfHostile; + case mtChicken: return mfPassive; + case mtCod: return mfWater; + case mtCow: return mfPassive; + case mtCreeper: return mfHostile; + case mtDolphin: return mfWater; + case mtDonkey: return mfPassive; + case mtDrowned: return mfHostile; + case mtElderGuardian: return mfHostile; + case mtEnderDragon: return mfNoSpawn; + case mtEnderman: return mfHostile; + case mtEndermite: return mfHostile; + case mtEvoker: return mfHostile; + case mtFox: return mfPassive; + case mtGhast: return mfHostile; + case mtGiant: return mfNoSpawn; + case mtGuardian: return mfWater; // Just because they have special spawning conditions. TODO: If Watertemples have been added, this needs to be edited! + case mtHoglin: return mfHostile; + case mtHorse: return mfPassive; + case mtHusk: return mfHostile; + case mtIllusioner: return mfHostile; + case mtIronGolem: return mfPassive; + case mtLlama: return mfPassive; + case mtMagmaCube: return mfHostile; + case mtMooshroom: return mfPassive; + case mtMule: return mfPassive; + case mtOcelot: return mfPassive; + case mtPanda: return mfPassive; + case mtParrot: return mfPassive; + case mtPhantom: return mfHostile; + case mtPig: return mfPassive; + case mtPiglin: return mfHostile; + case mtPiglinBrute: return mfHostile; + case mtPillager: return mfHostile; + case mtPolarBear: return mfPassive; + case mtPufferfish: return mfWater; + case mtRabbit: return mfPassive; + case mtRavager: return mfHostile; + case mtSalmon: return mfWater; + case mtSheep: return mfPassive; + case mtShulker: return mfHostile; + case mtSilverfish: return mfHostile; + case mtSkeleton: return mfHostile; + case mtSkeletonHorse: return mfPassive; + case mtSlime: return mfHostile; + case mtSnowGolem: return mfNoSpawn; + case mtSpider: return mfHostile; + case mtSquid: return mfWater; + case mtStray: return mfHostile; + case mtStrider: return mfHostile; + case mtTraderLlama: return mfPassive; + case mtTropicalFish: return mfWater; + case mtTurtle: return mfWater; // I'm not quite sure + case mtVex: return mfHostile; + case mtVindicator: return mfHostile; + case mtVillager: return mfPassive; + case mtWanderingTrader: return mfPassive; + case mtWitch: return mfHostile; + case mtWither: return mfNoSpawn; + case mtWitherSkeleton: return mfHostile; + case mtWolf: return mfPassive; + case mtZoglin: return mfHostile; + case mtZombie: return mfHostile; + case mtZombieHorse: return mfPassive; + case mtZombiePigman: return mfHostile; + case mtZombieVillager: return mfHostile; default: { diff --git a/src/Mobs/MonsterTypes.h b/src/Mobs/MonsterTypes.h index ea51f3539..5a591b31f 100644 --- a/src/Mobs/MonsterTypes.h +++ b/src/Mobs/MonsterTypes.h @@ -13,37 +13,76 @@ enum eMonsterType mtBat, mtBlaze, + mtCat, // Added in 1.14 mtCaveSpider, mtChicken, + mtCod, // Added in 1.13 mtCow, mtCreeper, + mtDolphin, // Added in 1.13 + mtDonkey, // Added in 1.6 + mtDrowned, // Added in 1.13 + mtElderGuardian, // Added in 1.13 mtEnderDragon, mtEnderman, + mtEndermite, // Added in 1.8 + mtEvoker, // Added in 1.11 + mtFox, // Added in 1.14 mtGhast, mtGiant, mtGuardian, mtHorse, + mtHoglin, // Added in 1.16 + mtHusk, // Added in 1.10 + mtIllusioner, // Added in 1.12 mtIronGolem, + mtLlama, // Added in 1.11 mtMagmaCube, mtMooshroom, + mtMule, // Added in 1.6 mtOcelot, + mtPanda, // Added in 1.14 + mtParrot, // Added in 1.12 + mtPhantom, // Added in 1.13 mtPig, + mtPiglin, // Added in 1.16 + mtPiglinBrute, // Added in 1.16 + mtPillager, // Added in 1.14 + mtPolarBear, // Added in 1.10 + mtPufferfish, // Added in 1.13 mtRabbit, + mtRavager, // Added in 1.14 + mtSalmon, // Added in 1.13 mtSheep, + mtShulker, // Added in 1.9 mtSilverfish, mtSkeleton, + mtSkeletonHorse, mtSlime, mtSnowGolem, mtSpider, mtSquid, + mtStray, // Added in 1.10 + mtStrider, // Added in 1.16 + mtTraderLlama, // Added in 1.11 + mtTropicalFish, // Added in 1.13 + mtTurtle, // Added in 1.13 + mtVex, // Added in 1.11 mtVillager, + mtVindicator, // Added in 1.11 + mtWanderingTrader, // Added in 1.14 mtWitch, mtWither, mtWitherSkeleton, mtWolf, + mtZoglin, // Added in 1.16 mtZombie, - mtZombiePigman, + mtZombieHorse, // Added in 1.6 + mtZombifiedPiglin, mtZombieVillager, + + // Synonyms: + mtZombiePigman = mtZombifiedPiglin, } ; // tolua_end diff --git a/src/Protocol/Protocol_1_10.cpp b/src/Protocol/Protocol_1_10.cpp index 6a39589e3..0efef360c 100644 --- a/src/Protocol/Protocol_1_10.cpp +++ b/src/Protocol/Protocol_1_10.cpp @@ -337,6 +337,19 @@ cProtocol::Version cProtocol_1_10_0::GetProtocolVersion() +UInt32 cProtocol_1_10_0::GetProtocolMobType(const eMonsterType a_MobType) +{ + switch (a_MobType) + { + case mtPolarBear: return 102; + default: return Super::GetProtocolMobType(a_MobType); + } +} + + + + + void cProtocol_1_10_0::HandlePacketResourcePackStatus(cByteBuffer & a_ByteBuffer) { HANDLE_READ(a_ByteBuffer, ReadBEUInt8, UInt8, Status); @@ -677,7 +690,7 @@ void cProtocol_1_10_0::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_ { using namespace Metadata; - // Living Enitiy Metadata + // Living entity metadata if (a_Mob.HasCustomName()) { // TODO: As of 1.9 _all_ entities can have custom names; should this be moved up? @@ -975,6 +988,7 @@ void cProtocol_1_10_0::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_ break; } // case mtWolf + case mtHusk: case mtZombie: { auto & Zombie = static_cast<const cZombie &>(a_Mob); @@ -1018,6 +1032,50 @@ void cProtocol_1_10_0::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_ break; } // case mtZombieVillager - default: break; + case mtBlaze: + case mtElderGuardian: + case mtGuardian: + { + // TODO: Mobs with extra fields that aren't implemented + break; + } + case mtCat: + + case mtEndermite: + + case mtPolarBear: + + case mtShulker: + + case mtDonkey: + case mtMule: + case mtSkeletonHorse: + case mtZombieHorse: + { + // Todo: Mobs not added yet. Grouped ones have the same metadata + UNREACHABLE("cProtocol_1_10::WriteMobMetadata: received unimplemented type"); + break; + } + + case mtCaveSpider: + case mtEnderDragon: + case mtGiant: + case mtIronGolem: + case mtMooshroom: + case mtSilverfish: + case mtSkeleton: + case mtSnowGolem: + case mtStray: + case mtSpider: + case mtSquid: + { + // Entities without additional metadata + break; + } + case mtInvalidType: + { + break; + } + default: UNREACHABLE("cProtocol_1_10::WriteMobMetadata: received mob of invalid type"); } // switch (a_Mob.GetType()) } diff --git a/src/Protocol/Protocol_1_10.h b/src/Protocol/Protocol_1_10.h index 46e7f7b04..3d78e7079 100644 --- a/src/Protocol/Protocol_1_10.h +++ b/src/Protocol/Protocol_1_10.h @@ -33,6 +33,7 @@ protected: virtual void SendSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch) override; virtual Version GetProtocolVersion() override; + virtual UInt32 GetProtocolMobType(eMonsterType a_MobType) override; virtual void HandlePacketResourcePackStatus(cByteBuffer & a_ByteBuffer) override; virtual void WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & a_Entity) override; virtual void WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob) override; diff --git a/src/Protocol/Protocol_1_11.cpp b/src/Protocol/Protocol_1_11.cpp index d475bd005..05bf35562 100644 --- a/src/Protocol/Protocol_1_11.cpp +++ b/src/Protocol/Protocol_1_11.cpp @@ -378,12 +378,20 @@ void cProtocol_1_11_0::SendSpawnMob(const cMonster & a_Mob) { ASSERT(m_State == 3); // In game mode? + const auto MobType = GetProtocolMobType(a_Mob.GetMobType()); + + // If the type is not valid in this protocol bail out: + if (MobType == 0) + { + return; + } + cPacketizer Pkt(*this, pktSpawnMob); Pkt.WriteVarInt32(a_Mob.GetUniqueID()); // TODO: Bad way to write a UUID, and it's not a true UUID, but this is functional for now. Pkt.WriteBEUInt64(0); Pkt.WriteBEUInt64(a_Mob.GetUniqueID()); - Pkt.WriteVarInt32(GetProtocolMobType(a_Mob.GetMobType())); + Pkt.WriteVarInt32(MobType); Vector3d LastSentPos = a_Mob.GetLastSentPosition(); Pkt.WriteBEDouble(LastSentPos.x); Pkt.WriteBEDouble(LastSentPos.y); @@ -543,7 +551,7 @@ cProtocol::Version cProtocol_1_11_0::GetProtocolVersion() -UInt32 cProtocol_1_11_0::GetProtocolMobType(eMonsterType a_MobType) +UInt32 cProtocol_1_11_0::GetProtocolMobType(const eMonsterType a_MobType) { switch (a_MobType) { @@ -555,26 +563,38 @@ UInt32 cProtocol_1_11_0::GetProtocolMobType(eMonsterType a_MobType) case mtChicken: return 93; case mtCow: return 92; case mtCreeper: return 50; + case mtDonkey: return 31; case mtEnderDragon: return 63; case mtEnderman: return 58; + case mtEndermite: return 67; + case mtEvoker: return 34; case mtGhast: return 56; case mtGiant: return 53; case mtGuardian: return 68; case mtHorse: return 100; + case mtHusk: return 23; case mtIronGolem: return 99; + case mtLlama: return 103; case mtMagmaCube: return 62; case mtMooshroom: return 96; + case mtMule: return 32; case mtOcelot: return 98; case mtPig: return 90; + case mtPolarBear: return 102; case mtRabbit: return 101; case mtSheep: return 91; + case mtShulker: return 69; case mtSilverfish: return 60; case mtSkeleton: return 51; case mtSlime: return 55; case mtSnowGolem: return 97; case mtSpider: return 52; + case mtStray: return 6; + case mtTraderLlama: return 103; case mtSquid: return 94; + case mtVex: return 35; case mtVillager: return 120; + case mtVindicator: return 36; case mtWitch: return 66; case mtWither: return 64; case mtWitherSkeleton: return 5; @@ -582,8 +602,9 @@ UInt32 cProtocol_1_11_0::GetProtocolMobType(eMonsterType a_MobType) case mtZombie: return 54; case mtZombiePigman: return 57; case mtZombieVillager: return 27; + + default: return 0; } - UNREACHABLE("Unsupported mob type"); } @@ -837,7 +858,7 @@ void cProtocol_1_11_0::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_ { using namespace Metadata_1_11; - // Living Enitiy Metadata + // Living entity Metadata if (a_Mob.HasCustomName()) { // TODO: As of 1.9 _all_ entities can have custom names; should this be moved up? @@ -929,7 +950,7 @@ void cProtocol_1_11_0::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_ case mtHorse: { - // XXX This behaves incorrectly with different varients; horses have different entity IDs now + // XXX This behaves incorrectly with different variants; horses have different entity IDs now // Abstract horse auto & Horse = static_cast<const cHorse &>(a_Mob); @@ -996,6 +1017,7 @@ void cProtocol_1_11_0::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_ case mtOcelot: { + // Todo: move unnecessary to cat auto & Ocelot = static_cast<const cOcelot &>(a_Mob); a_Pkt.WriteBEUInt8(AGEABLE_BABY); @@ -1153,7 +1175,7 @@ void cProtocol_1_11_0::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_ case mtZombie: { - // XXX Zombies were also split into new sublcasses; this doesn't handle that. + // XXX Zombies were also split into new subclasses; this doesn't handle that. auto & Zombie = static_cast<const cZombie &>(a_Mob); a_Pkt.WriteBEUInt8(ZOMBIE_IS_BABY); a_Pkt.WriteBEUInt8(METADATA_TYPE_BOOL); @@ -1187,7 +1209,62 @@ void cProtocol_1_11_0::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_ break; } // case mtZombieVillager - default: break; + case mtBlaze: + case mtElderGuardian: + case mtGuardian: + case mtSnowGolem: + { + // TODO: Mobs with extra fields that aren't implemented + break; + } + + case mtCat: + + case mtDonkey: + case mtMule: + + case mtEndermite: + + case mtEvoker: + + case mtLlama: + + case mtPolarBear: + + case mtShulker: + + case mtSkeletonHorse: + case mtZombieHorse: + + case mtVex: + + case mtVindicator: + { + // Todo: Mobs not added yet. Grouped ones have the same metadata + UNREACHABLE("cProtocol_1_11::WriteMobMetadata: received unimplemented type"); + break; + } + + case mtCaveSpider: + case mtEnderDragon: + case mtGiant: + case mtIronGolem: + case mtMooshroom: + case mtSilverfish: + case mtSkeleton: + case mtStray: + case mtSpider: + case mtSquid: + case mtWitherSkeleton: + { + // Mobs without additional metadata + break; + } + case mtInvalidType: + { + break; + } + default: UNREACHABLE("cProtocol_1_11::WriteMobMetadata: received mob of invalid type"); } // switch (a_Mob.GetType()) } diff --git a/src/Protocol/Protocol_1_12.cpp b/src/Protocol/Protocol_1_12.cpp index 4e0d2b063..93a1160ee 100644 --- a/src/Protocol/Protocol_1_12.cpp +++ b/src/Protocol/Protocol_1_12.cpp @@ -550,7 +550,7 @@ void cProtocol_1_12::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mo { using namespace Metadata_1_12; - // Living Enitiy Metadata + // Living entity metadata if (a_Mob.HasCustomName()) { // TODO: As of 1.9 _all_ entities can have custom names; should this be moved up? @@ -642,7 +642,7 @@ void cProtocol_1_12::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mo case mtHorse: { - // XXX This behaves incorrectly with different varients; horses have different entity IDs now + // XXX This behaves incorrectly with different variants; horses have different entity IDs now // Abstract horse auto & Horse = static_cast<const cHorse &>(a_Mob); @@ -866,7 +866,7 @@ void cProtocol_1_12::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mo case mtZombie: { - // XXX Zombies were also split into new sublcasses; this doesn't handle that. + // XXX Zombies were also split into new subclasses; this doesn't handle that. auto & Zombie = static_cast<const cZombie &>(a_Mob); a_Pkt.WriteBEUInt8(ZOMBIE_IS_BABY); a_Pkt.WriteBEUInt8(METADATA_TYPE_BOOL); @@ -907,28 +907,64 @@ void cProtocol_1_12::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mo } // case mtZombieVillager case mtBlaze: + case mtCaveSpider: + case mtElderGuardian: case mtEnderDragon: case mtGuardian: case mtIronGolem: case mtSnowGolem: case mtSpider: + case mtWitherSkeleton: { // TODO: Mobs with extra fields that aren't implemented break; } case mtMooshroom: - case mtCaveSpider: { // Not mentioned on http://wiki.vg/Entities break; } + case mtCat: + + case mtDonkey: + case mtMule: + + case mtEndermite: + + case mtEvoker: + + case mtHusk: + + case mtIllusioner: + + case mtLlama: + + case mtParrot: + + case mtPolarBear: + + case mtShulker: + + case mtSkeletonHorse: + case mtZombieHorse: + + case mtStray: + + case mtVex: + + case mtVindicator: + { + // Todo: Mobs not added yet. Grouped ones have the same metadata + UNREACHABLE("cProtocol_1_12::WriteMobMetadata: received unimplemented type"); + break; + } + case mtGiant: case mtSilverfish: case mtSkeleton: case mtSquid: - case mtWitherSkeleton: { // Mobs with no extra fields break; @@ -936,9 +972,9 @@ void cProtocol_1_12::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mo case mtInvalidType: { - ASSERT(!"cProtocol_1_12::WriteMobMetadata: Recieved mob of invalid type"); break; } + default: UNREACHABLE("cProtocol_1_12::WriteMobMetadata: received mob of invalid type"); } // switch (a_Mob.GetType()) } @@ -1035,6 +1071,20 @@ cProtocol::Version cProtocol_1_12::GetProtocolVersion() +UInt32 cProtocol_1_12::GetProtocolMobType(const eMonsterType a_MobType) +{ + switch (a_MobType) + { + case mtIllusioner: return 37; + case mtParrot: return 105; + default: return Super::GetProtocolMobType(a_MobType); + } +} + + + + + bool cProtocol_1_12::HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType) { switch (m_State) diff --git a/src/Protocol/Protocol_1_12.h b/src/Protocol/Protocol_1_12.h index 757ea9cc0..24e0eca60 100644 --- a/src/Protocol/Protocol_1_12.h +++ b/src/Protocol/Protocol_1_12.h @@ -36,6 +36,7 @@ protected: virtual UInt32 GetPacketID(ePacketType a_Packet) override; virtual Version GetProtocolVersion() override; + virtual UInt32 GetProtocolMobType(eMonsterType a_MobType) override; virtual bool HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType) override; virtual void HandlePacketAdvancementTab(cByteBuffer & a_ByteBuffer); virtual void HandleCraftRecipe(cByteBuffer & a_ByteBuffer); diff --git a/src/Protocol/Protocol_1_13.cpp b/src/Protocol/Protocol_1_13.cpp index a61c094f4..9497012e3 100644 --- a/src/Protocol/Protocol_1_13.cpp +++ b/src/Protocol/Protocol_1_13.cpp @@ -406,38 +406,65 @@ UInt32 cProtocol_1_13::GetProtocolMobType(eMonsterType a_MobType) // Map invalid type to Giant for easy debugging (if this ever spawns, something has gone very wrong) case mtInvalidType: return 27; case mtBat: return 3; + case mtCat: return 48; case mtBlaze: return 4; case mtCaveSpider: return 6; case mtChicken: return 7; + case mtCod: return 8; case mtCow: return 9; case mtCreeper: return 10; + case mtDonkey: return 11; + case mtDolphin: return 12; + case mtDrowned: return 14; + case mtElderGuardian: return 15; case mtEnderDragon: return 17; case mtEnderman: return 18; + case mtEndermite: return 19; + case mtEvoker: return 21; case mtGhast: return 26; case mtGiant: return 27; case mtGuardian: return 28; case mtHorse: return 29; + case mtHusk: return 30; + case mtIllusioner: return 31; case mtIronGolem: return 80; + case mtLlama: return 36; case mtMagmaCube: return 38; + case mtMule: return 46; case mtMooshroom: return 47; case mtOcelot: return 48; + case mtParrot: return 50; + case mtPhantom: return 90; case mtPig: return 51; + case mtPufferfish: return 52; + case mtPolarBear: return 54; case mtRabbit: return 56; + case mtSalmon: return 57; case mtSheep: return 58; + case mtShulker: return 59; case mtSilverfish: return 61; case mtSkeleton: return 62; + case mtSkeletonHorse: return 63; case mtSlime: return 64; case mtSnowGolem: return 66; case mtSpider: return 69; case mtSquid: return 70; + case mtStray: return 71; + case mtTropicalFish: return 72; + case mtTurtle: return 73; + case mtVex: return 78; case mtVillager: return 79; + case mtVindicator: return 81; case mtWitch: return 82; case mtWither: return 83; case mtWitherSkeleton: return 84; case mtWolf: return 86; case mtZombie: return 87; case mtZombiePigman: return 53; + case mtZombieHorse: return 88; case mtZombieVillager: return 89; + + default: return 0; } UNREACHABLE("Unsupported mob type"); } @@ -1222,7 +1249,6 @@ void cProtocol_1_13::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mo case mtBlaze: case mtEnderDragon: - case mtGuardian: case mtIronGolem: case mtSnowGolem: case mtSpider: @@ -1232,6 +1258,62 @@ void cProtocol_1_13::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mo break; } + case mtCat: + + case mtCod: + + case mtDolphin: + + case mtDonkey: + + case mtDrowned: + + case mtElderGuardian: + case mtGuardian: + + case mtEndermite: + + case mtEvoker: + + case mtIllusioner: + + case mtLlama: + + case mtMule: + + case mtParrot: + + case mtPhantom: + + case mtPolarBear: + + case mtPufferfish: + + case mtSalmon: + + case mtShulker: + + case mtStray: + + case mtSkeletonHorse: + case mtZombieHorse: + + case mtTropicalFish: + + case mtTurtle: + + case mtVex: + + case mtVindicator: + + case mtHusk: + + { + // Todo: Mobs not added yet. Grouped ones have the same metadata + UNREACHABLE("cProtocol_1_13::WriteMobMetadata: received unimplemented type"); + break; + } + case mtMooshroom: case mtCaveSpider: { @@ -1251,9 +1333,9 @@ void cProtocol_1_13::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mo case mtInvalidType: { - ASSERT(!"cProtocol_1_13::WriteMobMetadata: Recieved mob of invalid type"); break; } + default: UNREACHABLE("cProtocol_1_13::WriteMobMetadata: received mob of invalid type"); } // switch (a_Mob.GetType()) } diff --git a/src/Protocol/Protocol_1_8.cpp b/src/Protocol/Protocol_1_8.cpp index 5856a87d2..acfa676b5 100644 --- a/src/Protocol/Protocol_1_8.cpp +++ b/src/Protocol/Protocol_1_8.cpp @@ -1388,9 +1388,17 @@ void cProtocol_1_8_0::SendSpawnMob(const cMonster & a_Mob) { ASSERT(m_State == 3); // In game mode? + const auto MobType = GetProtocolMobType(a_Mob.GetMobType()); + + // If the type is not valid in this protocol bail out: + if (MobType == 0) + { + return; + } + cPacketizer Pkt(*this, pktSpawnMob); Pkt.WriteVarInt32(a_Mob.GetUniqueID()); - Pkt.WriteBEUInt8(static_cast<Byte>(GetProtocolMobType(a_Mob.GetMobType()))); + Pkt.WriteBEUInt8(static_cast<Byte>(MobType)); Vector3d LastSentPos = a_Mob.GetLastSentPosition(); Pkt.WriteFPInt(LastSentPos.x); Pkt.WriteFPInt(LastSentPos.y); @@ -1876,7 +1884,7 @@ int cProtocol_1_8_0::GetParticleID(const AString & a_ParticleName) -UInt32 cProtocol_1_8_0::GetProtocolMobType(eMonsterType a_MobType) +UInt32 cProtocol_1_8_0::GetProtocolMobType(const eMonsterType a_MobType) { switch (a_MobType) { @@ -1890,6 +1898,7 @@ UInt32 cProtocol_1_8_0::GetProtocolMobType(eMonsterType a_MobType) case mtCreeper: return 50; case mtEnderDragon: return 63; case mtEnderman: return 58; + case mtEndermite: return 67; case mtGhast: return 56; case mtGiant: return 53; case mtGuardian: return 68; @@ -1915,8 +1924,18 @@ UInt32 cProtocol_1_8_0::GetProtocolMobType(eMonsterType a_MobType) case mtZombie: return 54; case mtZombiePigman: return 57; case mtZombieVillager: return 27; + + // Mobs that get replaced with another because they were added later + case mtCat: return GetProtocolMobType(mtOcelot); + case mtDonkey: return GetProtocolMobType(mtHorse); + case mtMule: return GetProtocolMobType(mtHorse); + case mtSkeletonHorse: return GetProtocolMobType(mtHorse); + case mtZombieHorse: return GetProtocolMobType(mtHorse); + case mtStray: return GetProtocolMobType(mtSkeleton); + case mtHusk: return GetProtocolMobType(mtZombie); + + default: return 0; } - UNREACHABLE("Unsupported mob type"); } @@ -3792,6 +3811,14 @@ void cProtocol_1_8_0::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_M break; } // case mtSlime + case mtSkeleton: + case mtStray: + { + a_Pkt.WriteBEUInt8(0x0d); + a_Pkt.WriteBEUInt8(0); // Is normal skeleton + break; + } + case mtVillager: { auto & Villager = static_cast<const cVillager &>(a_Mob); @@ -3857,6 +3884,7 @@ void cProtocol_1_8_0::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_M break; } // case mtWolf + case mtHusk: case mtZombie: { auto & Zombie = static_cast<const cZombie &>(a_Mob); @@ -3889,7 +3917,46 @@ void cProtocol_1_8_0::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_M break; } // case mtZombieVillager - default: break; + case mtBlaze: + case mtElderGuardian: + case mtGuardian: + { + // TODO: Mobs with extra fields that aren't implemented + break; + } + + case mtCat: + + case mtEndermite: + + case mtDonkey: + case mtMule: + case mtSkeletonHorse: + case mtZombieHorse: + { + // Todo: Mobs not added yet. Grouped ones have the same metadata + UNREACHABLE("cProtocol_1_8::WriteMobMetadata: received unimplemented type"); + break; + } + + case mtCaveSpider: + case mtEnderDragon: + case mtGiant: + case mtIronGolem: + case mtMooshroom: + case mtSilverfish: + case mtSnowGolem: + case mtSpider: + case mtSquid: + { + // Allowed mobs without additional metadata + break; + } + case mtInvalidType: + { + break; + } + default: UNREACHABLE("cProtocol_1_8::WriteMobMetadata: received mob of invalid type"); } // switch (a_Mob.GetType()) } diff --git a/src/Protocol/Protocol_1_9.cpp b/src/Protocol/Protocol_1_9.cpp index eff9c8530..72d3fd4b1 100644 --- a/src/Protocol/Protocol_1_9.cpp +++ b/src/Protocol/Protocol_1_9.cpp @@ -418,12 +418,20 @@ void cProtocol_1_9_0::SendSpawnMob(const cMonster & a_Mob) { ASSERT(m_State == 3); // In game mode? + const auto MobType = GetProtocolMobType(a_Mob.GetMobType()); + + // If the type is not valid in this protocol bail out: + if (MobType == 0) + { + return; + } + cPacketizer Pkt(*this, pktSpawnMob); Pkt.WriteVarInt32(a_Mob.GetUniqueID()); // TODO: Bad way to write a UUID, and it's not a true UUID, but this is functional for now. Pkt.WriteBEUInt64(0); Pkt.WriteBEUInt64(a_Mob.GetUniqueID()); - Pkt.WriteBEUInt8(static_cast<Byte>(GetProtocolMobType(a_Mob.GetMobType()))); + Pkt.WriteBEUInt8(static_cast<Byte>(MobType)); Vector3d LastSentPos = a_Mob.GetLastSentPosition(); Pkt.WriteBEDouble(LastSentPos.x); Pkt.WriteBEDouble(LastSentPos.y); @@ -572,6 +580,19 @@ cProtocol::Version cProtocol_1_9_0::GetProtocolVersion() +UInt32 cProtocol_1_9_0::GetProtocolMobType(const eMonsterType a_MobType) +{ + switch (a_MobType) + { + case mtShulker: return 69; + default: return Super::GetProtocolMobType(a_MobType); + } +} + + + + + bool cProtocol_1_9_0::HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType) { switch (m_State) @@ -1756,7 +1777,7 @@ void cProtocol_1_9_0::WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & a void cProtocol_1_9_0::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob) { - // Living Enitiy Metadata + // Living entity metadata if (a_Mob.HasCustomName()) { // TODO: As of 1.9 _all_ entities can have custom names; should this be moved up? @@ -1966,6 +1987,13 @@ void cProtocol_1_9_0::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_M break; } // case mtSheep + case mtSkeleton: + { + a_Pkt.WriteBEUInt8(11); + a_Pkt.WriteBEUInt8(METADATA_TYPE_VARINT); + a_Pkt.WriteVarInt32(0); + } + case mtSlime: { auto & Slime = static_cast<const cSlime &>(a_Mob); @@ -2097,7 +2125,52 @@ void cProtocol_1_9_0::WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_M break; } // case mtZombieVillager - default: break; + case mtBlaze: + case mtElderGuardian: + case mtGuardian: + { + // TODO: Mobs with extra fields that aren't implemented + break; + } + + case mtCat: + + case mtDonkey: + + case mtEndermite: + + case mtMule: + + case mtStray: + + case mtSkeletonHorse: + case mtZombieHorse: + + case mtShulker: + { + // Todo: Mobs not added yet. Grouped ones have the same metadata + UNREACHABLE("cProtocol_1_9::WriteMobMetadata: received unimplemented type"); + break; + } + + case mtCaveSpider: + case mtEnderDragon: + case mtGiant: + case mtIronGolem: + case mtMooshroom: + case mtSilverfish: + case mtSnowGolem: + case mtSpider: + case mtSquid: + { + // Entities without additional metadata + break; + } + case mtInvalidType: + { + + } + default: UNREACHABLE("cProtocol_1_9::WriteMobMetadata: received mob of invalid type"); } // switch (a_Mob.GetType()) } diff --git a/src/Protocol/Protocol_1_9.h b/src/Protocol/Protocol_1_9.h index a180c8f5e..0339ddeb3 100644 --- a/src/Protocol/Protocol_1_9.h +++ b/src/Protocol/Protocol_1_9.h @@ -72,6 +72,9 @@ protected: /** Returns 1.9. */ virtual Version GetProtocolVersion() override; + /** Converts eMonsterType to protocol-specific mob types */ + virtual UInt32 GetProtocolMobType(eMonsterType a_MobType) override; + /** Reads and handles the packet. The packet length and type have already been read. Returns true if the packet was understood, false if it was an unknown packet. */ virtual bool HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType) override; diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index d159f6e49..0e3cdde76 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -5,6 +5,7 @@ #include "Globals.h" #include "NBTChunkSerializer.h" #include "EnchantmentSerializer.h" +#include "NamespaceSerializer.h" #include "../ChunkDataCallback.h" #include "../ItemGrid.h" #include "../StringCompression.h" @@ -546,7 +547,7 @@ public: { mWriter.BeginCompound(""); AddBasicTileEntity(a_MobSpawner, "MobSpawner"); - mWriter.AddString("EntityId", cMonster::MobTypeToVanillaName(a_MobSpawner->GetEntity())); + mWriter.AddString("EntityId", NamespaceSerializer::From(a_MobSpawner->GetEntity())); mWriter.AddShort("SpawnCount", a_MobSpawner->GetSpawnCount()); mWriter.AddShort("SpawnRange", a_MobSpawner->GetSpawnRange()); mWriter.AddShort("Delay", a_MobSpawner->GetSpawnDelay()); @@ -643,7 +644,7 @@ public: - void AddBasicEntity(cEntity * a_Entity, const AString & a_ClassName) + void AddBasicEntity(cEntity * a_Entity, const std::string_view a_ClassName) { mWriter.AddString("id", a_ClassName); mWriter.BeginList("Pos", TAG_Double); @@ -762,51 +763,8 @@ public: void AddMonsterEntity(cMonster * a_Monster) { - const char * EntityClass = nullptr; - switch (a_Monster->GetMobType()) - { - case mtBat: EntityClass = "Bat"; break; - case mtBlaze: EntityClass = "Blaze"; break; - case mtCaveSpider: EntityClass = "CaveSpider"; break; - case mtChicken: EntityClass = "Chicken"; break; - case mtCow: EntityClass = "Cow"; break; - case mtCreeper: EntityClass = "Creeper"; break; - case mtEnderDragon: EntityClass = "EnderDragon"; break; - case mtEnderman: EntityClass = "Enderman"; break; - case mtGhast: EntityClass = "Ghast"; break; - case mtGiant: EntityClass = "Giant"; break; - case mtGuardian: EntityClass = "Guardian"; break; - case mtHorse: EntityClass = "Horse"; break; - case mtIronGolem: EntityClass = "VillagerGolem"; break; - case mtMagmaCube: EntityClass = "LavaSlime"; break; - case mtMooshroom: EntityClass = "MushroomCow"; break; - case mtOcelot: EntityClass = "Ozelot"; break; - case mtPig: EntityClass = "Pig"; break; - case mtRabbit: EntityClass = "Rabbit"; break; - case mtSheep: EntityClass = "Sheep"; break; - case mtSilverfish: EntityClass = "Silverfish"; break; - case mtSkeleton: EntityClass = "Skeleton"; break; - case mtSlime: EntityClass = "Slime"; break; - case mtSnowGolem: EntityClass = "SnowMan"; break; - case mtSpider: EntityClass = "Spider"; break; - case mtSquid: EntityClass = "Squid"; break; - case mtVillager: EntityClass = "Villager"; break; - case mtWitch: EntityClass = "Witch"; break; - case mtWither: EntityClass = "WitherBoss"; break; - case mtWitherSkeleton: EntityClass = "WitherSkeleton"; break; - case mtWolf: EntityClass = "Wolf"; break; - case mtZombie: EntityClass = "Zombie"; break; - case mtZombiePigman: EntityClass = "PigZombie"; break; - case mtZombieVillager: EntityClass = "ZombieVillager"; break; - default: - { - ASSERT(!"Unhandled monster type"); - return; - } - } // switch (payload) - mWriter.BeginCompound(""); - AddBasicEntity(a_Monster, EntityClass); + AddBasicEntity(a_Monster, NamespaceSerializer::From(a_Monster->GetMobType())); mWriter.BeginList("DropChances", TAG_Float); mWriter.AddFloat("", a_Monster->GetDropChanceWeapon()); mWriter.AddFloat("", a_Monster->GetDropChanceHelmet()); @@ -971,6 +929,7 @@ public: mWriter.AddInt("Profession", ZombieVillager->GetProfession()); mWriter.AddInt("ConversionTime", ZombieVillager->ConversionTime()); mWriter.AddInt("Age", ZombieVillager->GetAge()); + break; } case mtBlaze: case mtCaveSpider: @@ -993,6 +952,47 @@ public: // Other mobs have no special tags. break; } + case mtCat: + case mtCod: + case mtDolphin: + case mtDonkey: + case mtDrowned: + case mtElderGuardian: + case mtEndermite: + case mtEvoker: + case mtFox: + case mtHoglin: + case mtHusk: + case mtIllusioner: + case mtLlama: + case mtMule: + case mtPanda: + case mtParrot: + case mtPhantom: + case mtPiglin: + case mtPiglinBrute: + case mtPillager: + case mtPolarBear: + case mtPufferfish: + case mtRavager: + case mtSalmon: + case mtShulker: + case mtSkeletonHorse: + case mtStray: + case mtStrider: + case mtTraderLlama: + case mtTropicalFish: + case mtTurtle: + case mtVex: + case mtVindicator: + case mtWanderingTrader: + case mtZoglin: + case mtZombieHorse: + { + // All the entities not added + LOGD("Saving unimplemented entity type: %d", NamespaceSerializer::From(a_Monster->GetMobType())); + break; + } case mtInvalidType: { ASSERT(!"NBTChunkSerializer::SerializerCollector::AddMonsterEntity: Recieved mob of invalid type"); diff --git a/src/WorldStorage/NamespaceSerializer.cpp b/src/WorldStorage/NamespaceSerializer.cpp index 41023caea..4d3d1a544 100644 --- a/src/WorldStorage/NamespaceSerializer.cpp +++ b/src/WorldStorage/NamespaceSerializer.cpp @@ -2,284 +2,496 @@ #include "NamespaceSerializer.h" -namespace NamespaceSerializer + + + + +unsigned NamespaceSerializer::DataVersion() { - unsigned DataVersion() + return 2566; +} + + + + + +std::string_view NamespaceSerializer::From(const Statistic a_ID) +{ + switch (a_ID) { - return 2566; + case Statistic::AnimalsBred: return "animals_bred"; + case Statistic::AviateOneCm: return "aviate_one_cm"; + case Statistic::BellRing: return "bell_ring"; + case Statistic::BoatOneCm: return "boat_one_cm"; + case Statistic::CleanArmor: return "clean_armor"; + case Statistic::CleanBanner: return "clean_banner"; + case Statistic::CleanShulkerBox: return "clean_shulker_box"; + case Statistic::ClimbOneCm: return "climb_one_cm"; + case Statistic::CrouchOneCm: return "crouch_one_cm"; + case Statistic::DamageAbsorbed: return "damage_absorbed"; + case Statistic::DamageBlockedByShield: return "damage_blocked_by_shield"; + case Statistic::DamageDealt: return "damage_dealt"; + case Statistic::DamageDealtAbsorbed: return "damage_dealt_absorbed"; + case Statistic::DamageDealtResisted: return "damage_dealt_resisted"; + case Statistic::DamageResisted: return "damage_resisted"; + case Statistic::DamageTaken: return "damage_taken"; + case Statistic::Deaths: return "deaths"; + case Statistic::Drop: return "drop"; + case Statistic::EatCakeSlice: return "eat_cake_slice"; + case Statistic::EnchantItem: return "enchant_item"; + case Statistic::FallOneCm: return "fall_one_cm"; + case Statistic::FillCauldron: return "fill_cauldron"; + case Statistic::FishCaught: return "fish_caught"; + case Statistic::FlyOneCm: return "fly_one_cm"; + case Statistic::HorseOneCm: return "horse_one_cm"; + case Statistic::InspectDispenser: return "inspect_dispenser"; + case Statistic::InspectDropper: return "inspect_dropper"; + case Statistic::InspectHopper: return "inspect_hopper"; + case Statistic::InteractWithAnvil: return "interact_with_anvil"; + case Statistic::InteractWithBeacon: return "interact_with_beacon"; + case Statistic::InteractWithBlastFurnace: return "interact_with_blast_furnace"; + case Statistic::InteractWithBrewingstand: return "interact_with_brewingstand"; + case Statistic::InteractWithCampfire: return "interact_with_campfire"; + case Statistic::InteractWithCartographyTable: return "interact_with_cartography_table"; + case Statistic::InteractWithCraftingTable: return "interact_with_crafting_table"; + case Statistic::InteractWithFurnace: return "interact_with_furnace"; + case Statistic::InteractWithGrindstone: return "interact_with_grindstone"; + case Statistic::InteractWithLectern: return "interact_with_lectern"; + case Statistic::InteractWithLoom: return "interact_with_loom"; + case Statistic::InteractWithSmithingTable: return "interact_with_smithing_table"; + case Statistic::InteractWithSmoker: return "interact_with_smoker"; + case Statistic::InteractWithStonecutter: return "interact_with_stonecutter"; + case Statistic::Jump: return "jump"; + case Statistic::LeaveGame: return "leave_game"; + case Statistic::MinecartOneCm: return "minecart_one_cm"; + case Statistic::MobKills: return "mob_kills"; + case Statistic::OpenBarrel: return "open_barrel"; + case Statistic::OpenChest: return "open_chest"; + case Statistic::OpenEnderchest: return "open_enderchest"; + case Statistic::OpenShulkerBox: return "open_shulker_box"; + case Statistic::PigOneCm: return "pig_one_cm"; + case Statistic::PlayNoteblock: return "play_noteblock"; + case Statistic::PlayOneMinute: return "play_one_minute"; + case Statistic::PlayRecord: return "play_record"; + case Statistic::PlayerKills: return "player_kills"; + case Statistic::PotFlower: return "pot_flower"; + case Statistic::RaidTrigger: return "raid_trigger"; + case Statistic::RaidWin: return "raid_win"; + case Statistic::SleepInBed: return "sleep_in_bed"; + case Statistic::SneakTime: return "sneak_time"; + case Statistic::SprintOneCm: return "sprint_one_cm"; + case Statistic::StriderOneCm: return "strider_one_cm"; + case Statistic::SwimOneCm: return "swim_one_cm"; + case Statistic::TalkedToVillager: return "talked_to_villager"; + case Statistic::TargetHit: return "target_hit"; + case Statistic::TimeSinceDeath: return "time_since_death"; + case Statistic::TimeSinceRest: return "time_since_rest"; + case Statistic::TradedWithVillager: return "traded_with_villager"; + case Statistic::TriggerTrappedChest: return "trigger_trapped_chest"; + case Statistic::TuneNoteblock: return "tune_noteblock"; + case Statistic::UseCauldron: return "use_cauldron"; + case Statistic::WalkOnWaterOneCm: return "walk_on_water_one_cm"; + case Statistic::WalkOneCm: return "walk_one_cm"; + case Statistic::WalkUnderWaterOneCm: return "walk_under_water_one_cm"; + + // Old ones just for compatibility + case Statistic::JunkFished: return "junk_fished"; + case Statistic::TreasureFished: return "treasure_fished"; + + // The old advancements + case Statistic::AchOpenInventory: return "cuberite:achievement.openInventory"; + case Statistic::AchMineWood: return "cuberite:achievement.mineWood"; + case Statistic::AchBuildWorkBench: return "cuberite:achievement.buildWorkBench"; + case Statistic::AchBuildPickaxe: return "cuberite:achievement.buildPickaxe"; + case Statistic::AchBuildFurnace: return "cuberite:achievement.buildFurnace"; + case Statistic::AchAcquireIron: return "cuberite:achievement.acquireIron"; + case Statistic::AchBuildHoe: return "cuberite:achievement.buildHoe"; + case Statistic::AchMakeBread: return "cuberite:achievement.makeBread"; + case Statistic::AchBakeCake: return "cuberite:achievement.bakeCake"; + case Statistic::AchBuildBetterPickaxe: return "cuberite:achievement.buildBetterPickaxe"; + case Statistic::AchCookFish: return "cuberite:achievement.cookFish"; + case Statistic::AchOnARail: return "cuberite:achievement.onARail"; + case Statistic::AchBuildSword: return "cuberite:achievement.buildSword"; + case Statistic::AchKillEnemy: return "cuberite:achievement.killEnemy"; + case Statistic::AchKillCow: return "cuberite:achievement.killCow"; + case Statistic::AchFlyPig: return "cuberite:achievement.flyPig"; + case Statistic::AchSnipeSkeleton: return "cuberite:achievement.snipeSkeleton"; + case Statistic::AchDiamonds: return "cuberite:achievement.diamonds"; + case Statistic::AchPortal: return "cuberite:achievement.portal"; + case Statistic::AchGhast: return "cuberite:achievement.ghast"; + case Statistic::AchBlazeRod: return "cuberite:achievement.blazeRod"; + case Statistic::AchPotion: return "cuberite:achievement.potion"; + case Statistic::AchTheEnd: return "cuberite:achievement.theEnd"; + case Statistic::AchTheEnd2: return "cuberite:achievement.theEnd2"; + case Statistic::AchEnchantments: return "cuberite:achievement.enchantments"; + case Statistic::AchOverkill: return "cuberite:achievement.overkill"; + case Statistic::AchBookcase: return "cuberite:achievement.bookcase"; + case Statistic::AchExploreAllBiomes: return "cuberite:achievement.exploreAllBiomes"; + case Statistic::AchSpawnWither: return "cuberite:achievement.spawnWither"; + case Statistic::AchKillWither: return "cuberite:achievement.killWither"; + case Statistic::AchFullBeacon: return "cuberite:achievement.fullBeacon"; + case Statistic::AchBreedCow: return "cuberite:achievement.breedCow"; + case Statistic::AchDiamondsToYou: return "cuberite:achievement.diamondsToYou"; } - const char * From(const Statistic ID) + UNREACHABLE("Tried to save unhandled statistic"); +} + + + + + +std::string_view NamespaceSerializer::From(eMonsterType a_ID) +{ + switch (a_ID) { - switch (ID) - { - case Statistic::AnimalsBred: return "animals_bred"; - case Statistic::AviateOneCm: return "aviate_one_cm"; - case Statistic::BellRing: return "bell_ring"; - case Statistic::BoatOneCm: return "boat_one_cm"; - case Statistic::CleanArmor: return "clean_armor"; - case Statistic::CleanBanner: return "clean_banner"; - case Statistic::CleanShulkerBox: return "clean_shulker_box"; - case Statistic::ClimbOneCm: return "climb_one_cm"; - case Statistic::CrouchOneCm: return "crouch_one_cm"; - case Statistic::DamageAbsorbed: return "damage_absorbed"; - case Statistic::DamageBlockedByShield: return "damage_blocked_by_shield"; - case Statistic::DamageDealt: return "damage_dealt"; - case Statistic::DamageDealtAbsorbed: return "damage_dealt_absorbed"; - case Statistic::DamageDealtResisted: return "damage_dealt_resisted"; - case Statistic::DamageResisted: return "damage_resisted"; - case Statistic::DamageTaken: return "damage_taken"; - case Statistic::Deaths: return "deaths"; - case Statistic::Drop: return "drop"; - case Statistic::EatCakeSlice: return "eat_cake_slice"; - case Statistic::EnchantItem: return "enchant_item"; - case Statistic::FallOneCm: return "fall_one_cm"; - case Statistic::FillCauldron: return "fill_cauldron"; - case Statistic::FishCaught: return "fish_caught"; - case Statistic::FlyOneCm: return "fly_one_cm"; - case Statistic::HorseOneCm: return "horse_one_cm"; - case Statistic::InspectDispenser: return "inspect_dispenser"; - case Statistic::InspectDropper: return "inspect_dropper"; - case Statistic::InspectHopper: return "inspect_hopper"; - case Statistic::InteractWithAnvil: return "interact_with_anvil"; - case Statistic::InteractWithBeacon: return "interact_with_beacon"; - case Statistic::InteractWithBlastFurnace: return "interact_with_blast_furnace"; - case Statistic::InteractWithBrewingstand: return "interact_with_brewingstand"; - case Statistic::InteractWithCampfire: return "interact_with_campfire"; - case Statistic::InteractWithCartographyTable: return "interact_with_cartography_table"; - case Statistic::InteractWithCraftingTable: return "interact_with_crafting_table"; - case Statistic::InteractWithFurnace: return "interact_with_furnace"; - case Statistic::InteractWithGrindstone: return "interact_with_grindstone"; - case Statistic::InteractWithLectern: return "interact_with_lectern"; - case Statistic::InteractWithLoom: return "interact_with_loom"; - case Statistic::InteractWithSmithingTable: return "interact_with_smithing_table"; - case Statistic::InteractWithSmoker: return "interact_with_smoker"; - case Statistic::InteractWithStonecutter: return "interact_with_stonecutter"; - case Statistic::Jump: return "jump"; - case Statistic::LeaveGame: return "leave_game"; - case Statistic::MinecartOneCm: return "minecart_one_cm"; - case Statistic::MobKills: return "mob_kills"; - case Statistic::OpenBarrel: return "open_barrel"; - case Statistic::OpenChest: return "open_chest"; - case Statistic::OpenEnderchest: return "open_enderchest"; - case Statistic::OpenShulkerBox: return "open_shulker_box"; - case Statistic::PigOneCm: return "pig_one_cm"; - case Statistic::PlayNoteblock: return "play_noteblock"; - case Statistic::PlayOneMinute: return "play_one_minute"; - case Statistic::PlayRecord: return "play_record"; - case Statistic::PlayerKills: return "player_kills"; - case Statistic::PotFlower: return "pot_flower"; - case Statistic::RaidTrigger: return "raid_trigger"; - case Statistic::RaidWin: return "raid_win"; - case Statistic::SleepInBed: return "sleep_in_bed"; - case Statistic::SneakTime: return "sneak_time"; - case Statistic::SprintOneCm: return "sprint_one_cm"; - case Statistic::StriderOneCm: return "strider_one_cm"; - case Statistic::SwimOneCm: return "swim_one_cm"; - case Statistic::TalkedToVillager: return "talked_to_villager"; - case Statistic::TargetHit: return "target_hit"; - case Statistic::TimeSinceDeath: return "time_since_death"; - case Statistic::TimeSinceRest: return "time_since_rest"; - case Statistic::TradedWithVillager: return "traded_with_villager"; - case Statistic::TriggerTrappedChest: return "trigger_trapped_chest"; - case Statistic::TuneNoteblock: return "tune_noteblock"; - case Statistic::UseCauldron: return "use_cauldron"; - case Statistic::WalkOnWaterOneCm: return "walk_on_water_one_cm"; - case Statistic::WalkOneCm: return "walk_one_cm"; - case Statistic::WalkUnderWaterOneCm: return "walk_under_water_one_cm"; - - // Old ones just for compatibility - case Statistic::JunkFished: return "junk_fished"; - case Statistic::TreasureFished: return "treasure_fished"; - - // The old advancements - case Statistic::AchOpenInventory: return "cuberite:achievement.openInventory"; - case Statistic::AchMineWood: return "cuberite:achievement.mineWood"; - case Statistic::AchBuildWorkBench: return "cuberite:achievement.buildWorkBench"; - case Statistic::AchBuildPickaxe: return "cuberite:achievement.buildPickaxe"; - case Statistic::AchBuildFurnace: return "cuberite:achievement.buildFurnace"; - case Statistic::AchAcquireIron: return "cuberite:achievement.acquireIron"; - case Statistic::AchBuildHoe: return "cuberite:achievement.buildHoe"; - case Statistic::AchMakeBread: return "cuberite:achievement.makeBread"; - case Statistic::AchBakeCake: return "cuberite:achievement.bakeCake"; - case Statistic::AchBuildBetterPickaxe: return "cuberite:achievement.buildBetterPickaxe"; - case Statistic::AchCookFish: return "cuberite:achievement.cookFish"; - case Statistic::AchOnARail: return "cuberite:achievement.onARail"; - case Statistic::AchBuildSword: return "cuberite:achievement.buildSword"; - case Statistic::AchKillEnemy: return "cuberite:achievement.killEnemy"; - case Statistic::AchKillCow: return "cuberite:achievement.killCow"; - case Statistic::AchFlyPig: return "cuberite:achievement.flyPig"; - case Statistic::AchSnipeSkeleton: return "cuberite:achievement.snipeSkeleton"; - case Statistic::AchDiamonds: return "cuberite:achievement.diamonds"; - case Statistic::AchPortal: return "cuberite:achievement.portal"; - case Statistic::AchGhast: return "cuberite:achievement.ghast"; - case Statistic::AchBlazeRod: return "cuberite:achievement.blazeRod"; - case Statistic::AchPotion: return "cuberite:achievement.potion"; - case Statistic::AchTheEnd: return "cuberite:achievement.theEnd"; - case Statistic::AchTheEnd2: return "cuberite:achievement.theEnd2"; - case Statistic::AchEnchantments: return "cuberite:achievement.enchantments"; - case Statistic::AchOverkill: return "cuberite:achievement.overkill"; - case Statistic::AchBookcase: return "cuberite:achievement.bookcase"; - case Statistic::AchExploreAllBiomes: return "cuberite:achievement.exploreAllBiomes"; - case Statistic::AchSpawnWither: return "cuberite:achievement.spawnWither"; - case Statistic::AchKillWither: return "cuberite:achievement.killWither"; - case Statistic::AchFullBeacon: return "cuberite:achievement.fullBeacon"; - case Statistic::AchBreedCow: return "cuberite:achievement.breedCow"; - case Statistic::AchDiamondsToYou: return "cuberite:achievement.diamondsToYou"; - } - - UNREACHABLE("Tried to save unhandled statistic"); + case mtBat: return "bat"; + case mtBlaze: return "blaze"; + case mtCat: return "cat"; + case mtCaveSpider: return "cave_spider"; + case mtChicken: return "chicken"; + case mtCod: return "cod"; + case mtCow: return "cow"; + case mtCreeper: return "creeper"; + case mtDolphin: return "dolphin"; + case mtDonkey: return "donkey"; + case mtDrowned: return "drowned"; + case mtElderGuardian: return "elder_guardian"; + case mtEnderDragon: return "ender_dragon"; + case mtEnderman: return "enderman"; + case mtEndermite: return "endermite"; + case mtEvoker: return "evoker"; + case mtFox: return "fox"; + case mtGhast: return "ghast"; + case mtGiant: return "giant"; + case mtGuardian: return "guardian"; + case mtHorse: return "horse"; + case mtHoglin: return "hoglin"; + case mtHusk: return "husk"; + case mtIllusioner: return "illusioner"; + case mtIronGolem: return "iron_golem"; + case mtLlama: return "llama"; + case mtMagmaCube: return "magma_cube"; + case mtMooshroom: return "mooshroom"; + case mtMule: return "mule"; + case mtOcelot: return "ocelot"; + case mtPanda: return "panda"; + case mtParrot: return "parrot"; + case mtPhantom: return "phantom"; + case mtPig: return "pig"; + case mtPiglin: return "piglin"; + case mtPiglinBrute: return "piglin_brute"; + case mtPillager: return "pillager"; + case mtPolarBear: return "polar_bear"; + case mtPufferfish: return "pufferfish"; + case mtRabbit: return "rabbit"; + case mtRavager: return "ravager"; + case mtSalmon: return "salmon"; + case mtSheep: return "sheep"; + case mtShulker: return "shulker"; + case mtSilverfish: return "silverfish"; + case mtSkeleton: return "skeleton"; + case mtSkeletonHorse: return "skeleton_horse"; + case mtSlime: return "slime"; + case mtSnowGolem: return "snow_golem"; + case mtSpider: return "spider"; + case mtSquid: return "squid"; + case mtStray: return "stray"; + case mtStrider: return "strider"; + case mtTraderLlama: return "trader_llama"; + case mtTropicalFish: return "tropical_fish"; + case mtTurtle: return "turtle"; + case mtVex: return "vex"; + case mtVillager: return "villager"; + case mtVindicator: return "vindicator"; + case mtWanderingTrader:return "wandering_trader"; + case mtWitch: return "witch"; + case mtWither: return "wither"; + case mtWitherSkeleton: return "wither_skeleton"; + case mtWolf: return "wolf"; + case mtZoglin: return "zoglin"; + case mtZombie: return "zombie"; + case mtZombieHorse: return "zombie_horse"; + case mtZombiePigman: return "zombified_piglin"; + case mtZombieVillager: return "zombie_villager"; + case mtInvalidType: break; } + UNREACHABLE("Tried to save unknown monster type"); +} + + + + + +Statistic NamespaceSerializer::ToCustomStatistic(const std::string_view ID) +{ + static const std::unordered_map<std::string_view, Statistic> CustomStatistics + { + { "animals_bred", Statistic::AnimalsBred }, + { "aviate_one_cm", Statistic::AviateOneCm }, + { "bell_ring", Statistic::BellRing }, + { "boat_one_cm", Statistic::BoatOneCm }, + { "clean_armor", Statistic::CleanArmor }, + { "clean_banner", Statistic::CleanBanner }, + { "clean_shulker_box", Statistic::CleanShulkerBox }, + { "climb_one_cm", Statistic::ClimbOneCm }, + { "crouch_one_cm", Statistic::CrouchOneCm }, + { "damage_absorbed", Statistic::DamageAbsorbed }, + { "damage_blocked_by_shield", Statistic::DamageBlockedByShield }, + { "damage_dealt", Statistic::DamageDealt }, + { "damage_dealt_absorbed", Statistic::DamageDealtAbsorbed }, + { "damage_dealt_resisted", Statistic::DamageDealtResisted }, + { "damage_resisted", Statistic::DamageResisted }, + { "damage_taken", Statistic::DamageTaken }, + { "deaths", Statistic::Deaths }, + { "drop", Statistic::Drop }, + { "eat_cake_slice", Statistic::EatCakeSlice }, + { "enchant_item", Statistic::EnchantItem }, + { "fall_one_cm", Statistic::FallOneCm }, + { "fill_cauldron", Statistic::FillCauldron }, + { "fish_caught", Statistic::FishCaught }, + { "fly_one_cm", Statistic::FlyOneCm }, + { "horse_one_cm", Statistic::HorseOneCm }, + { "inspect_dispenser", Statistic::InspectDispenser }, + { "inspect_dropper", Statistic::InspectDropper }, + { "inspect_hopper", Statistic::InspectHopper }, + { "interact_with_anvil", Statistic::InteractWithAnvil }, + { "interact_with_beacon", Statistic::InteractWithBeacon }, + { "interact_with_blast_furnace", Statistic::InteractWithBlastFurnace }, + { "interact_with_brewingstand", Statistic::InteractWithBrewingstand }, + { "interact_with_campfire", Statistic::InteractWithCampfire }, + { "interact_with_cartography_table", Statistic::InteractWithCartographyTable }, + { "interact_with_crafting_table", Statistic::InteractWithCraftingTable }, + { "interact_with_furnace", Statistic::InteractWithFurnace }, + { "interact_with_grindstone", Statistic::InteractWithGrindstone }, + { "interact_with_lectern", Statistic::InteractWithLectern }, + { "interact_with_loom", Statistic::InteractWithLoom }, + { "interact_with_smithing_table", Statistic::InteractWithSmithingTable }, + { "interact_with_smoker", Statistic::InteractWithSmoker }, + { "interact_with_stonecutter", Statistic::InteractWithStonecutter }, + { "jump", Statistic::Jump }, + { "leave_game", Statistic::LeaveGame }, + { "minecart_one_cm", Statistic::MinecartOneCm }, + { "mob_kills", Statistic::MobKills }, + { "open_barrel", Statistic::OpenBarrel }, + { "open_chest", Statistic::OpenChest }, + { "open_enderchest", Statistic::OpenEnderchest }, + { "open_shulker_box", Statistic::OpenShulkerBox }, + { "pig_one_cm", Statistic::PigOneCm }, + { "play_noteblock", Statistic::PlayNoteblock }, + { "play_one_minute", Statistic::PlayOneMinute }, + { "play_record", Statistic::PlayRecord }, + { "player_kills", Statistic::PlayerKills }, + { "pot_flower", Statistic::PotFlower }, + { "raid_trigger", Statistic::RaidTrigger }, + { "raid_win", Statistic::RaidWin }, + { "sleep_in_bed", Statistic::SleepInBed }, + { "sneak_time", Statistic::SneakTime }, + { "sprint_one_cm", Statistic::SprintOneCm }, + { "strider_one_cm", Statistic::StriderOneCm }, + { "swim_one_cm", Statistic::SwimOneCm }, + { "talked_to_villager", Statistic::TalkedToVillager }, + { "target_hit", Statistic::TargetHit }, + { "time_since_death", Statistic::TimeSinceDeath }, + { "time_since_rest", Statistic::TimeSinceRest }, + { "traded_with_villager", Statistic::TradedWithVillager }, + { "trigger_trapped_chest", Statistic::TriggerTrappedChest }, + { "tune_noteblock", Statistic::TuneNoteblock }, + { "use_cauldron", Statistic::UseCauldron }, + { "walk_on_water_one_cm", Statistic::WalkOnWaterOneCm }, + { "walk_one_cm", Statistic::WalkOneCm }, + { "walk_under_water_one_cm", Statistic::WalkUnderWaterOneCm }, + + // Old ones just for compatibility + { "junk_fished", Statistic::JunkFished }, + { "treasure_fished", Statistic::TreasureFished }, + + // The old advancements + { "cuberite:achievement.openInventory", Statistic::AchOpenInventory }, + { "cuberite:achievement.mineWood", Statistic::AchMineWood }, + { "cuberite:achievement.buildWorkBench", Statistic::AchBuildWorkBench }, + { "cuberite:achievement.buildPickaxe", Statistic::AchBuildPickaxe }, + { "cuberite:achievement.buildFurnace", Statistic::AchBuildFurnace }, + { "cuberite:achievement.acquireIron", Statistic::AchAcquireIron }, + { "cuberite:achievement.buildHoe", Statistic::AchBuildHoe }, + { "cuberite:achievement.makeBread", Statistic::AchMakeBread }, + { "cuberite:achievement.bakeCake", Statistic::AchBakeCake }, + { "cuberite:achievement.buildBetterPickaxe", Statistic::AchBuildBetterPickaxe }, + { "cuberite:achievement.cookFish", Statistic::AchCookFish }, + { "cuberite:achievement.onARail", Statistic::AchOnARail }, + { "cuberite:achievement.buildSword", Statistic::AchBuildSword }, + { "cuberite:achievement.killEnemy", Statistic::AchKillEnemy }, + { "cuberite:achievement.killCow", Statistic::AchKillCow }, + { "cuberite:achievement.flyPig", Statistic::AchFlyPig }, + { "cuberite:achievement.snipeSkeleton", Statistic::AchSnipeSkeleton }, + { "cuberite:achievement.diamonds", Statistic::AchDiamonds }, + { "cuberite:achievement.portal", Statistic::AchPortal }, + { "cuberite:achievement.ghast", Statistic::AchGhast }, + { "cuberite:achievement.blazeRod", Statistic::AchBlazeRod }, + { "cuberite:achievement.potion", Statistic::AchPotion }, + { "cuberite:achievement.theEnd", Statistic::AchTheEnd }, + { "cuberite:achievement.theEnd2", Statistic::AchTheEnd2 }, + { "cuberite:achievement.enchantments", Statistic::AchEnchantments }, + { "cuberite:achievement.overkill", Statistic::AchOverkill }, + { "cuberite:achievement.bookcase", Statistic::AchBookcase }, + { "cuberite:achievement.exploreAllBiomes", Statistic::AchExploreAllBiomes }, + { "cuberite:achievement.spawnWither", Statistic::AchSpawnWither }, + { "cuberite:achievement.killWither", Statistic::AchKillWither }, + { "cuberite:achievement.fullBeacon", Statistic::AchFullBeacon }, + { "cuberite:achievement.breedCow", Statistic::AchBreedCow }, + { "cuberite:achievement.diamondsToYou", Statistic::AchDiamondsToYou} + }; + + return CustomStatistics.at(ID); +} - Statistic ToCustomStatistic(const std::string_view ID) + +std::pair<NamespaceSerializer::Namespace, std::string_view> NamespaceSerializer::SplitNamespacedID(const std::string_view ID) +{ + const auto NamespaceIndex = ID.find(':'); + if (NamespaceIndex == std::string_view::npos) + { + // No explicit namespace defaults to the Minecraft namespace: + return { Namespace::Minecraft, ID }; + } + + const auto Namespace = ID.substr(0, NamespaceIndex); + if (Namespace == "minecraft") { - static const std::unordered_map<std::string_view, Statistic> CustomStatistics - { - { "animals_bred", Statistic::AnimalsBred }, - { "aviate_one_cm", Statistic::AviateOneCm }, - { "bell_ring", Statistic::BellRing }, - { "boat_one_cm", Statistic::BoatOneCm }, - { "clean_armor", Statistic::CleanArmor }, - { "clean_banner", Statistic::CleanBanner }, - { "clean_shulker_box", Statistic::CleanShulkerBox }, - { "climb_one_cm", Statistic::ClimbOneCm }, - { "crouch_one_cm", Statistic::CrouchOneCm }, - { "damage_absorbed", Statistic::DamageAbsorbed }, - { "damage_blocked_by_shield", Statistic::DamageBlockedByShield }, - { "damage_dealt", Statistic::DamageDealt }, - { "damage_dealt_absorbed", Statistic::DamageDealtAbsorbed }, - { "damage_dealt_resisted", Statistic::DamageDealtResisted }, - { "damage_resisted", Statistic::DamageResisted }, - { "damage_taken", Statistic::DamageTaken }, - { "deaths", Statistic::Deaths }, - { "drop", Statistic::Drop }, - { "eat_cake_slice", Statistic::EatCakeSlice }, - { "enchant_item", Statistic::EnchantItem }, - { "fall_one_cm", Statistic::FallOneCm }, - { "fill_cauldron", Statistic::FillCauldron }, - { "fish_caught", Statistic::FishCaught }, - { "fly_one_cm", Statistic::FlyOneCm }, - { "horse_one_cm", Statistic::HorseOneCm }, - { "inspect_dispenser", Statistic::InspectDispenser }, - { "inspect_dropper", Statistic::InspectDropper }, - { "inspect_hopper", Statistic::InspectHopper }, - { "interact_with_anvil", Statistic::InteractWithAnvil }, - { "interact_with_beacon", Statistic::InteractWithBeacon }, - { "interact_with_blast_furnace", Statistic::InteractWithBlastFurnace }, - { "interact_with_brewingstand", Statistic::InteractWithBrewingstand }, - { "interact_with_campfire", Statistic::InteractWithCampfire }, - { "interact_with_cartography_table", Statistic::InteractWithCartographyTable }, - { "interact_with_crafting_table", Statistic::InteractWithCraftingTable }, - { "interact_with_furnace", Statistic::InteractWithFurnace }, - { "interact_with_grindstone", Statistic::InteractWithGrindstone }, - { "interact_with_lectern", Statistic::InteractWithLectern }, - { "interact_with_loom", Statistic::InteractWithLoom }, - { "interact_with_smithing_table", Statistic::InteractWithSmithingTable }, - { "interact_with_smoker", Statistic::InteractWithSmoker }, - { "interact_with_stonecutter", Statistic::InteractWithStonecutter }, - { "jump", Statistic::Jump }, - { "leave_game", Statistic::LeaveGame }, - { "minecart_one_cm", Statistic::MinecartOneCm }, - { "mob_kills", Statistic::MobKills }, - { "open_barrel", Statistic::OpenBarrel }, - { "open_chest", Statistic::OpenChest }, - { "open_enderchest", Statistic::OpenEnderchest }, - { "open_shulker_box", Statistic::OpenShulkerBox }, - { "pig_one_cm", Statistic::PigOneCm }, - { "play_noteblock", Statistic::PlayNoteblock }, - { "play_one_minute", Statistic::PlayOneMinute }, - { "play_record", Statistic::PlayRecord }, - { "player_kills", Statistic::PlayerKills }, - { "pot_flower", Statistic::PotFlower }, - { "raid_trigger", Statistic::RaidTrigger }, - { "raid_win", Statistic::RaidWin }, - { "sleep_in_bed", Statistic::SleepInBed }, - { "sneak_time", Statistic::SneakTime }, - { "sprint_one_cm", Statistic::SprintOneCm }, - { "strider_one_cm", Statistic::StriderOneCm }, - { "swim_one_cm", Statistic::SwimOneCm }, - { "talked_to_villager", Statistic::TalkedToVillager }, - { "target_hit", Statistic::TargetHit }, - { "time_since_death", Statistic::TimeSinceDeath }, - { "time_since_rest", Statistic::TimeSinceRest }, - { "traded_with_villager", Statistic::TradedWithVillager }, - { "trigger_trapped_chest", Statistic::TriggerTrappedChest }, - { "tune_noteblock", Statistic::TuneNoteblock }, - { "use_cauldron", Statistic::UseCauldron }, - { "walk_on_water_one_cm", Statistic::WalkOnWaterOneCm }, - { "walk_one_cm", Statistic::WalkOneCm }, - { "walk_under_water_one_cm", Statistic::WalkUnderWaterOneCm }, - - // Old ones just for compatibility - { "junk_fished", Statistic::JunkFished }, - { "treasure_fished", Statistic::TreasureFished }, - - // The old advancements - { "cuberite:achievement.openInventory", Statistic::AchOpenInventory }, - { "cuberite:achievement.mineWood", Statistic::AchMineWood }, - { "cuberite:achievement.buildWorkBench", Statistic::AchBuildWorkBench }, - { "cuberite:achievement.buildPickaxe", Statistic::AchBuildPickaxe }, - { "cuberite:achievement.buildFurnace", Statistic::AchBuildFurnace }, - { "cuberite:achievement.acquireIron", Statistic::AchAcquireIron }, - { "cuberite:achievement.buildHoe", Statistic::AchBuildHoe }, - { "cuberite:achievement.makeBread", Statistic::AchMakeBread }, - { "cuberite:achievement.bakeCake", Statistic::AchBakeCake }, - { "cuberite:achievement.buildBetterPickaxe", Statistic::AchBuildBetterPickaxe }, - { "cuberite:achievement.cookFish", Statistic::AchCookFish }, - { "cuberite:achievement.onARail", Statistic::AchOnARail }, - { "cuberite:achievement.buildSword", Statistic::AchBuildSword }, - { "cuberite:achievement.killEnemy", Statistic::AchKillEnemy }, - { "cuberite:achievement.killCow", Statistic::AchKillCow }, - { "cuberite:achievement.flyPig", Statistic::AchFlyPig }, - { "cuberite:achievement.snipeSkeleton", Statistic::AchSnipeSkeleton }, - { "cuberite:achievement.diamonds", Statistic::AchDiamonds }, - { "cuberite:achievement.portal", Statistic::AchPortal }, - { "cuberite:achievement.ghast", Statistic::AchGhast }, - { "cuberite:achievement.blazeRod", Statistic::AchBlazeRod }, - { "cuberite:achievement.potion", Statistic::AchPotion }, - { "cuberite:achievement.theEnd", Statistic::AchTheEnd }, - { "cuberite:achievement.theEnd2", Statistic::AchTheEnd2 }, - { "cuberite:achievement.enchantments", Statistic::AchEnchantments }, - { "cuberite:achievement.overkill", Statistic::AchOverkill }, - { "cuberite:achievement.bookcase", Statistic::AchBookcase }, - { "cuberite:achievement.exploreAllBiomes", Statistic::AchExploreAllBiomes }, - { "cuberite:achievement.spawnWither", Statistic::AchSpawnWither }, - { "cuberite:achievement.killWither", Statistic::AchKillWither }, - { "cuberite:achievement.fullBeacon", Statistic::AchFullBeacon }, - { "cuberite:achievement.breedCow", Statistic::AchBreedCow }, - { "cuberite:achievement.diamondsToYou", Statistic::AchDiamondsToYou} - }; - - return CustomStatistics.at(ID); + // An unprefixed ID in the vanilla Minecraft namespace. + const auto Value = ID.substr(NamespaceIndex + 1); + + return { Namespace::Minecraft, Value }; } - std::pair<Namespace, std::string_view> SplitNamespacedID(const std::string_view ID) + if (Namespace == "cuberite") { - const auto NamespaceIndex = ID.find(':'); - if (NamespaceIndex == std::string_view::npos) - { - // No explicit namespace defaults to the Minecraft namespace: - return { Namespace::Minecraft, ID }; - } - - const auto Namespace = ID.substr(0, NamespaceIndex); - if (Namespace == "minecraft") - { - // An unprefixed ID in the vanilla Minecraft namespace. - const auto Value = ID.substr(NamespaceIndex + 1); - - return { Namespace::Minecraft, Value }; - } - - if (Namespace == "cuberite") - { - return { Namespace::Cuberite, ID }; - } - - return { Namespace::Unknown, ID }; + return { Namespace::Cuberite, ID }; } + + return { Namespace::Unknown, ID }; +} + + + + + +eMonsterType NamespaceSerializer::ToMonsterType(const std::string_view a_ID) +{ + static const std::unordered_map<std::string_view, eMonsterType> MonsterTypes + { + { "bat", mtBat }, + { "blaze", mtBlaze }, + { "cat", mtCat }, + { "cave_spider", mtCaveSpider }, + { "chicken", mtChicken }, + { "cod", mtCod }, + { "cow", mtCow }, + { "creeper", mtCreeper }, + { "dolphin", mtDolphin }, + { "donkey", mtDonkey }, + { "drowned", mtDrowned }, + { "elder_guardian", mtElderGuardian }, + { "ender_dragon", mtEnderDragon }, + { "enderman", mtEnderman }, + { "endermite", mtEndermite }, + { "evoker", mtEvoker }, + { "fox", mtFox }, + { "ghast", mtGhast }, + { "giant", mtGiant }, + { "guardian", mtGuardian }, + { "horse", mtHorse }, + { "hoglin", mtHoglin }, + { "husk", mtHusk }, + { "illusioner", mtIllusioner }, + { "iron_golem", mtIronGolem }, + { "llama", mtLlama }, + { "magma_cube", mtMagmaCube }, + { "mooshroom", mtMooshroom }, + { "mule", mtMule }, + { "ocelot", mtOcelot }, + { "panda", mtPanda }, + { "parrot", mtParrot }, + { "phantom", mtPhantom }, + { "pig", mtPig }, + { "piglin", mtPiglin }, + { "piglin_brute", mtPiglinBrute }, + { "pillager", mtPillager }, + { "polar_bear", mtPolarBear }, + { "pufferfish", mtPufferfish }, + { "rabbit", mtRabbit }, + { "ravager", mtRavager }, + { "salmon", mtSalmon }, + { "sheep", mtSheep }, + { "shulker", mtShulker }, + { "silverfish", mtSilverfish }, + { "skeleton", mtSkeleton }, + { "skeleton_horse", mtSkeletonHorse }, + { "slime", mtSlime }, + { "snow_golem", mtSnowGolem }, + { "spider", mtSpider }, + { "squid", mtSquid }, + { "stray", mtStray }, + { "strider", mtStrider }, + { "trader_llama", mtTraderLlama }, + { "tropical_fish", mtTropicalFish }, + { "turtle", mtTurtle }, + { "vex", mtVex }, + { "villager", mtVillager }, + { "vindicator", mtVindicator }, + { "wandering_trader", mtWanderingTrader }, + { "witch", mtWitch }, + { "wither", mtWither }, + { "wither_skeleton", mtWitherSkeleton }, + { "wolf", mtWolf }, + { "zoglin", mtZoglin }, + { "zombie", mtZombie }, + { "zombie_horse", mtZombieHorse }, + { "zombie_pigman", mtZombiePigman }, + { "zombie_villager", mtZombieVillager }, + + { "villager_golem", mtIronGolem }, + { "snowman", mtSnowGolem }, + + // Old names: + { "Bat", mtBat }, + { "Blaze", mtBlaze }, + { "CaveSpider", mtCaveSpider }, + { "Chicken", mtChicken }, + { "Cow", mtCow }, + { "Creeper", mtCreeper }, + { "EnderDragon", mtEnderDragon }, + { "Enderman", mtEnderman }, + { "Ghast", mtGhast }, + { "Giant", mtGiant }, + { "Guardian", mtGuardian }, + { "Horse", mtHorse }, + { "VillagerGolem", mtIronGolem }, + { "LavaSlime", mtMagmaCube }, + { "MushroomCow", mtMooshroom }, + { "Ozelot", mtOcelot }, + { "Pig", mtPig }, + { "Rabbit", mtRabbit }, + { "Sheep", mtSheep }, + { "Silverfish", mtSilverfish }, + { "Skeleton", mtSkeleton }, + { "Slime", mtSlime }, + { "SnowMan", mtSnowGolem }, + { "Spider", mtSpider }, + { "Squid", mtSquid }, + { "Villager", mtVillager }, + { "Witch", mtWitch }, + { "WitherBoss", mtWither }, + { "WitherSkeleton", mtWitherSkeleton }, + { "Wolf", mtWolf }, + { "Zombie", mtZombie }, + { "PigZombie", mtZombiePigman }, + { "ZombieVillager", mtZombieVillager } + }; + + return MonsterTypes.at(a_ID); } diff --git a/src/WorldStorage/NamespaceSerializer.h b/src/WorldStorage/NamespaceSerializer.h index d7902409f..5b0093bcc 100644 --- a/src/WorldStorage/NamespaceSerializer.h +++ b/src/WorldStorage/NamespaceSerializer.h @@ -1,6 +1,7 @@ #pragma once #include "../Registries/Statistics.h" +#include "../Mobs/MonsterTypes.h" namespace NamespaceSerializer { @@ -13,9 +14,11 @@ namespace NamespaceSerializer unsigned DataVersion(); - const char * From(Statistic ID); + std::string_view From(Statistic a_ID); + std::string_view From(eMonsterType a_ID); - Statistic ToCustomStatistic(std::string_view ID); + Statistic ToCustomStatistic(std::string_view a_ID); + eMonsterType ToMonsterType(std::string_view a_ID); std::pair<Namespace, std::string_view> SplitNamespacedID(std::string_view ID); } diff --git a/src/WorldStorage/StatSerializer.cpp b/src/WorldStorage/StatSerializer.cpp index 11b5ffbf9..d5543ca79 100644 --- a/src/WorldStorage/StatSerializer.cpp +++ b/src/WorldStorage/StatSerializer.cpp @@ -46,7 +46,7 @@ namespace StatSerializer auto & Custom = a_Out["custom"]; for (const auto & Item : Store) { - Custom[NamespaceSerializer::From(Item.first)] = Item.second; + Custom[NamespaceSerializer::From(Item.first).data()] = Item.second; } }); } diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index cfea33737..0e874df7c 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -7,6 +7,7 @@ #include "WSSAnvil.h" #include "NBTChunkSerializer.h" #include "EnchantmentSerializer.h" +#include "NamespaceSerializer.h" #include "zlib/zlib.h" #include "json/json.h" #include "../World.h" @@ -583,7 +584,15 @@ void cWSSAnvil::LoadEntitiesFromNBT(cEntityList & a_Entities, const cParsedNBT & { continue; } - LoadEntityFromNBT(a_Entities, a_NBT, Child, a_NBT.GetData(sID), a_NBT.GetDataLength(sID)); + + try + { + LoadEntityFromNBT(a_Entities, a_NBT, Child, a_NBT.GetData(sID), a_NBT.GetDataLength(sID)); + } + catch (...) + { + continue; + } } // for Child - a_NBT[] } @@ -617,15 +626,28 @@ void cWSSAnvil::LoadBlockEntitiesFromNBT(cBlockEntities & a_BlockEntities, const // Load the proper BlockEntity type based on the block type: BLOCKTYPE BlockType = cChunkDef::GetBlock(a_BlockTypes, relPos); NIBBLETYPE BlockMeta = cChunkDef::GetNibble(a_BlockMetas, relPos); - auto be = LoadBlockEntityFromNBT(a_NBT, Child, absPos, BlockType, BlockMeta); - if (be == nullptr) + OwnedBlockEntity Entity; + + try + { + Entity = LoadBlockEntityFromNBT(a_NBT, Child, absPos, BlockType, BlockMeta); + } + catch (...) { continue; } + // TODO: exception-ify the failure case + if (Entity == nullptr) + { + continue; + } + + // Index computed before Entity moved. + const auto Idx = cChunkDef::MakeIndexNoCheck(Entity->GetRelPos()); + // Add the BlockEntity to the loaded data: - auto Idx = cChunkDef::MakeIndex(be->GetRelX(), be->GetPosY(), be->GetRelZ()); - a_BlockEntities.emplace(Idx, std::move(be)); + a_BlockEntities.emplace(Idx, std::move(Entity)); } // for Child - tag children } @@ -1342,7 +1364,13 @@ OwnedBlockEntity cWSSAnvil::LoadMobSpawnerFromNBT(const cParsedNBT & a_NBT, int int Type = a_NBT.FindChildByName(a_TagIdx, "EntityId"); if ((Type >= 0) && (a_NBT.GetType(Type) == TAG_String)) { - eMonsterType MonsterType = cMonster::StringToMobType(a_NBT.GetString(Type)); + const auto StatInfo = NamespaceSerializer::SplitNamespacedID(a_NBT.GetString(Type)); + if (StatInfo.first == NamespaceSerializer::Namespace::Unknown) + { + return nullptr; + } + + eMonsterType MonsterType = NamespaceSerializer::ToMonsterType(StatInfo.second); if (MonsterType != eMonsterType::mtInvalidType) { MobSpawner->SetEntity(MonsterType); @@ -1591,81 +1619,97 @@ void cWSSAnvil::LoadEntityFromNBT(cEntityList & a_Entities, const cParsedNBT & a { "SmallFireball", &cWSSAnvil::LoadFireChargeFromNBT }, { "minecraft:small_fireball", &cWSSAnvil::LoadFireChargeFromNBT }, { "ThrownEnderpearl", &cWSSAnvil::LoadThrownEnderpearlFromNBT }, - { "minecraft:ender_pearl", &cWSSAnvil::LoadThrownEnderpearlFromNBT }, - { "Bat", &cWSSAnvil::LoadBatFromNBT }, - { "minecraft:bat", &cWSSAnvil::LoadBatFromNBT }, - { "Blaze", &cWSSAnvil::LoadBlazeFromNBT }, - { "minecraft:blaze", &cWSSAnvil::LoadBlazeFromNBT }, - { "CaveSpider", &cWSSAnvil::LoadCaveSpiderFromNBT }, - { "minecraft:cave_spider", &cWSSAnvil::LoadCaveSpiderFromNBT }, - { "Chicken", &cWSSAnvil::LoadChickenFromNBT }, - { "minecraft:chicken", &cWSSAnvil::LoadChickenFromNBT }, - { "Cow", &cWSSAnvil::LoadCowFromNBT }, - { "minecraft:cow", &cWSSAnvil::LoadCowFromNBT }, - { "Creeper", &cWSSAnvil::LoadCreeperFromNBT }, - { "minecraft:creeper", &cWSSAnvil::LoadCreeperFromNBT }, - { "EnderDragon", &cWSSAnvil::LoadEnderDragonFromNBT }, - { "minecraft:ender_dragon", &cWSSAnvil::LoadEnderDragonFromNBT }, - { "Enderman", &cWSSAnvil::LoadEndermanFromNBT }, - { "minecraft:enderman", &cWSSAnvil::LoadEndermanFromNBT }, - { "Ghast", &cWSSAnvil::LoadGhastFromNBT }, - { "minecraft:ghast", &cWSSAnvil::LoadGhastFromNBT }, - { "Giant", &cWSSAnvil::LoadGiantFromNBT }, - { "minecraft:giant", &cWSSAnvil::LoadGiantFromNBT }, - { "Guardian", &cWSSAnvil::LoadGuardianFromNBT }, - { "minecraft:guardian", &cWSSAnvil::LoadGuardianFromNBT }, - { "Horse", &cWSSAnvil::LoadHorseFromNBT }, - { "minecraft:horse", &cWSSAnvil::LoadHorseFromNBT }, - { "Villager", &cWSSAnvil::LoadVillagerFromNBT }, - { "minecraft:villager", &cWSSAnvil::LoadVillagerFromNBT }, - { "VillagerGolem", &cWSSAnvil::LoadIronGolemFromNBT }, - { "minecraft:villager_golem", &cWSSAnvil::LoadIronGolemFromNBT }, - { "LavaSlime", &cWSSAnvil::LoadMagmaCubeFromNBT }, - { "minecraft:magma_cube", &cWSSAnvil::LoadMagmaCubeFromNBT }, - { "MushroomCow", &cWSSAnvil::LoadMooshroomFromNBT }, - { "minecraft:mooshroom", &cWSSAnvil::LoadMooshroomFromNBT }, - { "Ozelot", &cWSSAnvil::LoadOcelotFromNBT }, - { "minecraft:ocelot", &cWSSAnvil::LoadOcelotFromNBT }, - { "Pig", &cWSSAnvil::LoadPigFromNBT }, - { "minecraft:pig", &cWSSAnvil::LoadPigFromNBT }, - { "Rabbit", &cWSSAnvil::LoadRabbitFromNBT }, - { "minecraft:rabbit", &cWSSAnvil::LoadRabbitFromNBT }, - { "Sheep", &cWSSAnvil::LoadSheepFromNBT }, - { "minecraft:sheep", &cWSSAnvil::LoadSheepFromNBT }, - { "Silverfish", &cWSSAnvil::LoadSilverfishFromNBT }, - { "minecraft:silverfish", &cWSSAnvil::LoadSilverfishFromNBT }, - { "Skeleton", &cWSSAnvil::LoadSkeletonFromNBT }, - { "minecraft:skeleton", &cWSSAnvil::LoadSkeletonFromNBT }, - { "Slime", &cWSSAnvil::LoadSlimeFromNBT }, - { "minecraft:slime", &cWSSAnvil::LoadSlimeFromNBT }, - { "SnowMan", &cWSSAnvil::LoadSnowGolemFromNBT }, - { "minecraft:snowman", &cWSSAnvil::LoadSnowGolemFromNBT }, - { "Spider", &cWSSAnvil::LoadSpiderFromNBT }, - { "minecraft:spider", &cWSSAnvil::LoadSpiderFromNBT }, - { "Squid", &cWSSAnvil::LoadSquidFromNBT }, - { "minecraft:squid", &cWSSAnvil::LoadSquidFromNBT }, - { "Witch", &cWSSAnvil::LoadWitchFromNBT }, - { "minecraft:witch", &cWSSAnvil::LoadWitchFromNBT }, - { "WitherBoss", &cWSSAnvil::LoadWitherFromNBT }, - { "minecraft:wither", &cWSSAnvil::LoadWitherFromNBT }, - { "WitherSkeleton", &cWSSAnvil::LoadWitherSkeletonFromNBT }, - { "minecraft:wither_skeleton", &cWSSAnvil::LoadWitherSkeletonFromNBT }, - { "Wolf", &cWSSAnvil::LoadWolfFromNBT }, - { "minecraft:wolf", &cWSSAnvil::LoadWolfFromNBT }, - { "Zombie", &cWSSAnvil::LoadZombieFromNBT }, - { "minecraft:zombie", &cWSSAnvil::LoadZombieFromNBT }, - { "PigZombie", &cWSSAnvil::LoadPigZombieFromNBT }, - { "minecraft:zombie_pigman", &cWSSAnvil::LoadPigZombieFromNBT }, - { "ZombieVillager", &cWSSAnvil::LoadZombieVillagerFromNBT }, - { "minecraft:zombie_villager", &cWSSAnvil::LoadZombieVillagerFromNBT }, + { "minecraft:ender_pearl", &cWSSAnvil::LoadThrownEnderpearlFromNBT } }; + // TODO: flatten monster\projectile into one entity type enum + auto it = EntityTypeToFunction.find(AString(a_IDTag, a_IDTagLength)); if (it != EntityTypeToFunction.end()) { (this->*it->second)(a_Entities, a_NBT, a_EntityTagIdx); + return; + } + + const auto StatInfo = NamespaceSerializer::SplitNamespacedID({ a_IDTag, a_IDTagLength }); + if (StatInfo.first == NamespaceSerializer::Namespace::Unknown) + { + return; + } + + switch (NamespaceSerializer::ToMonsterType(StatInfo.second)) + { + case mtBat: return LoadBatFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtBlaze: return LoadBlazeFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtCat: return LoadCatFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtCaveSpider: return LoadCaveSpiderFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtChicken: return LoadChickenFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtCod: return LoadCodFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtCow: return LoadCowFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtCreeper: return LoadCreeperFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtDolphin: return LoadDolphinFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtDonkey: return LoadDonkeyFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtDrowned: return LoadDrownedFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtElderGuardian: return LoadElderGuardianFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtEnderDragon: return LoadEnderDragonFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtEnderman: return LoadEndermanFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtEndermite: return LoadEndermiteFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtEvoker: return LoadEvokerFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtFox: return LoadFoxFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtGhast: return LoadGhastFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtGiant: return LoadGiantFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtGuardian: return LoadGuardianFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtHorse: return LoadHorseFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtHoglin: return LoadHoglinFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtHusk: return LoadHuskFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtIllusioner: return LoadIllusionerFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtIronGolem: return LoadVillagerFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtLlama: return LoadIronGolemFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtMagmaCube: return LoadLlamaFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtMooshroom: return LoadMagmaCubeFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtMule: return LoadMooshroomFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtOcelot: return LoadMuleFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtPanda: return LoadOcelotFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtParrot: return LoadPandaFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtPhantom: return LoadParrotFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtPig: return LoadPhantomFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtPiglin: return LoadPigFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtPiglinBrute: return LoadPiglinFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtPillager: return LoadPiglinBruteFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtPolarBear: return LoadPillagerFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtPufferfish: return LoadPolarBearFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtRabbit: return LoadPufferfishFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtRavager: return LoadRabbitFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtSalmon: return LoadRavagerFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtSheep: return LoadSalmonFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtShulker: return LoadSheepFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtSilverfish: return LoadShulkerFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtSkeleton: return LoadSilverfishFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtSkeletonHorse: return LoadSkeletonFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtSlime: return LoadSlimeFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtSnowGolem: return LoadSnowGolemFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtSpider: return LoadSpiderFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtSquid: return LoadSquidFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtStray: return LoadStrayFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtStrider: return LoadStriderFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtTraderLlama: return LoadTraderLlamaFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtTropicalFish: return LoadTropicalFishFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtTurtle: return LoadTurtleFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtVex: return LoadVexFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtVillager: return LoadVillagerFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtVindicator: return LoadVindicatorFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtWanderingTrader: return LoadWanderingTraderFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtWitch: return LoadWitchFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtWither: return LoadWitherFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtWitherSkeleton: return LoadWitherSkeletonFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtWolf: return LoadWolfFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtZoglin: return LoadZoglinFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtZombie: return LoadZombieFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtZombieHorse: return LoadZombieHorseFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtZombifiedPiglin: return LoadZombifiedPiglinFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtZombieVillager: return LoadZombieVillagerFromNBT(a_Entities, a_NBT, a_EntityTagIdx); + case mtInvalidType: break; } - // TODO: other entities } @@ -2290,6 +2334,15 @@ void cWSSAnvil::LoadBlazeFromNBT(cEntityList & a_Entities, const cParsedNBT & a_ +void cWSSAnvil::LoadCatFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx) +{ + // TODO +} + + + + + void cWSSAnvil::LoadCaveSpiderFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx) { std::unique_ptr<cCaveSpider> Monster = std::make_unique<cCaveSpider>(); @@ -2330,6 +2383,15 @@ void cWSSAnvil::LoadChickenFromNBT(cEntityList & a_Entities, const cParsedNBT & +void cWSSAnvil::LoadCodFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx) +{ + // TODO +} + + + + + void cWSSAnvil::LoadCowFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx) { std::unique_ptr<cCow> Monster = std::make_unique<cCow>(); @@ -2370,6 +2432,42 @@ void cWSSAnvil::LoadCreeperFromNBT(cEntityList & a_Entities, const cParsedNBT & +void cWSSAnvil::LoadDolphinFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx) +{ + // TODO +} + + + + + +void cWSSAnvil::LoadDonkeyFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx) +{ + // TODO +} + + + + + +void cWSSAnvil::LoadDrownedFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx) +{ + // TODO +} + + + + + +void cWSSAnvil::LoadElderGuardianFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx) +{ + // TODO +} + + + + + void cWSSAnvil::LoadEnderDragonFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx) { std::unique_ptr<cEnderDragon> Monster = std::make_unique<cEnderDragon>(); @@ -2410,6 +2508,33 @@ void cWSSAnvil::LoadEndermanFromNBT(cEntityList & a_Entities, const cParsedNBT & +void cWSSAnvil::LoadEndermiteFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx) +{ + // TODO +} + + + + + +void cWSSAnvil::LoadEvokerFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx) +{ + // TODO +} + + + + + +void cWSSAnvil::LoadFoxFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx) +{ + // TODO +} + + + + + void cWSSAnvil::LoadGhastFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx) { std::unique_ptr<cGhast> Monster = std::make_unique<cGhast>(); @@ -2516,6 +2641,33 @@ void cWSSAnvil::LoadHorseFromNBT(cEntityList & a_Entities, const cParsedNBT & a_ +void cWSSAnvil::LoadHoglinFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx) +{ + // TODO +} + + + + + +void cWSSAnvil::LoadHuskFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx) +{ + // TODO +} + + + + + +void cWSSAnvil::LoadIllusionerFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx) +{ + // TODO +} + + + + + void cWSSAnvil::LoadIronGolemFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx) { std::unique_ptr<cIronGolem> Monster = std::make_unique<cIronGolem>(); @@ -2536,6 +2688,15 @@ void cWSSAnvil::LoadIronGolemFromNBT(cEntityList & a_Entities, const cParsedNBT +void cWSSAnvil::LoadLlamaFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx) +{ + // TODO +} + + + + + void cWSSAnvil::LoadMagmaCubeFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx) { int SizeIdx = a_NBT.FindChildByName(a_TagIdx, "Size"); @@ -2585,6 +2746,15 @@ void cWSSAnvil::LoadMooshroomFromNBT(cEntityList & a_Entities, const cParsedNBT +void cWSSAnvil::LoadMuleFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx) +{ + // TODO +} + + + + + void cWSSAnvil::LoadOcelotFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx) { std::unique_ptr<cOcelot> Monster = std::make_unique<cOcelot>(); @@ -2639,6 +2809,33 @@ void cWSSAnvil::LoadOcelotFromNBT(cEntityList & a_Entities, const cParsedNBT & a +void cWSSAnvil::LoadPandaFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx) +{ + // TODO +} + + + + + +void cWSSAnvil::LoadParrotFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx) +{ + // TODO +} + + + + + +void cWSSAnvil::LoadPhantomFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx) +{ + // TODO +} + + + + + void cWSSAnvil::LoadPigFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx) { std::unique_ptr<cPig> Monster = std::make_unique<cPig>(); @@ -2672,6 +2869,51 @@ void cWSSAnvil::LoadPigFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NB +void cWSSAnvil::LoadPiglinFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx) +{ + // TODO +} + + + + + +void cWSSAnvil::LoadPiglinBruteFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx) +{ + // TODO +} + + + + + +void cWSSAnvil::LoadPillagerFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx) +{ + // TODO +} + + + + + +void cWSSAnvil::LoadPolarBearFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx) +{ + // TODO +} + + + + + +void cWSSAnvil::LoadPufferfishFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx) +{ + // TODO +} + + + + + void cWSSAnvil::LoadRabbitFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx) { int TypeIdx = a_NBT.FindChildByName(a_TagIdx, "RabbitType"); @@ -2716,6 +2958,24 @@ void cWSSAnvil::LoadRabbitFromNBT(cEntityList & a_Entities, const cParsedNBT & a +void cWSSAnvil::LoadRavagerFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx) +{ + // TODO +} + + + + + +void cWSSAnvil::LoadSalmonFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx) +{ + // TODO +} + + + + + void cWSSAnvil::LoadSheepFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx) { int ColorIdx = a_NBT.FindChildByName(a_TagIdx, "Color"); @@ -2762,6 +3022,15 @@ void cWSSAnvil::LoadSheepFromNBT(cEntityList & a_Entities, const cParsedNBT & a_ +void cWSSAnvil::LoadShulkerFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx) +{ + // TODO +} + + + + + void cWSSAnvil::LoadSilverfishFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx) { std::unique_ptr<cSilverfish> Monster = std::make_unique<cSilverfish>(); @@ -2815,6 +3084,15 @@ void cWSSAnvil::LoadSkeletonFromNBT(cEntityList & a_Entities, const cParsedNBT & +void cWSSAnvil::LoadSkeletonHorseFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx) +{ + // TODO +} + + + + + void cWSSAnvil::LoadSlimeFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx) { int SizeIdx = a_NBT.FindChildByName(a_TagIdx, "Size"); @@ -2904,6 +3182,60 @@ void cWSSAnvil::LoadSquidFromNBT(cEntityList & a_Entities, const cParsedNBT & a_ +void cWSSAnvil::LoadStrayFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx) +{ + // TODO +} + + + + + +void cWSSAnvil::LoadStriderFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx) +{ + // TODO +} + + + + + +void cWSSAnvil::LoadTraderLlamaFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx) +{ + // TODO +} + + + + + +void cWSSAnvil::LoadTropicalFishFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx) +{ + // TODO +} + + + + + +void cWSSAnvil::LoadTurtleFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx) +{ + // TODO +} + + + + + +void cWSSAnvil::LoadVexFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx) +{ + // TODO +} + + + + + void cWSSAnvil::LoadVillagerFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx) { int TypeIdx = a_NBT.FindChildByName(a_TagIdx, "Profession"); @@ -2946,6 +3278,24 @@ void cWSSAnvil::LoadVillagerFromNBT(cEntityList & a_Entities, const cParsedNBT & +void cWSSAnvil::LoadVindicatorFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx) +{ + // TODO +} + + + + + +void cWSSAnvil::LoadWanderingTraderFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx) +{ + // TODO +} + + + + + void cWSSAnvil::LoadWitchFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx) { std::unique_ptr<cWitch> Monster = std::make_unique<cWitch>(); @@ -3088,6 +3438,15 @@ void cWSSAnvil::LoadWolfFromNBT(cEntityList & a_Entities, const cParsedNBT & a_N +void cWSSAnvil::LoadZoglinFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx) +{ + // TODO +} + + + + + void cWSSAnvil::LoadZombieFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx) { std::unique_ptr<cZombie> Monster = std::make_unique<cZombie>(); @@ -3121,7 +3480,16 @@ void cWSSAnvil::LoadZombieFromNBT(cEntityList & a_Entities, const cParsedNBT & a -void cWSSAnvil::LoadPigZombieFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx) +void cWSSAnvil::LoadZombieHorseFromNBT(cEntityList &a_Entities, const cParsedNBT &a_NBT, int a_TagIdx) +{ + // TODO +} + + + + + +void cWSSAnvil::LoadZombifiedPiglinFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx) { std::unique_ptr<cZombiePigman> Monster = std::make_unique<cZombiePigman>(); if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx)) diff --git a/src/WorldStorage/WSSAnvil.h b/src/WorldStorage/WSSAnvil.h index 8baa69c00..6d9b49788 100755 --- a/src/WorldStorage/WSSAnvil.h +++ b/src/WorldStorage/WSSAnvil.h @@ -205,36 +205,72 @@ protected: void LoadBatFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadBlazeFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); + void LoadCatFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadCaveSpiderFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadChickenFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); + void LoadCodFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadCowFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadCreeperFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); + void LoadDolphinFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); + void LoadDonkeyFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); + void LoadDrownedFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); + void LoadElderGuardianFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadEnderDragonFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadEndermanFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); + void LoadEndermiteFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); + void LoadEvokerFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); + void LoadFoxFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadGhastFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadGiantFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadGuardianFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadHorseFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); + void LoadHoglinFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); + void LoadHuskFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); + void LoadIllusionerFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadIronGolemFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); + void LoadLlamaFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadMagmaCubeFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadMooshroomFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); + void LoadMuleFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadOcelotFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); + void LoadPandaFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); + void LoadParrotFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); + void LoadPhantomFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadPigFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); + void LoadPiglinFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); + void LoadPiglinBruteFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); + void LoadPillagerFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); + void LoadPolarBearFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); + void LoadPufferfishFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadRabbitFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); + void LoadRavagerFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); + void LoadSalmonFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadSheepFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); + void LoadShulkerFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadSilverfishFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadSkeletonFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); + void LoadSkeletonHorseFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadSlimeFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadSnowGolemFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadSpiderFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadSquidFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); + void LoadStrayFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); + void LoadStriderFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); + void LoadTraderLlamaFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); + void LoadTropicalFishFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); + void LoadTurtleFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); + void LoadVexFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadVillagerFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); + void LoadVindicatorFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); + void LoadWanderingTraderFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadWitchFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadWitherFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadWitherSkeletonFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadWolfFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); + void LoadZoglinFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadZombieFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); - void LoadPigZombieFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); + void LoadZombieHorseFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); + void LoadZombifiedPiglinFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); void LoadZombieVillagerFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx); /** Loads the owner name and UUID from the entity at the specified NBT tag. |