Merge remote-tracking branch 'origin/main' into exp/worldgen

This commit is contained in:
github-actions 2026-05-30 13:59:39 +00:00
commit 6a23c7f135
5 changed files with 30 additions and 2 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View file

@ -35,13 +35,16 @@ Ocelot::Ocelot(Level *level) : TamableAnimal(level)
registerAttributes();
setHealth(getMaxHealth());
avoidPlayerGoal = nullptr;
reassessTameGoals();
setSize(0.6f, 0.8f);
getNavigation()->setAvoidWater(true);
goalSelector.addGoal(1, new FloatGoal(this));
goalSelector.addGoal(2, sitGoal, false);
goalSelector.addGoal(3, temptGoal = new TemptGoal(this, SNEAK_SPEED_MOD, Item::fish_raw_Id, true), false);
goalSelector.addGoal(4, new AvoidPlayerGoal(this, typeid(Player), 16, WALK_SPEED_MOD, SPRINT_SPEED_MOD));
goalSelector.addGoal(5, new FollowOwnerGoal(this, FOLLOW_SPEED_MOD, 10, 5));
goalSelector.addGoal(6, new OcelotSitOnTileGoal(this, SPRINT_SPEED_MOD));
goalSelector.addGoal(7, new LeapAtTargetGoal(this, 0.3f));
@ -60,6 +63,21 @@ void Ocelot::defineSynchedData()
entityData->define(DATA_TYPE_ID, static_cast<byte>(0));
}
void Ocelot::reassessTameGoals()
{
if (!avoidPlayerGoal)
avoidPlayerGoal = new AvoidPlayerGoal(this, typeid(Player), 16, WALK_SPEED_MOD, SPRINT_SPEED_MOD);
goalSelector.removeGoal(avoidPlayerGoal);
if (!isTame())
goalSelector.addGoal(4, avoidPlayerGoal, false);
}
void Ocelot::setTame(bool tame)
{
TamableAnimal::setTame(tame);
}
void Ocelot::serverAiMobStep()
{
if (getMoveControl()->hasWanted())
@ -199,7 +217,10 @@ bool Ocelot::mobInteract(shared_ptr<Player> player)
}
else
{
if (/*temptGoal->isRunning() &&*/ item != nullptr && item->id == Item::fish_raw_Id && player->distanceToSqr(shared_from_this()) < 3 * 3)
//player must be close holding raw fish
// temptGoal->isRunning() check removed
// when the player enters interaction range, which would block taming entirely
if (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--;
@ -284,6 +305,8 @@ void Ocelot::setCatType(int type)
bool Ocelot::canSpawn()
{
//return level->random->nextInt(3) != 0; when checkSpawnObstruction is implemented
// artificially make ozelots more rare
if (level->random->nextInt(3) == 0)
{

View file

@ -1,6 +1,7 @@
#pragma once
#include "TamableAnimal.h"
#include "AvoidPlayerGoal.h"
class TemptGoal;
@ -32,6 +33,7 @@ public:
private:
TemptGoal *temptGoal;
AvoidPlayerGoal *avoidPlayerGoal;
public:
Ocelot(Level *level);
@ -41,6 +43,8 @@ protected:
public:
virtual void serverAiMobStep();
virtual void reassessTameGoals();
virtual void setTame(bool tame);
protected:
virtual bool removeWhenFarAway();
@ -78,6 +82,7 @@ public:
virtual int getCatType();
virtual void setCatType(int type);
virtual bool canSpawn();
//virtual bool checkSpawnObstruction(); TODO when blockstates will be merged.
virtual wstring getAName();
virtual MobGroupData *finalizeMobSpawn(MobGroupData *groupData, int extraData = 0); // 4J Added extraData param