From 28614b922fb77149a54da1a87bebfbc98736f296 Mon Sep 17 00:00:00 2001 From: ModMaker101 <119018978+ModMaker101@users.noreply.github.com> Date: Sun, 8 Mar 2026 19:08:36 -0400 Subject: 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 --- Minecraft.World/ExperienceOrb.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'Minecraft.World/ExperienceOrb.cpp') diff --git a/Minecraft.World/ExperienceOrb.cpp b/Minecraft.World/ExperienceOrb.cpp index 9fed6d71..cc4b12bc 100644 --- a/Minecraft.World/ExperienceOrb.cpp +++ b/Minecraft.World/ExperienceOrb.cpp @@ -35,11 +35,11 @@ ExperienceOrb::ExperienceOrb(Level *level, double x, double y, double z, int cou heightOffset = bbHeight / 2.0f; setPos(x, y, z); - yRot = (float) (Math::random() * 360); + yRot = static_cast(Math::random() * 360); - xd = (float) (Math::random() * 0.2f - 0.1f) * 2; - yd = (float) (Math::random() * 0.2) * 2; - zd = (float) (Math::random() * 0.2f - 0.1f) * 2; + xd = static_cast(Math::random() * 0.2f - 0.1f) * 2; + yd = static_cast(Math::random() * 0.2) * 2; + zd = static_cast(Math::random() * 0.2f - 0.1f) * 2; value = count; } @@ -70,7 +70,7 @@ int ExperienceOrb::getLightColor(float a) int br1 = (br) & 0xff; int br2 = (br >> 16) & 0xff; - br1 += (int) (l * 15 * 16); + br1 += static_cast(l * 15 * 16); if (br1 > 15 * 16) br1 = 15 * 16; // br2 = 15*16; return br1 | br2 << 16; @@ -99,13 +99,13 @@ void ExperienceOrb::tick() // Usually exp orbs will get created at the same time so smoothen the lagspikes if (followingTime < tickCount - SharedConstants::TICKS_PER_SECOND + (entityId % 100)) { - if (followingPlayer == NULL || followingPlayer->distanceToSqr(shared_from_this()) > maxDist * maxDist) + if (followingPlayer == nullptr || followingPlayer->distanceToSqr(shared_from_this()) > maxDist * maxDist) { followingPlayer = level->getNearestPlayer(shared_from_this(), maxDist); } followingTime = tickCount; } - if (followingPlayer != NULL) + if (followingPlayer != nullptr) { double xdd = (followingPlayer->x - x) / maxDist; double ydd = (followingPlayer->y + followingPlayer->getHeadHeight() - y) / maxDist; @@ -176,9 +176,9 @@ bool ExperienceOrb::hurt(DamageSource *source, float damage) void ExperienceOrb::addAdditonalSaveData(CompoundTag *entityTag) { - entityTag->putShort(L"Health", (byte) health); - entityTag->putShort(L"Age", (short) age); - entityTag->putShort(L"Value", (short) value); + entityTag->putShort(L"Health", static_cast(health)); + entityTag->putShort(L"Age", static_cast(age)); + entityTag->putShort(L"Value", static_cast(value)); } void ExperienceOrb::readAdditionalSaveData(CompoundTag *tag) -- cgit v1.2.3