summaryrefslogtreecommitdiffstats
path: root/src/Entities
diff options
context:
space:
mode:
Diffstat (limited to 'src/Entities')
-rw-r--r--src/Entities/Entity.cpp26
-rw-r--r--src/Entities/Entity.h23
-rw-r--r--src/Entities/HangingEntity.h1
-rw-r--r--src/Entities/Player.cpp25
4 files changed, 53 insertions, 22 deletions
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index 108f79e82..bb9d3c44b 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -744,6 +744,13 @@ void cEntity::KilledBy(TakeDamageInfo & a_TDI)
return;
}
+ // If the victim is a player the hook is handled by the cPlayer class
+ if (!IsPlayer())
+ {
+ AString emptystring = AString("");
+ cRoot::Get()->GetPluginManager()->CallHookKilled(*this, a_TDI, emptystring);
+ }
+
// Drop loot:
cItems Drops;
GetDrops(Drops, a_TDI.Attacker);
@@ -1262,11 +1269,12 @@ void cEntity::DetectCacti(void)
-void cEntity::ScheduleMoveToWorld(cWorld * a_World, Vector3d a_NewPosition)
+void cEntity::ScheduleMoveToWorld(cWorld * a_World, Vector3d a_NewPosition, bool a_SetPortalCooldown)
{
m_NewWorld = a_World;
m_NewWorldPosition = a_NewPosition;
m_IsWorldChangeScheduled = true;
+ m_WorldChangeSetPortalCooldown = a_SetPortalCooldown;
}
@@ -1278,6 +1286,14 @@ bool cEntity::DetectPortal()
if (m_IsWorldChangeScheduled)
{
m_IsWorldChangeScheduled = false;
+
+ if (m_WorldChangeSetPortalCooldown)
+ {
+ // Delay the portal check.
+ m_PortalCooldownData.m_TicksDelayed = 0;
+ m_PortalCooldownData.m_ShouldPreventTeleportation = true;
+ }
+
MoveToWorld(m_NewWorld, false, m_NewWorldPosition);
return true;
}
@@ -1336,10 +1352,10 @@ bool cEntity::DetectPortal()
TargetPos.x *= 8.0;
TargetPos.z *= 8.0;
- cWorld * TargetWorld = cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetLinkedOverworldName(), dimNether, GetWorld()->GetName());
+ cWorld * TargetWorld = cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetLinkedOverworldName(), dimNether, GetWorld()->GetName(), false);
LOGD("Jumping nether -> overworld");
new cNetherPortalScanner(this, TargetWorld, TargetPos, 256);
- return false;
+ return true;
}
else
{
@@ -1360,10 +1376,10 @@ bool cEntity::DetectPortal()
TargetPos.x /= 8.0;
TargetPos.z /= 8.0;
- cWorld * TargetWorld = cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetLinkedNetherWorldName(), dimNether, GetWorld()->GetName());
+ cWorld * TargetWorld = cRoot::Get()->CreateAndInitializeWorld(GetWorld()->GetLinkedNetherWorldName(), dimNether, GetWorld()->GetName(), false);
LOGD("Jumping overworld -> nether");
new cNetherPortalScanner(this, TargetWorld, TargetPos, 128);
- return false;
+ return true;
}
}
case E_BLOCK_END_PORTAL:
diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h
index 8d1d62ddf..f54e130eb 100644
--- a/src/Entities/Entity.h
+++ b/src/Entities/Entity.h
@@ -350,31 +350,31 @@ public:
*/
virtual bool DetectPortal(void);
- /// Handles when the entity is in the void
+ /** Handles when the entity is in the void */
virtual void TickInVoid(cChunk & a_Chunk);
- /// Called when the entity starts burning
+ /** Called when the entity starts burning */
virtual void OnStartedBurning(void);
- /// Called when the entity finishes burning
+ /** Called when the entity finishes burning */
virtual void OnFinishedBurning(void);
// tolua_begin
- /// Sets the maximum value for the health
+ /** Sets the maximum value for the health */
void SetMaxHealth(int a_MaxHealth);
int GetMaxHealth(void) const { return m_MaxHealth; }
- /// Sets whether the entity is fireproof
+ /** Sets whether the entity is fireproof */
void SetIsFireproof(bool a_IsFireproof);
bool IsFireproof(void) const { return m_IsFireproof; }
- /// Puts the entity on fire for the specified amount of ticks
+ /** Puts the entity on fire for the specified amount of ticks */
void StartBurning(int a_TicksLeftBurning);
- /// Stops the entity from burning, resets all burning timers
+ /** Stops the entity from burning, resets all burning timers */
void StopBurning(void);
// tolua_end
@@ -386,14 +386,14 @@ public:
// tolua_begin
- /// Teleports to the entity specified
+ /** Teleports to the entity specified */
virtual void TeleportToEntity(cEntity & a_Entity);
- /// Teleports to the coordinates specified
+ /** Teleports to the coordinates specified */
virtual void TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ);
- /// Schedules a MoveToWorld call to occur on the next Tick of the entity
- void ScheduleMoveToWorld(cWorld * a_World, Vector3d a_NewPosition);
+ /** Schedules a MoveToWorld call to occur on the next Tick of the entity */
+ void ScheduleMoveToWorld(cWorld * a_World, Vector3d a_NewPosition, bool a_SetPortalCooldown = false);
bool MoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn, Vector3d a_NewPosition) { return DoMoveToWorld(a_World, a_ShouldSendRespawn, a_NewPosition); }
@@ -538,6 +538,7 @@ protected:
/** State variables for ScheduleMoveToWorld. */
bool m_IsWorldChangeScheduled;
+ bool m_WorldChangeSetPortalCooldown;
cWorld * m_NewWorld;
Vector3d m_NewWorldPosition;
diff --git a/src/Entities/HangingEntity.h b/src/Entities/HangingEntity.h
index 5d0aa17b3..003c22082 100644
--- a/src/Entities/HangingEntity.h
+++ b/src/Entities/HangingEntity.h
@@ -103,6 +103,7 @@ protected:
// ASSERT(!"Tried to convert a bad facing!");
Dir = cHangingEntity::BlockFaceToProtocolFace(BLOCK_FACE_XP);
+ break;
}
#if !defined(__clang__)
default:
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 0ca560d75..97e2eca3a 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -920,11 +920,11 @@ void cPlayer::KilledBy(TakeDamageInfo & a_TDI)
{
Pickups.Add(cItem(E_ITEM_RED_APPLE));
}
-
m_Stats.AddValue(statItemsDropped, (StatValue)Pickups.Size());
m_World->SpawnItemPickups(Pickups, GetPosX(), GetPosY(), GetPosZ(), 10);
SaveToDisk(); // Save it, yeah the world is a tough place !
+ cPluginManager * PluginManager = cRoot::Get()->GetPluginManager();
if ((a_TDI.Attacker == nullptr) && m_World->ShouldBroadcastDeathMessages())
{
@@ -950,7 +950,12 @@ void cPlayer::KilledBy(TakeDamageInfo & a_TDI)
case dtExplosion: DamageText = "blew up"; break;
default: DamageText = "died, somehow; we've no idea how though"; break;
}
- GetWorld()->BroadcastChatDeath(Printf("%s %s", GetName().c_str(), DamageText.c_str()));
+ AString DeathMessage = Printf("%s %s", GetName().c_str(), DamageText.c_str());
+ PluginManager->CallHookKilled(*this, a_TDI, DeathMessage);
+ if (DeathMessage != AString(""))
+ {
+ GetWorld()->BroadcastChatDeath(DeathMessage);
+ }
}
else if (a_TDI.Attacker == nullptr) // && !m_World->ShouldBroadcastDeathMessages() by fallthrough
{
@@ -959,15 +964,23 @@ void cPlayer::KilledBy(TakeDamageInfo & a_TDI)
else if (a_TDI.Attacker->IsPlayer())
{
cPlayer * Killer = (cPlayer *)a_TDI.Attacker;
-
- GetWorld()->BroadcastChatDeath(Printf("%s was killed by %s", GetName().c_str(), Killer->GetName().c_str()));
+ AString DeathMessage = Printf("%s was killed by %s", GetName().c_str(), Killer->GetName().c_str());
+ PluginManager->CallHookKilled(*this, a_TDI, DeathMessage);
+ if (DeathMessage != AString(""))
+ {
+ GetWorld()->BroadcastChatDeath(DeathMessage);
+ }
}
else
{
AString KillerClass = a_TDI.Attacker->GetClass();
KillerClass.erase(KillerClass.begin()); // Erase the 'c' of the class (e.g. "cWitch" -> "Witch")
-
- GetWorld()->BroadcastChatDeath(Printf("%s was killed by a %s", GetName().c_str(), KillerClass.c_str()));
+ AString DeathMessage = Printf("%s was killed by a %s", GetName().c_str(), KillerClass.c_str());
+ PluginManager->CallHookKilled(*this, a_TDI, DeathMessage);
+ if (DeathMessage != AString(""))
+ {
+ GetWorld()->BroadcastChatDeath(DeathMessage);
+ }
}
m_Stats.AddValue(statDeaths);