Project modernization (#630)

* 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
This commit is contained in:
ModMaker101
2026-03-07 21:56:03 -05:00
committed by GitHub
parent 1be5faaea7
commit a9be52c41a
1373 changed files with 19903 additions and 19449 deletions

View File

@@ -106,10 +106,10 @@ void Throwable::shoot(double xd, double yd, double zd, float pow, float uncertai
this->yd = yd;
this->zd = zd;
float sd = (float) sqrt(xd * xd + zd * zd);
float sd = static_cast<float>(sqrt(xd * xd + zd * zd));
yRotO = yRot = (float) (atan2(xd, zd) * 180 / PI);
xRotO = xRot = (float) (atan2(yd, (double)sd) * 180 / PI);
yRotO = yRot = static_cast<float>(atan2(xd, zd) * 180 / PI);
xRotO = xRot = static_cast<float>(atan2(yd, (double)sd) * 180 / PI);
life = 0;
}
@@ -120,9 +120,9 @@ void Throwable::lerpMotion(double xd, double yd, double zd)
this->zd = zd;
if (xRotO == 0 && yRotO == 0)
{
float sd = (float) sqrt(xd * xd + zd * zd);
yRotO = yRot = (float) (atan2(xd, zd) * 180 / PI);
xRotO = xRot = (float) (atan2(yd, (double)sd) * 180 / PI);
float sd = static_cast<float>(sqrt(xd * xd + zd * zd));
yRotO = yRot = static_cast<float>(atan2(xd, zd) * 180 / PI);
xRotO = xRot = static_cast<float>(atan2(yd, (double)sd) * 180 / PI);
}
}
@@ -166,7 +166,7 @@ void Throwable::tick()
from = Vec3::newTemp(x, y, z);
to = Vec3::newTemp(x + xd, y + yd, z + zd);
if (res != NULL)
if (res != nullptr)
{
to = Vec3::newTemp(res->pos->x, res->pos->y, res->pos->z);
}
@@ -185,7 +185,7 @@ void Throwable::tick()
float rr = 0.3f;
AABB *bb = e->bb->grow(rr, rr, rr);
HitResult *p = bb->clip(from, to);
if (p != NULL)
if (p != nullptr)
{
double dd = from->distanceTo(p->pos);
delete p;
@@ -197,14 +197,14 @@ void Throwable::tick()
}
}
if (hitEntity != NULL)
if (hitEntity != nullptr)
{
if(res != NULL) delete res;
if(res != nullptr) delete res;
res = new HitResult(hitEntity);
}
}
if (res != NULL)
if (res != nullptr)
{
if ( (res->type == HitResult::TILE) && (level->getTile(res->x, res->y, res->z) == Tile::portalTile_Id) )
{
@@ -220,9 +220,9 @@ void Throwable::tick()
y += yd;
z += zd;
float sd = (float) sqrt(xd * xd + zd * zd);
yRot = (float) (atan2(xd, zd) * 180 / PI);
xRot = (float) (atan2(yd, (double)sd) * 180 / PI);
float sd = static_cast<float>(sqrt(xd * xd + zd * zd));
yRot = static_cast<float>(atan2(xd, zd) * 180 / PI);
xRot = static_cast<float>(atan2(yd, (double)sd) * 180 / PI);
while (xRot - xRotO < -180)
xRotO -= 360;
@@ -267,14 +267,14 @@ float Throwable::getGravity()
void Throwable::addAdditonalSaveData(CompoundTag *tag)
{
tag->putShort(L"xTile", (short) xTile);
tag->putShort(L"yTile", (short) yTile);
tag->putShort(L"zTile", (short) zTile);
tag->putByte(L"inTile", (byte) lastTile);
tag->putByte(L"shake", (byte) shakeTime);
tag->putByte(L"inGround", (byte) (inGround ? 1 : 0));
tag->putShort(L"xTile", static_cast<short>(xTile));
tag->putShort(L"yTile", static_cast<short>(yTile));
tag->putShort(L"zTile", static_cast<short>(zTile));
tag->putByte(L"inTile", static_cast<byte>(lastTile));
tag->putByte(L"shake", static_cast<byte>(shakeTime));
tag->putByte(L"inGround", static_cast<byte>(inGround ? 1 : 0));
if (ownerName.empty() && (owner != NULL) && owner->instanceof(eTYPE_PLAYER) )
if (ownerName.empty() && (owner != nullptr) && owner->instanceof(eTYPE_PLAYER) )
{
ownerName = owner->getAName();
}
@@ -301,7 +301,7 @@ float Throwable::getShadowHeightOffs()
shared_ptr<LivingEntity> Throwable::getOwner()
{
if (owner == NULL && !ownerName.empty() )
if (owner == nullptr && !ownerName.empty() )
{
owner = level->getPlayerByName(ownerName);
}