aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/Ocelot.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/Ocelot.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/Ocelot.cpp')
-rw-r--r--Minecraft.World/Ocelot.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/Minecraft.World/Ocelot.cpp b/Minecraft.World/Ocelot.cpp
index 50285682..75c6e0f0 100644
--- a/Minecraft.World/Ocelot.cpp
+++ b/Minecraft.World/Ocelot.cpp
@@ -57,7 +57,7 @@ void Ocelot::defineSynchedData()
{
TamableAnimal::defineSynchedData();
- entityData->define(DATA_TYPE_ID, (byte) 0);
+ entityData->define(DATA_TYPE_ID, static_cast<byte>(0));
}
void Ocelot::serverAiMobStep()
@@ -199,7 +199,7 @@ bool Ocelot::mobInteract(shared_ptr<Player> player)
}
else
{
- if (temptGoal->isRunning() && item != NULL && item->id == Item::fish_raw_Id && player->distanceToSqr(shared_from_this()) < 3 * 3)
+ if (temptGoal->isRunning() && item != nullptr && item->id == Item::fish_raw_Id && player->distanceToSqr(shared_from_this()) < 3 * 3)
{
// 4J-PB - don't lose the fish in creative mode
if (!player->abilities.instabuild) item->count--;
@@ -240,7 +240,7 @@ shared_ptr<AgableMob> Ocelot::getBreedOffspring(shared_ptr<AgableMob> target)
// 4J - added limit to number of animals that can be bred
if( level->canCreateMore( GetType(), Level::eSpawnType_Breed) )
{
- shared_ptr<Ocelot> offspring = shared_ptr<Ocelot>( new Ocelot(level) );
+ shared_ptr<Ocelot> offspring = std::make_shared<Ocelot>(level);
if (isTame())
{
offspring->setOwnerUUID(getOwnerUUID());
@@ -257,7 +257,7 @@ shared_ptr<AgableMob> Ocelot::getBreedOffspring(shared_ptr<AgableMob> target)
bool Ocelot::isFood(shared_ptr<ItemInstance> itemInstance)
{
- return itemInstance != NULL && itemInstance->id == Item::fish_raw_Id;
+ return itemInstance != nullptr && itemInstance->id == Item::fish_raw_Id;
}
bool Ocelot::canMate(shared_ptr<Animal> animal)
@@ -266,7 +266,7 @@ bool Ocelot::canMate(shared_ptr<Animal> animal)
if (!isTame()) return false;
shared_ptr<Ocelot> partner = dynamic_pointer_cast<Ocelot>(animal);
- if (partner == NULL) return false;
+ if (partner == nullptr) return false;
if (!partner->isTame()) return false;
return isInLove() && partner->isInLove();
@@ -279,7 +279,7 @@ int Ocelot::getCatType()
void Ocelot::setCatType(int type)
{
- entityData->set(DATA_TYPE_ID, (byte) type);
+ entityData->set(DATA_TYPE_ID, static_cast<byte>(type));
}
bool Ocelot::canSpawn()
@@ -339,7 +339,7 @@ MobGroupData *Ocelot::finalizeMobSpawn(MobGroupData *groupData, int extraData /*
{
for (int kitten = 0; kitten < 2; kitten++)
{
- shared_ptr<Ocelot> ocelot = shared_ptr<Ocelot>( new Ocelot(level) );
+ shared_ptr<Ocelot> ocelot = std::make_shared<Ocelot>(level);
ocelot->moveTo(x, y, z, yRot, 0);
ocelot->setAge(-20 * 60 * 20);
level->addEntity(ocelot);
@@ -351,7 +351,7 @@ MobGroupData *Ocelot::finalizeMobSpawn(MobGroupData *groupData, int extraData /*
void Ocelot::setSittingOnTile(bool val)
{
byte current = entityData->getByte(DATA_FLAGS_ID);
- entityData->set(DATA_FLAGS_ID, val ? (byte) (current | 0x02) : (byte) (current & ~0x02) );
+ entityData->set(DATA_FLAGS_ID, val ? static_cast<byte>(current | 0x02) : static_cast<byte>(current & ~0x02) );
}
bool Ocelot::isSittingOnTile()