diff options
| author | qwasdrizzel <145519042+qwasdrizzel@users.noreply.github.com> | 2026-03-16 21:44:26 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-16 21:44:26 -0500 |
| commit | ce739f6045ec72127491286ea3f3f21e537c1b55 (patch) | |
| tree | f33bd42a47c1b4a7b2153a7fb77127ee3b407db9 /Minecraft.World/Animal.cpp | |
| parent | 255a18fe8e9b57377975f82e2b227afe2a12eda0 (diff) | |
| parent | 5a59f5d146b43811dde6a5a0245ee9875d7b5cd1 (diff) | |
Merge branch 'smartcmd:main' into main
Diffstat (limited to 'Minecraft.World/Animal.cpp')
| -rw-r--r-- | Minecraft.World/Animal.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/Minecraft.World/Animal.cpp b/Minecraft.World/Animal.cpp index ecda8fc5..68278162 100644 --- a/Minecraft.World/Animal.cpp +++ b/Minecraft.World/Animal.cpp @@ -72,13 +72,13 @@ void Animal::checkHurtTarget(shared_ptr<Entity> target, float d) { double xd = target->x - x; double zd = target->z - z; - yRot = (float) (atan2(zd, xd) * 180 / PI) - 90; + yRot = static_cast<float>(atan2(zd, xd) * 180 / PI) - 90; holdGround = true; } shared_ptr<Player> p = dynamic_pointer_cast<Player>(target); - if (p->getSelectedItem() == NULL || !isFood(p->getSelectedItem())) + if (p->getSelectedItem() == nullptr || !isFood(p->getSelectedItem())) { attackTarget = nullptr; } @@ -97,7 +97,7 @@ void Animal::checkHurtTarget(shared_ptr<Entity> target, float d) } else if (getInLoveValue() > 0 && a->getInLoveValue() > 0) { - if (a->attackTarget == NULL) a->attackTarget = shared_from_this(); + if (a->attackTarget == nullptr) a->attackTarget = shared_from_this(); if (a->attackTarget == shared_from_this() && d < 3.5) { @@ -134,9 +134,9 @@ void Animal::breedWith(shared_ptr<Animal> target) target->loveTime = 0; target->setInLoveValue(0); - // 4J - we have offspring of NULL returned when we have hit our limits of spawning any particular type of animal. In these cases try and do everything we can apart from actually + // 4J - we have offspring of nullptr returned when we have hit our limits of spawning any particular type of animal. In these cases try and do everything we can apart from actually // spawning the entity. - if (offspring != NULL) + if (offspring != nullptr) { // Only want to set the age to this +ve value if something is actually spawned, as during this period the animal will attempt to follow offspring and ignore players. setAge(5 * 60 * 20); @@ -154,7 +154,7 @@ void Animal::breedWith(shared_ptr<Animal> target) } level->addEntity(offspring); - level->addEntity( shared_ptr<ExperienceOrb>( new ExperienceOrb(level, x, y, z, random->nextInt(4) + 1) ) ); + level->addEntity(std::make_shared<ExperienceOrb>(level, x, y, z, random->nextInt(4) + 1)); } setDespawnProtected(); @@ -169,7 +169,7 @@ float Animal::getWalkTargetValue(int x, int y, int z) bool Animal::hurt(DamageSource *dmgSource, float dmg) { if (isInvulnerable()) return false; - if (dynamic_cast<EntityDamageSource *>(dmgSource) != NULL) + if (dynamic_cast<EntityDamageSource *>(dmgSource) != nullptr) { shared_ptr<Entity> source = dmgSource->getDirectEntity(); @@ -179,12 +179,12 @@ bool Animal::hurt(DamageSource *dmgSource, float dmg) return false; } - if ( (source != NULL) && source->instanceof(eTYPE_ARROW) ) + if ( (source != nullptr) && source->instanceof(eTYPE_ARROW) ) { shared_ptr<Arrow> arrow = dynamic_pointer_cast<Arrow>(source); // 4J: Check that the arrow's owner can attack animals (dispenser arrows are not owned) - if (arrow->owner != NULL && arrow->owner->instanceof(eTYPE_PLAYER) && !dynamic_pointer_cast<Player>(arrow->owner)->isAllowedToAttackAnimals() ) + if (arrow->owner != nullptr && arrow->owner->instanceof(eTYPE_PLAYER) && !dynamic_pointer_cast<Player>(arrow->owner)->isAllowedToAttackAnimals() ) { return false; } @@ -196,7 +196,7 @@ bool Animal::hurt(DamageSource *dmgSource, float dmg) if (!useNewAi()) { AttributeInstance *speed = getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED); - if (speed->getModifier(eModifierId_MOB_FLEEING) == NULL) + if (speed->getModifier(eModifierId_MOB_FLEEING) == nullptr) { speed->addModifier(new AttributeModifier(*Animal::SPEED_MODIFIER_FLEEING)); } @@ -255,7 +255,7 @@ shared_ptr<Entity> Animal::findAttackTarget() setDespawnProtected(); shared_ptr<Player> p = dynamic_pointer_cast<Player>(it); - if (p->getSelectedItem() != NULL && this->isFood(p->getSelectedItem())) + if (p->getSelectedItem() != nullptr && this->isFood(p->getSelectedItem())) { delete players; return p; @@ -317,7 +317,7 @@ bool Animal::isFood(shared_ptr<ItemInstance> itemInstance) bool Animal::mobInteract(shared_ptr<Player> player) { shared_ptr<ItemInstance> item = player->inventory->getSelected(); - if (item != NULL && isFood(item) && getAge() == 0 && getInLoveValue() <= 0) + if (item != nullptr && isFood(item) && getAge() == 0 && getInLoveValue() <= 0) { if (!player->abilities.instabuild) { |
