Spawn eggs works again
This commit is contained in:
parent
e35ac1bfb9
commit
fc49ace897
@ -28,39 +28,40 @@ static const struct
|
|||||||
eMonsterType m_Type;
|
eMonsterType m_Type;
|
||||||
const char * m_lcName;
|
const char * m_lcName;
|
||||||
const char * m_VanillaName;
|
const char * m_VanillaName;
|
||||||
|
const char * m_VanillaNameNBT;
|
||||||
} g_MobTypeNames[] =
|
} g_MobTypeNames[] =
|
||||||
{
|
{
|
||||||
{mtBat, "bat", "Bat"},
|
{mtBat, "bat", "Bat", "bat"},
|
||||||
{mtBlaze, "blaze", "Blaze"},
|
{mtBlaze, "blaze", "Blaze", "blaze"},
|
||||||
{mtCaveSpider, "cavespider", "CaveSpider"},
|
{mtCaveSpider, "cavespider", "CaveSpider", "cave_spider"},
|
||||||
{mtChicken, "chicken", "Chicken"},
|
{mtChicken, "chicken", "Chicken", "chicken"},
|
||||||
{mtCow, "cow", "Cow"},
|
{mtCow, "cow", "Cow", "cow"},
|
||||||
{mtCreeper, "creeper", "Creeper"},
|
{mtCreeper, "creeper", "Creeper", "creeper"},
|
||||||
{mtEnderman, "enderman", "Enderman"},
|
{mtEnderman, "enderman", "Enderman", "enderman"},
|
||||||
{mtEnderDragon, "enderdragon", "EnderDragon"},
|
{mtEnderDragon, "enderdragon", "EnderDragon", "ender_dragon"},
|
||||||
{mtGhast, "ghast", "Ghast"},
|
{mtGhast, "ghast", "Ghast", "ghast"},
|
||||||
{mtGiant, "giant", "Giant"},
|
{mtGiant, "giant", "Giant", "giant"},
|
||||||
{mtGuardian, "guardian", "Guardian"},
|
{mtGuardian, "guardian", "Guardian", "guardian"},
|
||||||
{mtHorse, "horse", "EntityHorse"},
|
{mtHorse, "horse", "EntityHorse", "horse"},
|
||||||
{mtIronGolem, "irongolem", "VillagerGolem"},
|
{mtIronGolem, "irongolem", "VillagerGolem", "iron_golem"},
|
||||||
{mtMagmaCube, "magmacube", "LavaSlime"},
|
{mtMagmaCube, "magmacube", "LavaSlime", "magma_cube"},
|
||||||
{mtMooshroom, "mooshroom", "MushroomCow"},
|
{mtMooshroom, "mooshroom", "MushroomCow", "mooshroom"},
|
||||||
{mtOcelot, "ocelot", "Ozelot"},
|
{mtOcelot, "ocelot", "Ozelot", "ocelot"},
|
||||||
{mtPig, "pig", "Pig"},
|
{mtPig, "pig", "Pig", "pig"},
|
||||||
{mtRabbit, "rabbit", "Rabbit"},
|
{mtRabbit, "rabbit", "Rabbit", "rabbit"},
|
||||||
{mtSheep, "sheep", "Sheep"},
|
{mtSheep, "sheep", "Sheep", "sheep"},
|
||||||
{mtSilverfish, "silverfish", "Silverfish"},
|
{mtSilverfish, "silverfish", "Silverfish", "silverfish"},
|
||||||
{mtSkeleton, "skeleton", "Skeleton"},
|
{mtSkeleton, "skeleton", "Skeleton", "skeleton"},
|
||||||
{mtSlime, "slime", "Slime"},
|
{mtSlime, "slime", "Slime", "slime"},
|
||||||
{mtSnowGolem, "snowgolem", "SnowMan"},
|
{mtSnowGolem, "snowgolem", "SnowMan", "snow_golem"},
|
||||||
{mtSpider, "spider", "Spider"},
|
{mtSpider, "spider", "Spider", "spider"},
|
||||||
{mtSquid, "squid", "Squid"},
|
{mtSquid, "squid", "Squid", "squid"},
|
||||||
{mtVillager, "villager", "Villager"},
|
{mtVillager, "villager", "Villager", "villager"},
|
||||||
{mtWitch, "witch", "Witch"},
|
{mtWitch, "witch", "Witch", "witch"},
|
||||||
{mtWither, "wither", "WitherBoss"},
|
{mtWither, "wither", "WitherBoss", "wither"},
|
||||||
{mtWolf, "wolf", "Wolf"},
|
{mtWolf, "wolf", "Wolf", "wolf"},
|
||||||
{mtZombie, "zombie", "Zombie"},
|
{mtZombie, "zombie", "Zombie", "zombie"},
|
||||||
{mtZombiePigman, "zombiepigman", "PigZombie"},
|
{mtZombiePigman, "zombiepigman", "PigZombie", "zombie_pigman"},
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
||||||
@ -826,6 +827,25 @@ AString cMonster::MobTypeToVanillaName(eMonsterType a_MobType)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AString cMonster::MobTypeToVanillaNBT(eMonsterType a_MobType)
|
||||||
|
{
|
||||||
|
// Mob types aren't sorted, so we need to search linearly:
|
||||||
|
for (size_t i = 0; i < ARRAYCOUNT(g_MobTypeNames); i++)
|
||||||
|
{
|
||||||
|
if (g_MobTypeNames[i].m_Type == a_MobType)
|
||||||
|
{
|
||||||
|
return g_MobTypeNames[i].m_VanillaNameNBT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not found:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
eMonsterType cMonster::StringToMobType(const AString & a_Name)
|
eMonsterType cMonster::StringToMobType(const AString & a_Name)
|
||||||
{
|
{
|
||||||
AString lcName = StrToLower(a_Name);
|
AString lcName = StrToLower(a_Name);
|
||||||
@ -848,6 +868,15 @@ eMonsterType cMonster::StringToMobType(const AString & a_Name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Search in NBT name
|
||||||
|
for (size_t i = 0; i < ARRAYCOUNT(g_MobTypeNames); i++)
|
||||||
|
{
|
||||||
|
if (strcmp(StrToLower(g_MobTypeNames[i].m_VanillaNameNBT).c_str(), lcName.c_str()) == 0)
|
||||||
|
{
|
||||||
|
return g_MobTypeNames[i].m_Type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Not found:
|
// Not found:
|
||||||
return mtInvalidType;
|
return mtInvalidType;
|
||||||
}
|
}
|
||||||
|
@ -160,6 +160,9 @@ public:
|
|||||||
|
|
||||||
// tolua_end
|
// tolua_end
|
||||||
|
|
||||||
|
/** Translates the MobType enum to the vanilla nbt name */
|
||||||
|
static AString MobTypeToVanillaNBT(eMonsterType a_MobType);
|
||||||
|
|
||||||
/** Sets the target that this mob will chase. Pass a nullptr to unset. */
|
/** Sets the target that this mob will chase. Pass a nullptr to unset. */
|
||||||
void SetTarget (cPawn * a_NewTarget);
|
void SetTarget (cPawn * a_NewTarget);
|
||||||
|
|
||||||
|
@ -2995,9 +2995,11 @@ void cProtocol_1_9_0::ParseItemMetadata(cItem & a_Item, const AString & a_Metada
|
|||||||
{
|
{
|
||||||
if ((NBT.GetType(entitytag) == TAG_String) && (NBT.GetName(entitytag) == "id"))
|
if ((NBT.GetType(entitytag) == TAG_String) && (NBT.GetName(entitytag) == "id"))
|
||||||
{
|
{
|
||||||
eMonsterType MonsterType = cMonster::StringToMobType(NBT.GetString(entitytag));
|
AString NBTName = NBT.GetString(entitytag);
|
||||||
// No special method here to convert to the numeric damage value; just cast to the given ID
|
ReplaceString(NBTName, "minecraft:", "");
|
||||||
|
eMonsterType MonsterType = cMonster::StringToMobType(NBTName);
|
||||||
a_Item.m_ItemDamage = static_cast<short>(MonsterType);
|
a_Item.m_ItemDamage = static_cast<short>(MonsterType);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3395,7 +3397,7 @@ void cProtocol_1_9_0::WriteItem(cPacketizer & a_Pkt, const cItem & a_Item)
|
|||||||
if (MonsterType != eMonsterType::mtInvalidType)
|
if (MonsterType != eMonsterType::mtInvalidType)
|
||||||
{
|
{
|
||||||
Writer.BeginCompound("EntityTag");
|
Writer.BeginCompound("EntityTag");
|
||||||
Writer.AddString("id", cMonster::MobTypeToVanillaName(MonsterType));
|
Writer.AddString("id", "minecraft:" + cMonster::MobTypeToVanillaNBT(MonsterType));
|
||||||
Writer.EndCompound();
|
Writer.EndCompound();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user