From 28614b922fb77149a54da1a87bebfbc98736f296 Mon Sep 17 00:00:00 2001 From: ModMaker101 <119018978+ModMaker101@users.noreply.github.com> Date: Sun, 8 Mar 2026 19:08:36 -0400 Subject: 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 --- Minecraft.World/Ocelot.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'Minecraft.World/Ocelot.cpp') 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(0)); } void Ocelot::serverAiMobStep() @@ -199,7 +199,7 @@ bool Ocelot::mobInteract(shared_ptr 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 Ocelot::getBreedOffspring(shared_ptr target) // 4J - added limit to number of animals that can be bred if( level->canCreateMore( GetType(), Level::eSpawnType_Breed) ) { - shared_ptr offspring = shared_ptr( new Ocelot(level) ); + shared_ptr offspring = std::make_shared(level); if (isTame()) { offspring->setOwnerUUID(getOwnerUUID()); @@ -257,7 +257,7 @@ shared_ptr Ocelot::getBreedOffspring(shared_ptr target) bool Ocelot::isFood(shared_ptr 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) @@ -266,7 +266,7 @@ bool Ocelot::canMate(shared_ptr animal) if (!isTame()) return false; shared_ptr partner = dynamic_pointer_cast(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(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 = shared_ptr( new Ocelot(level) ); + shared_ptr ocelot = std::make_shared(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(current | 0x02) : static_cast(current & ~0x02) ); } bool Ocelot::isSittingOnTile() -- cgit v1.2.3