diff options
author | Kingsley Collie <kingsleydgs@gmail.com> | 2021-12-18 14:55:20 +0100 |
---|---|---|
committer | Alexander Harkness <me@bearbin.net> | 2021-12-18 21:46:03 +0100 |
commit | a9e111678a3eab1fade8e9785c4d169bbc8e1c36 (patch) | |
tree | 629decf3011147a71f31e17f3b282c3f0f0b2a00 /src | |
parent | Expand log4j mitigiation to cover more cases. (diff) | |
download | cuberite-a9e111678a3eab1fade8e9785c4d169bbc8e1c36.tar cuberite-a9e111678a3eab1fade8e9785c4d169bbc8e1c36.tar.gz cuberite-a9e111678a3eab1fade8e9785c4d169bbc8e1c36.tar.bz2 cuberite-a9e111678a3eab1fade8e9785c4d169bbc8e1c36.tar.lz cuberite-a9e111678a3eab1fade8e9785c4d169bbc8e1c36.tar.xz cuberite-a9e111678a3eab1fade8e9785c4d169bbc8e1c36.tar.zst cuberite-a9e111678a3eab1fade8e9785c4d169bbc8e1c36.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Mobs/Slime.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/Mobs/Slime.cpp b/src/Mobs/Slime.cpp index 05ef188f2..f2b16f071 100644 --- a/src/Mobs/Slime.cpp +++ b/src/Mobs/Slime.cpp @@ -71,6 +71,7 @@ void cSlime::KilledBy(TakeDamageInfo & a_TDI) if (m_Size != 1) { + // Queue slimes to be spawned after death animation delay: auto & Random = GetRandomProvider(); int SpawnAmount = Random.RandInt(2, 4); @@ -79,10 +80,18 @@ void cSlime::KilledBy(TakeDamageInfo & a_TDI) double AddX = (i % 2 - 0.5) * m_Size / 4.0; double AddZ = (i / 2 - 0.5) * m_Size / 4.0; - auto NewSlime = std::make_unique<cSlime>(m_Size / 2); - NewSlime->SetPosition(GetPosX() + AddX, GetPosY() + 0.5, GetPosZ() + AddZ); - NewSlime->SetYaw(Random.RandReal(360.0f)); - m_World->SpawnMobFinalize(std::move(NewSlime)); + Vector3d SpawnPos(GetPosX() + AddX, GetPosY() + 0.5, GetPosZ() + AddZ); + double Yaw = Random.RandReal(360.0f); + int Size = m_Size/2; + auto lambda = [SpawnPos, Yaw, Size](cWorld &a_World) + { + auto NewSlime = std::make_unique<cSlime>(Size); + NewSlime->SetPosition(SpawnPos); + NewSlime->SetYaw(Yaw); + a_World.SpawnMobFinalize(std::move(NewSlime)); + }; + cTickTime DelayTime(20); + m_World->ScheduleTask(DelayTime, lambda); } } Super::KilledBy(a_TDI); |