aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/HangingEntity.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/HangingEntity.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/HangingEntity.cpp')
-rw-r--r--Minecraft.World/HangingEntity.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/Minecraft.World/HangingEntity.cpp b/Minecraft.World/HangingEntity.cpp
index 26261710..67d53114 100644
--- a/Minecraft.World/HangingEntity.cpp
+++ b/Minecraft.World/HangingEntity.cpp
@@ -35,16 +35,16 @@ HangingEntity::HangingEntity(Level *level, int xTile, int yTile, int zTile, int
void HangingEntity::setDir(int dir)
{
this->dir = dir;
- yRotO = yRot = (float)(dir * 90);
+ yRotO = yRot = static_cast<float>(dir * 90);
- float w = (float)getWidth();
- float h = (float)getHeight();
- float d = (float)getWidth();
+ float w = static_cast<float>(getWidth());
+ float h = static_cast<float>(getHeight());
+ float d = static_cast<float>(getWidth());
if (dir == Direction::NORTH || dir == Direction::SOUTH)
{
d = 0.5f;
- yRot = yRotO = (float)(Direction::DIRECTION_OPPOSITE[dir] * 90);
+ yRot = yRotO = static_cast<float>(Direction::DIRECTION_OPPOSITE[dir] * 90);
}
else
{
@@ -150,7 +150,7 @@ bool HangingEntity::survives()
vector<shared_ptr<Entity> > *entities = level->getEntities(shared_from_this(), bb);
- if (entities != NULL && entities->size() > 0)
+ if (entities != nullptr && entities->size() > 0)
{
for (auto& e : *entities)
{
@@ -184,11 +184,11 @@ bool HangingEntity::hurt(DamageSource *source, float damage)
if (isInvulnerable()) return false;
if (!removed && !level->isClientSide)
{
- if (dynamic_cast<EntityDamageSource *>(source) != NULL)
+ if (dynamic_cast<EntityDamageSource *>(source) != nullptr)
{
shared_ptr<Entity> sourceEntity = source->getDirectEntity();
- if ( (sourceEntity != NULL) && sourceEntity->instanceof(eTYPE_PLAYER) && !dynamic_pointer_cast<Player>(sourceEntity)->isAllowedToHurtEntity(shared_from_this()) )
+ if ( (sourceEntity != nullptr) && sourceEntity->instanceof(eTYPE_PLAYER) && !dynamic_pointer_cast<Player>(sourceEntity)->isAllowedToHurtEntity(shared_from_this()) )
{
return false;
}
@@ -199,12 +199,12 @@ bool HangingEntity::hurt(DamageSource *source, float damage)
shared_ptr<Player> player = nullptr;
shared_ptr<Entity> e = source->getEntity();
- if ( (e!=NULL) && e->instanceof(eTYPE_PLAYER) ) // check if it's serverplayer or player
+ if ( (e!=nullptr) && e->instanceof(eTYPE_PLAYER) ) // check if it's serverplayer or player
{
player = dynamic_pointer_cast<Player>( e );
}
- if (player != NULL && player->abilities.instabuild)
+ if (player != nullptr && player->abilities.instabuild)
{
return true;
}
@@ -235,7 +235,7 @@ void HangingEntity::push(double xa, double ya, double za)
void HangingEntity::addAdditonalSaveData(CompoundTag *tag)
{
- tag->putByte(L"Direction", (byte) dir);
+ tag->putByte(L"Direction", static_cast<byte>(dir));
tag->putInt(L"TileX", xTile);
tag->putInt(L"TileY", yTile);
tag->putInt(L"TileZ", zTile);