mirror of
https://github.com/neoStudiosLCE/neoLegacy.git
synced 2026-08-20 09:57:09 +00:00
Merge remote-tracking branch 'origin/main' into exp/worldgen
This commit is contained in:
commit
6a23c7f135
|
Before Width: | Height: | Size: 198 KiB After Width: | Height: | Size: 198 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 3 KiB After Width: | Height: | Size: 2.5 KiB |
|
|
@ -35,13 +35,16 @@ Ocelot::Ocelot(Level *level) : TamableAnimal(level)
|
||||||
registerAttributes();
|
registerAttributes();
|
||||||
setHealth(getMaxHealth());
|
setHealth(getMaxHealth());
|
||||||
|
|
||||||
|
avoidPlayerGoal = nullptr;
|
||||||
|
|
||||||
|
reassessTameGoals();
|
||||||
|
|
||||||
setSize(0.6f, 0.8f);
|
setSize(0.6f, 0.8f);
|
||||||
|
|
||||||
getNavigation()->setAvoidWater(true);
|
getNavigation()->setAvoidWater(true);
|
||||||
goalSelector.addGoal(1, new FloatGoal(this));
|
goalSelector.addGoal(1, new FloatGoal(this));
|
||||||
goalSelector.addGoal(2, sitGoal, false);
|
goalSelector.addGoal(2, sitGoal, false);
|
||||||
goalSelector.addGoal(3, temptGoal = new TemptGoal(this, SNEAK_SPEED_MOD, Item::fish_raw_Id, true), 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(5, new FollowOwnerGoal(this, FOLLOW_SPEED_MOD, 10, 5));
|
||||||
goalSelector.addGoal(6, new OcelotSitOnTileGoal(this, SPRINT_SPEED_MOD));
|
goalSelector.addGoal(6, new OcelotSitOnTileGoal(this, SPRINT_SPEED_MOD));
|
||||||
goalSelector.addGoal(7, new LeapAtTargetGoal(this, 0.3f));
|
goalSelector.addGoal(7, new LeapAtTargetGoal(this, 0.3f));
|
||||||
|
|
@ -60,6 +63,21 @@ void Ocelot::defineSynchedData()
|
||||||
entityData->define(DATA_TYPE_ID, static_cast<byte>(0));
|
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()
|
void Ocelot::serverAiMobStep()
|
||||||
{
|
{
|
||||||
if (getMoveControl()->hasWanted())
|
if (getMoveControl()->hasWanted())
|
||||||
|
|
@ -199,7 +217,10 @@ bool Ocelot::mobInteract(shared_ptr<Player> player)
|
||||||
}
|
}
|
||||||
else
|
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
|
// 4J-PB - don't lose the fish in creative mode
|
||||||
if (!player->abilities.instabuild) item->count--;
|
if (!player->abilities.instabuild) item->count--;
|
||||||
|
|
@ -284,6 +305,8 @@ void Ocelot::setCatType(int type)
|
||||||
|
|
||||||
bool Ocelot::canSpawn()
|
bool Ocelot::canSpawn()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
//return level->random->nextInt(3) != 0; when checkSpawnObstruction is implemented
|
||||||
// artificially make ozelots more rare
|
// artificially make ozelots more rare
|
||||||
if (level->random->nextInt(3) == 0)
|
if (level->random->nextInt(3) == 0)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "TamableAnimal.h"
|
#include "TamableAnimal.h"
|
||||||
|
#include "AvoidPlayerGoal.h"
|
||||||
|
|
||||||
class TemptGoal;
|
class TemptGoal;
|
||||||
|
|
||||||
|
|
@ -32,6 +33,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TemptGoal *temptGoal;
|
TemptGoal *temptGoal;
|
||||||
|
AvoidPlayerGoal *avoidPlayerGoal;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Ocelot(Level *level);
|
Ocelot(Level *level);
|
||||||
|
|
@ -41,6 +43,8 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void serverAiMobStep();
|
virtual void serverAiMobStep();
|
||||||
|
virtual void reassessTameGoals();
|
||||||
|
virtual void setTame(bool tame);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool removeWhenFarAway();
|
virtual bool removeWhenFarAway();
|
||||||
|
|
@ -78,6 +82,7 @@ public:
|
||||||
virtual int getCatType();
|
virtual int getCatType();
|
||||||
virtual void setCatType(int type);
|
virtual void setCatType(int type);
|
||||||
virtual bool canSpawn();
|
virtual bool canSpawn();
|
||||||
|
//virtual bool checkSpawnObstruction(); TODO when blockstates will be merged.
|
||||||
virtual wstring getAName();
|
virtual wstring getAName();
|
||||||
virtual MobGroupData *finalizeMobSpawn(MobGroupData *groupData, int extraData = 0); // 4J Added extraData param
|
virtual MobGroupData *finalizeMobSpawn(MobGroupData *groupData, int extraData = 0); // 4J Added extraData param
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue