fix: correct the condition for adding ".player"
This commit is contained in:
+11
-9
@@ -20,8 +20,8 @@ bool isCrystal = false;
|
|||||||
|
|
||||||
std::string getCause(SharedTypes::Legacy::ActorDamageCause cause) {
|
std::string getCause(SharedTypes::Legacy::ActorDamageCause cause) {
|
||||||
auto id = (int)cause;
|
auto id = (int)cause;
|
||||||
if (mVanillaCauseMessage.count(id))
|
if (mVanillaCauseMessage.count(id)){return std::string(mVanillaCauseMessage[id]);}
|
||||||
return std::string(mVanillaCauseMessage[id]);
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,8 +32,8 @@ Actor* getDamagingEntity(ActorDamageSource* ads) {
|
|||||||
|
|
||||||
// %entity.warden.name
|
// %entity.warden.name
|
||||||
std::string getResourcePackKey(std::string const& name, Actor* ac) {
|
std::string getResourcePackKey(std::string const& name, Actor* ac) {
|
||||||
if (ac->hasCategory(ActorCategory::Player))
|
if (ac->hasCategory(ActorCategory::Player)){return name;}
|
||||||
return name;
|
|
||||||
auto type = ac->getTypeName();
|
auto type = ac->getTypeName();
|
||||||
ll::utils::string_utils::replaceAll(type, "minecraft:", "");
|
ll::utils::string_utils::replaceAll(type, "minecraft:", "");
|
||||||
std::string res = "%entity." + type + ".name";
|
std::string res = "%entity." + type + ".name";
|
||||||
@@ -54,15 +54,14 @@ DeathMessageResult makeDeathMessage(
|
|||||||
if (cause >= 35||mVanillaCauseMessage.count(cause) || isHardCodedMessage) {
|
if (cause >= 35||mVanillaCauseMessage.count(cause) || isHardCodedMessage) {
|
||||||
std::string msg = "death.attack.damageCause.item";
|
std::string msg = "death.attack.damageCause.item";
|
||||||
ll::utils::string_utils::replaceAll(msg, "damageCause", getCause(SharedTypes::Legacy::ActorDamageCause(cause)));
|
ll::utils::string_utils::replaceAll(msg, "damageCause", getCause(SharedTypes::Legacy::ActorDamageCause(cause)));
|
||||||
if (isHardCodedMessage)
|
if (isHardCodedMessage) {
|
||||||
msg = deathMessage.first;
|
msg = deathMessage.first;}
|
||||||
|
|
||||||
// 没有武器名不使用.item结尾
|
// 没有武器名不使用.item结尾
|
||||||
if (weaponName.empty()) {
|
if (weaponName.empty()) {
|
||||||
// 试图逃离 xx 使用.player
|
// 试图逃离 xx 使用.player
|
||||||
if (killer) {
|
if (killer) {
|
||||||
if (isEscaping)
|
if (isEscaping){ll::utils::string_utils::replaceAll(msg, ".item", ".player");}
|
||||||
ll::utils::string_utils::replaceAll(msg, ".item", ".player");
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
ll::utils::string_utils::replaceAll(msg, ".item", "");
|
ll::utils::string_utils::replaceAll(msg, ".item", "");
|
||||||
@@ -216,8 +215,11 @@ DeathMessageResult translateDeathMessage(DeathMessageResult origin, std::string
|
|||||||
killer = getDamagingEntity(ads);
|
killer = getDamagingEntity(ads);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (killer == nullptr && mHurtByEntityMap.count(uid)) {
|
if (mHurtByEntityMap.count(uid)) {
|
||||||
|
if (killer == nullptr) {
|
||||||
killer = ll::service::getLevel()->fetchEntity(mHurtByEntityMap[uid],true);
|
killer = ll::service::getLevel()->fetchEntity(mHurtByEntityMap[uid],true);
|
||||||
|
|
||||||
|
}
|
||||||
isEscaping = true;
|
isEscaping = true;
|
||||||
}
|
}
|
||||||
if (killer != nullptr) {
|
if (killer != nullptr) {
|
||||||
|
|||||||
Reference in New Issue
Block a user