diff options
| author | void_17 <61356189+void2012@users.noreply.github.com> | 2026-03-06 02:11:18 +0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-06 02:11:18 +0700 |
| commit | 55231bb8d3e1a4e2752ac3d444c4287eb0ca4e8b (patch) | |
| tree | 953c537a5c66e328e9f4ab29626cf738112d53c0 /Minecraft.World/EnderDragon.cpp | |
| parent | 7d6658fe5b3095f35093701b5ab669ffc291e875 (diff) | |
Remove AUTO_VAR macro and _toString function (#592)
Diffstat (limited to 'Minecraft.World/EnderDragon.cpp')
| -rw-r--r-- | Minecraft.World/EnderDragon.cpp | 80 |
1 files changed, 44 insertions, 36 deletions
diff --git a/Minecraft.World/EnderDragon.cpp b/Minecraft.World/EnderDragon.cpp index 2dc0c434..e1dea172 100644 --- a/Minecraft.World/EnderDragon.cpp +++ b/Minecraft.World/EnderDragon.cpp @@ -444,13 +444,16 @@ void EnderDragon::aiStep() { vector<shared_ptr<Entity> > *targets = level->getEntities(shared_from_this(), m_acidArea); - for( AUTO_VAR(it, targets->begin() ); it != targets->end(); ++it) + if ( targets ) { - if ( (*it)->instanceof(eTYPE_LIVINGENTITY) ) + for (auto& it : *targets ) { - //app.DebugPrintf("Attacking entity with acid\n"); - shared_ptr<LivingEntity> e = dynamic_pointer_cast<LivingEntity>( *it ); - e->hurt(DamageSource::dragonbreath, 2); + if ( it->instanceof(eTYPE_LIVINGENTITY)) + { + //app.DebugPrintf("Attacking entity with acid\n"); + shared_ptr<LivingEntity> e = dynamic_pointer_cast<LivingEntity>(it); + e->hurt(DamageSource::dragonbreath, 2); + } } } } @@ -796,24 +799,23 @@ void EnderDragon::checkCrystals() { float maxDist = 32; vector<shared_ptr<Entity> > *crystals = level->getEntitiesOfClass(typeid(EnderCrystal), bb->grow(maxDist, maxDist, maxDist)); - - shared_ptr<EnderCrystal> crystal = nullptr; - double nearest = Double::MAX_VALUE; - //for (Entity ec : crystals) - for(AUTO_VAR(it, crystals->begin()); it != crystals->end(); ++it) + if ( crystals ) { - shared_ptr<EnderCrystal> ec = dynamic_pointer_cast<EnderCrystal>( *it ); - double dist = ec->distanceToSqr(shared_from_this() ); - if (dist < nearest) + shared_ptr<EnderCrystal> crystal = nullptr; + double nearest = Double::MAX_VALUE; + for (auto& it : *crystals ) { - nearest = dist; - crystal = ec; + shared_ptr<EnderCrystal> ec = dynamic_pointer_cast<EnderCrystal>(it); + double dist = ec->distanceToSqr(shared_from_this()); + if (dist < nearest) + { + nearest = dist; + crystal = ec; + } } + delete crystals; + nearestCrystal = crystal; } - delete crystals; - - - nearestCrystal = crystal; } } @@ -839,33 +841,39 @@ void EnderDragon::knockBack(vector<shared_ptr<Entity> > *entities) // double ym = (body.bb.y0 + body.bb.y1) / 2; double zm = (body->bb->z0 + body->bb->z1) / 2; - //for (Entity e : entities) - for(AUTO_VAR(it, entities->begin()); it != entities->end(); ++it) + if ( entities ) { - - if ( (*it)->instanceof(eTYPE_LIVINGENTITY) )//(e instanceof Mob) + for ( auto& it : *entities ) { - shared_ptr<LivingEntity> e = dynamic_pointer_cast<LivingEntity>( *it ); - double xd = e->x - xm; - double zd = e->z - zm; - double dd = xd * xd + zd * zd; - e->push(xd / dd * 4, 0.2f, zd / dd * 4); + if (it->instanceof(eTYPE_LIVINGENTITY)) + { + shared_ptr<LivingEntity> e = dynamic_pointer_cast<LivingEntity>(it); + double xd = e->x - xm; + double zd = e->z - zm; + double dd = xd * xd + zd * zd; + e->push(xd / dd * 4, 0.2f, zd / dd * 4); + } } } } void EnderDragon::hurt(vector<shared_ptr<Entity> > *entities) { - //for (int i = 0; i < entities->size(); i++) - for(AUTO_VAR(it, entities->begin()); it != entities->end(); ++it) + if ( entities ) { - - if ( (*it)->instanceof(eTYPE_LIVINGENTITY) ) //(e instanceof Mob) + for ( auto& it : *entities ) { - shared_ptr<LivingEntity> e = dynamic_pointer_cast<LivingEntity>( *it );//entities.get(i); - DamageSource *damageSource = DamageSource::mobAttack( dynamic_pointer_cast<LivingEntity>( shared_from_this() )); - e->hurt(damageSource, 10); - delete damageSource; + + if ( it->instanceof(eTYPE_LIVINGENTITY)) + { + shared_ptr<LivingEntity> e = dynamic_pointer_cast<LivingEntity>(it); + DamageSource* damageSource = DamageSource::mobAttack(dynamic_pointer_cast<LivingEntity>(shared_from_this())); + if ( damageSource ) + { + e->hurt(damageSource, 10); + delete damageSource; + } + } } } } |
