summaryrefslogtreecommitdiffstats
path: root/src/World.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2020-09-12 20:57:44 +0200
committerGitHub <noreply@github.com>2020-09-12 20:57:44 +0200
commit93adbdce9a769b42baeb70f9ead5c7c6a35834b5 (patch)
treee0116770113a78af0d2d1c4d44a3878f551f0703 /src/World.cpp
parentfixed missing include for FreeBSD. (#4852) (diff)
downloadcuberite-93adbdce9a769b42baeb70f9ead5c7c6a35834b5.tar
cuberite-93adbdce9a769b42baeb70f9ead5c7c6a35834b5.tar.gz
cuberite-93adbdce9a769b42baeb70f9ead5c7c6a35834b5.tar.bz2
cuberite-93adbdce9a769b42baeb70f9ead5c7c6a35834b5.tar.lz
cuberite-93adbdce9a769b42baeb70f9ead5c7c6a35834b5.tar.xz
cuberite-93adbdce9a769b42baeb70f9ead5c7c6a35834b5.tar.zst
cuberite-93adbdce9a769b42baeb70f9ead5c7c6a35834b5.zip
Diffstat (limited to '')
-rw-r--r--src/World.cpp43
1 files changed, 5 insertions, 38 deletions
diff --git a/src/World.cpp b/src/World.cpp
index f5b64f297..d99c9c607 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -4,6 +4,7 @@
#include "World.h"
#include "BlockInfo.h"
#include "ClientHandle.h"
+#include "Physics/Explodinator.h"
#include "Server.h"
#include "Root.h"
#include "IniFile.h"
@@ -1393,47 +1394,13 @@ bool cWorld::ForEachFurnaceInChunk(int a_ChunkX, int a_ChunkZ, cFurnaceCallback
void cWorld::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_BlockY, double a_BlockZ, bool a_CanCauseFire, eExplosionSource a_Source, void * a_SourceData)
{
cLock Lock(*this);
- if (cPluginManager::Get()->CallHookExploding(*this, a_ExplosionSize, a_CanCauseFire, a_BlockX, a_BlockY, a_BlockZ, a_Source, a_SourceData) || (a_ExplosionSize <= 0))
- {
- return;
- }
-
- // TODO: Implement block hardiness
- cVector3iArray BlocksAffected;
- m_ChunkMap->DoExplosionAt(a_ExplosionSize, a_BlockX, a_BlockY, a_BlockZ, BlocksAffected);
- auto & Random = GetRandomProvider();
- auto SoundPitchMultiplier = 1.0f + (Random.RandReal(1.0f) - Random.RandReal(1.0f)) * 0.2f;
-
- BroadcastSoundEffect("entity.generic.explode", Vector3d(a_BlockX, a_BlockY, a_BlockZ), 4.0f, SoundPitchMultiplier * 0.7f);
-
- Vector3d ExplosionPos(a_BlockX, a_BlockY, a_BlockZ);
- for (auto Player : m_Players)
+ if (!cPluginManager::Get()->CallHookExploding(*this, a_ExplosionSize, a_CanCauseFire, a_BlockX, a_BlockY, a_BlockZ, a_Source, a_SourceData) && (a_ExplosionSize > 0))
{
- cClientHandle * ch = Player->GetClientHandle();
- if (ch == nullptr)
- {
- continue;
- }
-
- bool InRange = (Player->GetExplosionExposureRate(ExplosionPos, static_cast<float>(a_ExplosionSize)) > 0);
- auto Speed = InRange ? Player->GetSpeed() : Vector3d{};
- ch->SendExplosion({a_BlockX, a_BlockY, a_BlockZ}, static_cast<float>(a_ExplosionSize), BlocksAffected, Speed);
+ // TODO: CanCauseFire gets reset to false for some reason
+ Explodinator::Kaboom(*this, Vector3f(a_BlockX, a_BlockY, a_BlockZ), a_ExplosionSize, a_CanCauseFire);
+ cPluginManager::Get()->CallHookExploded(*this, a_ExplosionSize, a_CanCauseFire, a_BlockX, a_BlockY, a_BlockZ, a_Source, a_SourceData);
}
-
- auto Position = Vector3d(a_BlockX, a_BlockY - 0.5f, a_BlockZ);
- auto ParticleFormula = a_ExplosionSize * 0.33f;
- auto Spread = ParticleFormula * 0.5f;
- auto ParticleCount = std::min((ParticleFormula * 125), 600.0);
-
- BroadcastParticleEffect("largesmoke", Position, Vector3f{}, static_cast<float>(Spread), static_cast<int>(ParticleCount));
-
- Spread = ParticleFormula * 0.35f;
- ParticleCount = std::min((ParticleFormula * 550), 1800.0);
-
- BroadcastParticleEffect("explode", Position, Vector3f{}, static_cast<float>(Spread), static_cast<int>(ParticleCount));
-
- cPluginManager::Get()->CallHookExploded(*this, a_ExplosionSize, a_CanCauseFire, a_BlockX, a_BlockY, a_BlockZ, a_Source, a_SourceData);
}