aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/Creeper.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/Creeper.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/Creeper.cpp')
-rw-r--r--Minecraft.World/Creeper.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/Minecraft.World/Creeper.cpp b/Minecraft.World/Creeper.cpp
index 29be2c0c..0cd6b534 100644
--- a/Minecraft.World/Creeper.cpp
+++ b/Minecraft.World/Creeper.cpp
@@ -64,9 +64,9 @@ bool Creeper::useNewAi()
int Creeper::getMaxFallDistance()
{
- if (getTarget() == NULL) return 3;
+ if (getTarget() == nullptr) return 3;
// As long as they survive the fall they should try.
- return 3 + (int) (getHealth() - 1);
+ return 3 + static_cast<int>(getHealth() - 1);
}
void Creeper::causeFallDamage(float distance)
@@ -81,22 +81,22 @@ void Creeper::defineSynchedData()
{
Monster::defineSynchedData();
- entityData->define(DATA_SWELL_DIR, (byte) -1);
- entityData->define(DATA_IS_POWERED, (byte) 0);
+ entityData->define(DATA_SWELL_DIR, static_cast<byte>(-1));
+ entityData->define(DATA_IS_POWERED, static_cast<byte>(0));
}
void Creeper::addAdditonalSaveData(CompoundTag *entityTag)
{
Monster::addAdditonalSaveData(entityTag);
if (entityData->getByte(DATA_IS_POWERED) == 1) entityTag->putBoolean(L"powered", true);
- entityTag->putShort(L"Fuse", (short) maxSwell);
- entityTag->putByte(L"ExplosionRadius", (byte) explosionRadius);
+ entityTag->putShort(L"Fuse", static_cast<short>(maxSwell));
+ entityTag->putByte(L"ExplosionRadius", static_cast<byte>(explosionRadius));
}
void Creeper::readAdditionalSaveData(CompoundTag *tag)
{
Monster::readAdditionalSaveData(tag);
- entityData->set(DATA_IS_POWERED, (byte) (tag->getBoolean(L"powered") ? 1 : 0));
+ entityData->set(DATA_IS_POWERED, static_cast<byte>(tag->getBoolean(L"powered") ? 1 : 0));
if (tag->contains(L"Fuse")) maxSwell = tag->getShort(L"Fuse");
if (tag->contains(L"ExplosionRadius")) explosionRadius = tag->getByte(L"ExplosionRadius");
}
@@ -142,13 +142,13 @@ void Creeper::die(DamageSource *source)
{
Monster::die(source);
- if ( source->getEntity() != NULL && source->getEntity()->instanceof(eTYPE_SKELETON) )
+ if ( source->getEntity() != nullptr && source->getEntity()->instanceof(eTYPE_SKELETON) )
{
int recordId = Item::record_01_Id + random->nextInt(Item::record_12_Id - Item::record_01_Id + 1);
spawnAtLocation(recordId, 1);
}
- if ( source->getDirectEntity() != NULL && source->getDirectEntity()->instanceof(eTYPE_ARROW) && source->getEntity() != NULL && source->getEntity()->instanceof(eTYPE_PLAYER) )
+ if ( source->getDirectEntity() != nullptr && source->getDirectEntity()->instanceof(eTYPE_ARROW) && source->getEntity() != nullptr && source->getEntity()->instanceof(eTYPE_PLAYER) )
{
shared_ptr<Player> player = dynamic_pointer_cast<Player>(source->getEntity());
player->awardStat(GenericStats::archer(), GenericStats::param_archer());
@@ -177,16 +177,16 @@ int Creeper::getDeathLoot()
int Creeper::getSwellDir()
{
- return (int) (char) entityData->getByte(DATA_SWELL_DIR);
+ return (int) static_cast<char>(entityData->getByte(DATA_SWELL_DIR));
}
void Creeper::setSwellDir(int dir)
{
- entityData->set(DATA_SWELL_DIR, (byte) dir);
+ entityData->set(DATA_SWELL_DIR, static_cast<byte>(dir));
}
void Creeper::thunderHit(const LightningBolt *lightningBolt)
{
Monster::thunderHit(lightningBolt);
- entityData->set(DATA_IS_POWERED, (byte) 1);
+ entityData->set(DATA_IS_POWERED, static_cast<byte>(1));
}