aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/ParticleEngine.cpp
diff options
context:
space:
mode:
authorModMaker101 <119018978+ModMaker101@users.noreply.github.com>2026-03-08 19:08:36 -0400
committerGitHub <noreply@github.com>2026-03-08 18:08:36 -0500
commit28614b922fb77149a54da1a87bebfbc98736f296 (patch)
tree7f828ba86a4ee18d0a80d29de64f6199a5412512 /Minecraft.Client/ParticleEngine.cpp
parent88798b501d0cf6287b6f87acb2592676e3cec58d (diff)
Modernize project codebase (#906)
* 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 * Add safety checks and fix a issue with vector going OOR
Diffstat (limited to 'Minecraft.Client/ParticleEngine.cpp')
-rw-r--r--Minecraft.Client/ParticleEngine.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/Minecraft.Client/ParticleEngine.cpp b/Minecraft.Client/ParticleEngine.cpp
index 7fe26063..f8a8ec23 100644
--- a/Minecraft.Client/ParticleEngine.cpp
+++ b/Minecraft.Client/ParticleEngine.cpp
@@ -17,7 +17,7 @@ ResourceLocation ParticleEngine::PARTICLES_LOCATION = ResourceLocation(TN_PARTIC
ParticleEngine::ParticleEngine(Level *level, Textures *textures)
{
-// if (level != NULL) // 4J - removed - we want level to be initialised to *something*
+// if (level != nullptr) // 4J - removed - we want level to be initialised to *something*
{
this->level = level;
}
@@ -83,6 +83,11 @@ void ParticleEngine::tick()
void ParticleEngine::render(shared_ptr<Entity> player, float a, int list)
{
+ if (player == nullptr)
+ {
+ return;
+ }
+
// 4J - change brought forward from 1.2.3
float xa = Camera::xa;
float za = Camera::za;
@@ -188,8 +193,8 @@ void ParticleEngine::renderLit(shared_ptr<Entity> player, float a, int list)
void ParticleEngine::setLevel(Level *level)
{
this->level = level;
- // 4J - we've now got a set of particle vectors for each dimension, and only clearing them when its game over & the level is set to NULL
- if( level == NULL )
+ // 4J - we've now got a set of particle vectors for each dimension, and only clearing them when its game over & the level is set to nullptr
+ if( level == nullptr )
{
for( int l = 0; l < 3; l++ )
{
@@ -218,7 +223,7 @@ void ParticleEngine::destroy(int x, int y, int z, int tid, int data)
double yp = y + (yy + 0.5) / SD;
double zp = z + (zz + 0.5) / SD;
int face = random->nextInt(6);
- add(( shared_ptr<TerrainParticle>(new TerrainParticle(level, xp, yp, zp, xp - x - 0.5f, yp - y - 0.5f, zp - z - 0.5f, tile, face, data, textures) ) )->init(x, y, z, data));
+ add((std::make_shared<TerrainParticle>(level, xp, yp, zp, xp - x - 0.5f, yp - y - 0.5f, zp - z - 0.5f, tile, face, data, textures))->init(x, y, z, data));
}
}
@@ -237,7 +242,7 @@ void ParticleEngine::crack(int x, int y, int z, int face)
if (face == 3) zp = z + tile->getShapeZ1() + r;
if (face == 4) xp = x + tile->getShapeX0() - r;
if (face == 5) xp = x + tile->getShapeX1() + r;
- add(( shared_ptr<TerrainParticle>(new TerrainParticle(level, xp, yp, zp, 0, 0, 0, tile, face, level->getData(x, y, z), textures) ) )->init(x, y, z, level->getData(x, y, z))->setPower(0.2f)->scale(0.6f));
+ add((std::make_shared<TerrainParticle>(level, xp, yp, zp, 0, 0, 0, tile, face, level->getData(x, y, z), textures))->init(x, y, z, level->getData(x, y, z))->setPower(0.2f)->scale(0.6f));
}