From a9be52c41a02d207233199e98898fe7483d7e817 Mon Sep 17 00:00:00 2001 From: ModMaker101 <119018978+ModMaker101@users.noreply.github.com> Date: Sat, 7 Mar 2026 21:56:03 -0500 Subject: 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 --- Minecraft.World/Fireball.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'Minecraft.World/Fireball.cpp') diff --git a/Minecraft.World/Fireball.cpp b/Minecraft.World/Fireball.cpp index 2a538b06..b520f436 100644 --- a/Minecraft.World/Fireball.cpp +++ b/Minecraft.World/Fireball.cpp @@ -127,10 +127,10 @@ Fireball::Fireball(Level *level, shared_ptr mob, double xa, double void Fireball::tick() { // 4J-PB - Moved forward from 1.2.3 - //if (!level->isClientSide && (owner == NULL || owner->removed)) + //if (!level->isClientSide && (owner == nullptr || owner->removed)) if (!level->isClientSide) { - if((owner != NULL && owner->removed) || !level->hasChunkAt((int) x, (int) y, (int) z)) + if((owner != nullptr && owner->removed) || !level->hasChunkAt(static_cast(x), static_cast(y), static_cast(z))) { app.DebugPrintf("Fireball removed - owner is null or removed is true for owner\n"); remove(); @@ -193,7 +193,7 @@ void Fireball::tick() from = Vec3::newTemp(x, y, z); to = Vec3::newTemp(x + xd, y + yd, z + zd); - if (res != NULL) + if (res != nullptr) { to = Vec3::newTemp(res->pos->x, res->pos->y, res->pos->z); } @@ -207,7 +207,7 @@ void Fireball::tick() float rr = 0.3f; AABB *bb = e->bb->grow(rr, rr, rr); HitResult *p = bb->clip(from, to); - if (p != NULL) + if (p != nullptr) { double dd = from->distanceTo(p->pos); if (dd < nearest || nearest == 0) @@ -220,14 +220,14 @@ void Fireball::tick() } - if (hitEntity != NULL) + if (hitEntity != nullptr) { delete res; res = new HitResult(hitEntity); } MemSect(0); - if (res != NULL) + if (res != nullptr) { onHit(res); } @@ -237,8 +237,8 @@ void Fireball::tick() z += zd; double sd = sqrt(xd * xd + zd * zd); - yRot = (float) (atan2(zd, xd) * 180 / PI) + 90; - xRot = (float) (atan2(sd, yd) * 180 / PI) - 90; + yRot = static_cast(atan2(zd, xd) * 180 / PI) + 90; + xRot = static_cast(atan2(sd, yd) * 180 / PI) - 90; while (xRot - xRotO < -180) xRotO -= 360; @@ -297,11 +297,11 @@ float Fireball::getInertia() void Fireball::addAdditonalSaveData(CompoundTag *tag) { - tag->putShort(L"xTile", (short) xTile); - tag->putShort(L"yTile", (short) yTile); - tag->putShort(L"zTile", (short) zTile); - tag->putByte(L"inTile", (byte) lastTile); - tag->putByte(L"inGround", (byte) (inGround ? 1 : 0)); + tag->putShort(L"xTile", static_cast(xTile)); + tag->putShort(L"yTile", static_cast(yTile)); + tag->putShort(L"zTile", static_cast(zTile)); + tag->putByte(L"inTile", static_cast(lastTile)); + tag->putByte(L"inGround", static_cast(inGround ? 1 : 0)); tag->put(L"direction", newDoubleList(3, xd, yd, zd)); } @@ -343,10 +343,10 @@ bool Fireball::hurt(DamageSource *source, float damage) if (isInvulnerable()) return false; markHurt(); - if (source->getEntity() != NULL) + if (source->getEntity() != nullptr) { Vec3 *lookAngle = source->getEntity()->getLookAngle(); - if (lookAngle != NULL) + if (lookAngle != nullptr) { xd = lookAngle->x; yd = lookAngle->y; -- cgit v1.2.3