aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/Explosion.cpp
diff options
context:
space:
mode:
authorModMaker101 <119018978+ModMaker101@users.noreply.github.com>2026-03-07 21:56:03 -0500
committerGitHub <noreply@github.com>2026-03-08 09:56:03 +0700
commita9be52c41a02d207233199e98898fe7483d7e817 (patch)
tree71dfaec3a86b05e9ca409b97d8eb9d7f993bfdd0 /Minecraft.World/Explosion.cpp
parent1be5faaea781402e7de06b263eeca4c688b7712c (diff)
Project modernization (#630)
* Fixed boats falling and a TP glitch #266 * Replaced every C-style cast with C++ ones * Replaced every C-style cast with C++ ones * Fixed boats falling and a TP glitch #266 * Updated NULL to nullptr and fixing some type issues * Modernized and fixed a few bugs - Replaced most instances of `NULL` with `nullptr`. - Replaced most `shared_ptr(new ...)` with `make_shared`. - Removed the `nullptr` macro as it was interfering with the actual nullptr keyword in some instances. * Fixing more conflicts * Replace int loops with size_t and start work on overrides
Diffstat (limited to 'Minecraft.World/Explosion.cpp')
-rw-r--r--Minecraft.World/Explosion.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/Minecraft.World/Explosion.cpp b/Minecraft.World/Explosion.cpp
index ab305a02..65e719e4 100644
--- a/Minecraft.World/Explosion.cpp
+++ b/Minecraft.World/Explosion.cpp
@@ -72,10 +72,10 @@ void Explosion::explode()
if (t > 0)
{
Tile *tile = Tile::tiles[t];
- float resistance = source != NULL ? source->getTileExplosionResistance(this, level, xt, yt, zt, tile) : tile->getExplosionResistance(source);
+ float resistance = source != nullptr ? source->getTileExplosionResistance(this, level, xt, yt, zt, tile) : tile->getExplosionResistance(source);
remainingPower -= (resistance + 0.3f) * stepSize;
}
- if (remainingPower > 0&& (source == NULL || source->shouldTileExplode(this, level, xt, yt, zt, t, remainingPower)))
+ if (remainingPower > 0&& (source == nullptr || source->shouldTileExplode(this, level, xt, yt, zt, t, remainingPower)))
{
toBlow.insert(TilePos(xt, yt, zt));
}
@@ -143,7 +143,7 @@ void Explosion::explode()
double sp = level->getSeenPercent(center, e->bb);
double pow = (1 - dist) * sp;
- if(canDamage) e->hurt(DamageSource::explosion(this), (int) ((pow * pow + pow) / 2 * 8 * r + 1));
+ if(canDamage) e->hurt(DamageSource::explosion(this), static_cast<int>((pow * pow + pow) / 2 * 8 * r + 1));
double kbPower = ProtectionEnchantment::getExplosionKnockbackAfterDampener(e, pow);
e->xd += xa *kbPower;
@@ -163,7 +163,7 @@ void Explosion::explode()
}
-void Explosion::finalizeExplosion(bool generateParticles, vector<TilePos> *toBlowDirect/*=NULL*/) // 4J - added toBlowDirect parameter
+void Explosion::finalizeExplosion(bool generateParticles, vector<TilePos> *toBlowDirect/*=nullptr*/) // 4J - added toBlowDirect parameter
{
level->playSound(x, y, z, eSoundType_RANDOM_EXPLODE, 4, (1 + (level->random->nextFloat() - level->random->nextFloat()) * 0.2f) * 0.7f);
if (r < 2 || !destroyBlocks)
@@ -185,7 +185,7 @@ void Explosion::finalizeExplosion(bool generateParticles, vector<TilePos> *toBlo
app.DebugPrintf("Finalizing explosion size %d\n",toBlow.size());
static const int MAX_EXPLODE_PARTICLES = 50;
// 4J - try and make at most MAX_EXPLODE_PARTICLES pairs of particles
- int fraction = (int)toBlowArray->size() / MAX_EXPLODE_PARTICLES;
+ int fraction = static_cast<int>(toBlowArray->size()) / MAX_EXPLODE_PARTICLES;
if( fraction == 0 ) fraction = 1;
size_t j = toBlowArray->size() - 1;
//for (size_t j = toBlowArray->size() - 1; j >= 0; j--)
@@ -262,7 +262,7 @@ void Explosion::finalizeExplosion(bool generateParticles, vector<TilePos> *toBlo
}
PIXEndNamedEvent();
- if( toBlowDirect == NULL ) delete toBlowArray;
+ if( toBlowDirect == nullptr ) delete toBlowArray;
}
Explosion::playerVec3Map *Explosion::getHitPlayers()
@@ -281,7 +281,7 @@ Vec3 *Explosion::getHitPlayerKnockback( shared_ptr<Player> player )
shared_ptr<LivingEntity> Explosion::getSourceMob()
{
- if (source == NULL) return nullptr;
+ if (source == nullptr) return nullptr;
if (source->instanceof(eTYPE_PRIMEDTNT)) return dynamic_pointer_cast<PrimedTnt>(source)->getOwner();
if (source->instanceof(eTYPE_LIVINGENTITY)) return dynamic_pointer_cast<LivingEntity>(source);
return nullptr;