aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/Spider.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.World/Spider.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.World/Spider.cpp')
-rw-r--r--Minecraft.World/Spider.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/Minecraft.World/Spider.cpp b/Minecraft.World/Spider.cpp
index 49997db3..5d7bdd2c 100644
--- a/Minecraft.World/Spider.cpp
+++ b/Minecraft.World/Spider.cpp
@@ -31,7 +31,7 @@ void Spider::defineSynchedData()
{
Monster::defineSynchedData();
- entityData->define(DATA_FLAGS_ID, (byte) 0);
+ entityData->define(DATA_FLAGS_ID, static_cast<byte>(0));
}
void Spider::tick()
@@ -109,7 +109,7 @@ void Spider::checkHurtTarget(shared_ptr<Entity> target, float d)
{
double xdd = target->x - x;
double zdd = target->z - z;
- float dd = (float) sqrt(xdd * xdd + zdd * zdd);
+ float dd = static_cast<float>(sqrt(xdd * xdd + zdd * zdd));
xd = (xdd / dd * 0.5f) * 0.8f + xd * 0.2f;
zd = (zdd / dd * 0.5f) * 0.8f + zd * 0.2f;
yd = 0.4f;
@@ -195,26 +195,26 @@ MobGroupData *Spider::finalizeMobSpawn(MobGroupData *groupData, int extraData /*
if (level->random->nextInt(100) == 0)
#endif
{
- shared_ptr<Skeleton> skeleton = shared_ptr<Skeleton>( new Skeleton(level) );
+ shared_ptr<Skeleton> skeleton = std::make_shared<Skeleton>(level);
skeleton->moveTo(x, y, z, yRot, 0);
- skeleton->finalizeMobSpawn(NULL);
+ skeleton->finalizeMobSpawn(nullptr);
level->addEntity(skeleton);
skeleton->ride(shared_from_this());
}
- if (groupData == NULL)
+ if (groupData == nullptr)
{
groupData = new SpiderEffectsGroupData();
if (level->difficulty > Difficulty::NORMAL && level->random->nextFloat() < SPIDER_SPECIAL_EFFECT_CHANCE * level->getDifficulty(x, y, z))
{
- ((SpiderEffectsGroupData *) groupData)->setRandomEffect(level->random);
+ static_cast<SpiderEffectsGroupData *>(groupData)->setRandomEffect(level->random);
}
}
- if ( dynamic_cast<SpiderEffectsGroupData *>( groupData ) != NULL)
+ if ( dynamic_cast<SpiderEffectsGroupData *>( groupData ) != nullptr)
{
- int effect = ((SpiderEffectsGroupData *) groupData)->effectId;
- if (effect > 0 && MobEffect::effects[effect] != NULL)
+ int effect = static_cast<SpiderEffectsGroupData *>(groupData)->effectId;
+ if (effect > 0 && MobEffect::effects[effect] != nullptr)
{
addEffect(new MobEffectInstance(effect, Integer::MAX_VALUE));
}