diff options
| author | ModMaker101 <119018978+ModMaker101@users.noreply.github.com> | 2026-03-08 19:08:36 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-08 18:08:36 -0500 |
| commit | 28614b922fb77149a54da1a87bebfbc98736f296 (patch) | |
| tree | 7f828ba86a4ee18d0a80d29de64f6199a5412512 /Minecraft.World/WitherBoss.cpp | |
| parent | 88798b501d0cf6287b6f87acb2592676e3cec58d (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.World/WitherBoss.cpp')
| -rw-r--r-- | Minecraft.World/WitherBoss.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/Minecraft.World/WitherBoss.cpp b/Minecraft.World/WitherBoss.cpp index 84cf1382..af406a93 100644 --- a/Minecraft.World/WitherBoss.cpp +++ b/Minecraft.World/WitherBoss.cpp @@ -124,7 +124,7 @@ void WitherBoss::aiStep() if (!level->isClientSide && getAlternativeTarget(0) > 0) { shared_ptr<Entity> e = level->getEntity(getAlternativeTarget(0)); - if (e != NULL) + if (e != nullptr) { if ((y < e->y) || (!isPowered() && y < (e->y + 5))) { @@ -148,7 +148,7 @@ void WitherBoss::aiStep() } if ((xd * xd + zd * zd) > .05f) { - yRot = (float) atan2(zd, xd) * Mth::RADDEG - 90; + yRot = static_cast<float>(atan2(zd, xd)) * Mth::RADDEG - 90; } Monster::aiStep(); @@ -167,7 +167,7 @@ void WitherBoss::aiStep() { e = level->getEntity(entityId); } - if (e != NULL) + if (e != nullptr) { double hx = getHeadX(i + 1); double hy = getHeadY(i + 1); @@ -178,8 +178,8 @@ void WitherBoss::aiStep() double zd = e->z - hz; double sd = Mth::sqrt(xd * xd + zd * zd); - float yRotD = (float) (atan2(zd, xd) * 180 / PI) - 90; - float xRotD = (float) -(atan2(yd, sd) * 180 / PI); + float yRotD = static_cast<float>(atan2(zd, xd) * 180 / PI) - 90; + float xRotD = static_cast<float>(-(atan2(yd, sd) * 180 / PI)); xRotHeads[i] = rotlerp(xRotHeads[i], xRotD, 40); yRotHeads[i] = rotlerp(yRotHeads[i], yRotD, 10); @@ -221,7 +221,7 @@ void WitherBoss::newServerAiStep() if (newCount <= 0) { level->explode(shared_from_this(), x, y + getHeadHeight(), z, 7, false, level->getGameRules()->getBoolean(GameRules::RULE_MOBGRIEFING)); - level->globalLevelEvent(LevelEvent::SOUND_WITHER_BOSS_SPAWN, (int) x, (int) y, (int) z, 0); + level->globalLevelEvent(LevelEvent::SOUND_WITHER_BOSS_SPAWN, static_cast<int>(x), static_cast<int>(y), static_cast<int>(z), 0); } setInvulnerableTicks(newCount); @@ -258,7 +258,7 @@ void WitherBoss::newServerAiStep() shared_ptr<Entity> current = level->getEntity(headTarget); // 4J: Added check for instance of living entity, had a problem with IDs being recycled to other entities - if (current == NULL || !current->instanceof(eTYPE_LIVINGENTITY) || !current->isAlive() || distanceToSqr(current) > 30 * 30 || !canSee(current)) + if (current == nullptr || !current->instanceof(eTYPE_LIVINGENTITY) || !current->isAlive() || distanceToSqr(current) > 30 * 30 || !canSee(current)) { setAlternativeTarget(i, 0); } @@ -303,7 +303,7 @@ void WitherBoss::newServerAiStep() } } } - if (getTarget() != NULL) + if (getTarget() != nullptr) { assert(getTarget()->instanceof(eTYPE_LIVINGENTITY)); setAlternativeTarget(0, getTarget()->entityId); @@ -346,7 +346,7 @@ void WitherBoss::newServerAiStep() } if (destroyed) { - level->levelEvent(nullptr, LevelEvent::SOUND_ZOMBIE_DOOR_CRASH, (int) x, (int) y, (int) z, 0); + level->levelEvent(nullptr, LevelEvent::SOUND_ZOMBIE_DOOR_CRASH, static_cast<int>(x), static_cast<int>(y), static_cast<int>(z), 0); } } } @@ -427,7 +427,7 @@ void WitherBoss::performRangedAttack(int head, shared_ptr<LivingEntity> target) void WitherBoss::performRangedAttack(int head, double tx, double ty, double tz, bool dangerous) { - level->levelEvent(nullptr, LevelEvent::SOUND_WITHER_BOSS_SHOOT, (int) x, (int) y, (int) z, 0); + level->levelEvent(nullptr, LevelEvent::SOUND_WITHER_BOSS_SHOOT, static_cast<int>(x), static_cast<int>(y), static_cast<int>(z), 0); double hx = getHeadX(head); double hy = getHeadY(head); @@ -437,7 +437,7 @@ void WitherBoss::performRangedAttack(int head, double tx, double ty, double tz, double yd = ty - hy; double zd = tz - hz; - shared_ptr<WitherSkull> ie = shared_ptr<WitherSkull>( new WitherSkull(level, dynamic_pointer_cast<LivingEntity>(shared_from_this()), xd, yd, zd) ); + shared_ptr<WitherSkull> ie = std::make_shared<WitherSkull>(level, dynamic_pointer_cast<LivingEntity>(shared_from_this()), xd, yd, zd); if (dangerous) ie->setDangerous(true); ie->y = hy; ie->x = hx; @@ -462,14 +462,14 @@ bool WitherBoss::hurt(DamageSource *source, float dmg) if (isPowered()) { shared_ptr<Entity> directEntity = source->getDirectEntity(); - if (directEntity != NULL && directEntity->GetType() == eTYPE_ARROW) + if (directEntity != nullptr && directEntity->GetType() == eTYPE_ARROW) { return false; } } shared_ptr<Entity> sourceEntity = source->getEntity(); - if (sourceEntity != NULL) + if (sourceEntity != nullptr) { if ( sourceEntity->instanceof(eTYPE_PLAYER) ) { |
