summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTheHyper45 <dawid.priv@o2.pl>2021-06-20 10:39:52 +0200
committerAlexander Harkness <me@bearbin.net>2022-04-12 01:06:40 +0200
commitca9d0aa4e2c1b6dfd914f77a9cde349ee62a9851 (patch)
treea02ac39ce081a560d70e728ab3d4e7b4038d296b
parentadd hle0 to CONTRIBUTORS (diff)
downloadcuberite-ca9d0aa4e2c1b6dfd914f77a9cde349ee62a9851.tar
cuberite-ca9d0aa4e2c1b6dfd914f77a9cde349ee62a9851.tar.gz
cuberite-ca9d0aa4e2c1b6dfd914f77a9cde349ee62a9851.tar.bz2
cuberite-ca9d0aa4e2c1b6dfd914f77a9cde349ee62a9851.tar.lz
cuberite-ca9d0aa4e2c1b6dfd914f77a9cde349ee62a9851.tar.xz
cuberite-ca9d0aa4e2c1b6dfd914f77a9cde349ee62a9851.tar.zst
cuberite-ca9d0aa4e2c1b6dfd914f77a9cde349ee62a9851.zip
Diffstat (limited to '')
-rw-r--r--src/Entities/Entity.cpp12
-rw-r--r--src/WorldStorage/NamespaceSerializer.cpp84
-rw-r--r--src/WorldStorage/NamespaceSerializer.h2
3 files changed, 88 insertions, 10 deletions
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index b6a67859b..c4f61ad1e 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -16,6 +16,7 @@
#include "../FastRandom.h"
#include "../NetherPortalScanner.h"
#include "../BoundingBox.h"
+#include "../WorldStorage/NamespaceSerializer.h"
@@ -2364,16 +2365,7 @@ void cEntity::BroadcastDeathMessage(TakeDamageInfo & a_TDI)
}
else
{
- // Tamed ocelots are really cats in vanilla.
- if (Monster->IsTame() && (Monster->GetClass() == AString("cOcelot")))
- {
- Name = "Cat";
- }
- else
- {
- Name = Monster->GetClass();
- Name.erase(Name.begin()); // Erase the 'c' of the class (e.g. "cWitch" -> "Witch")
- }
+ Name = AString(NamespaceSerializer::Prettify(Monster->GetMobType(), Monster->IsTame()));
}
}
else
diff --git a/src/WorldStorage/NamespaceSerializer.cpp b/src/WorldStorage/NamespaceSerializer.cpp
index 2e2e9302e..969f9b5de 100644
--- a/src/WorldStorage/NamespaceSerializer.cpp
+++ b/src/WorldStorage/NamespaceSerializer.cpp
@@ -546,3 +546,87 @@ eMonsterType NamespaceSerializer::ToMonsterType(const std::string_view a_ID)
return MonsterTypes.at(a_ID);
}
+
+
+
+
+
+std::string_view NamespaceSerializer::Prettify(const eMonsterType a_ID, const bool a_IsTamed)
+{
+ switch (a_ID)
+ {
+ 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";
+ // In older vanilla Minecraft version (before 1.14) ocelots and cats were the same mob.
+ // So after killing a tamed ocelot without a custom name the message will say "Cat was slain by [PlayerName]".
+ case mtOcelot: return (a_IsTamed ? "Cat" : "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");
+}
diff --git a/src/WorldStorage/NamespaceSerializer.h b/src/WorldStorage/NamespaceSerializer.h
index 6ec6bc6f7..f6095519b 100644
--- a/src/WorldStorage/NamespaceSerializer.h
+++ b/src/WorldStorage/NamespaceSerializer.h
@@ -23,4 +23,6 @@ namespace NamespaceSerializer
eMonsterType ToMonsterType(std::string_view a_ID);
std::pair<Namespace, std::string_view> SplitNamespacedID(std::string_view ID);
+
+ std::string_view Prettify(eMonsterType a_ID, bool a_IsTamed = false);
}