Merge pull request #2877 from LogicParrot/spawn2
Fixed non-natural spawning near player (egg, breeding, etc.)
This commit is contained in:
commit
bc4a6ec3ea
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "MobSpawner.h"
|
#include "MobSpawner.h"
|
||||||
#include "Mobs/IncludeAllMonsters.h"
|
#include "Mobs/IncludeAllMonsters.h"
|
||||||
|
#include "World.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -128,10 +129,20 @@ eMonsterType cMobSpawner::ChooseMobType(EMCSBiome a_Biome)
|
|||||||
|
|
||||||
bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, eMonsterType a_MobType, EMCSBiome a_Biome)
|
bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, eMonsterType a_MobType, EMCSBiome a_Biome)
|
||||||
{
|
{
|
||||||
cFastRandom Random;
|
if (a_Chunk == nullptr)
|
||||||
BLOCKTYPE TargetBlock = E_BLOCK_AIR;
|
|
||||||
if (a_Chunk->UnboundedRelGetBlockType(a_RelX, a_RelY, a_RelZ, TargetBlock))
|
|
||||||
{
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
cFastRandom Random;
|
||||||
|
BLOCKTYPE TargetBlock = a_Chunk->GetBlock(a_RelX, a_RelY, a_RelZ);
|
||||||
|
|
||||||
|
cPlayer * a_Closest_Player = a_Chunk->GetWorld()->FindClosestPlayer(a_Chunk->PositionToWorldPosition(a_RelX, a_RelY, a_RelZ), 24);
|
||||||
|
if (a_Closest_Player != nullptr) // Too close to a player, bail out
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if ((a_RelY >= cChunkDef::Height - 1) || (a_RelY <= 0))
|
if ((a_RelY >= cChunkDef::Height - 1) || (a_RelY <= 0))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@ -324,7 +335,6 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3504,15 +3504,6 @@ UInt32 cWorld::SpawnMobFinalize(cMonster * a_Monster)
|
|||||||
return cEntity::INVALID_ID;
|
return cEntity::INVALID_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
cPlayer * a_Closest_Player = FindClosestPlayer(a_Monster->GetPosition(), 24);
|
|
||||||
if (a_Closest_Player != nullptr) // Too close to a player, bail out.
|
|
||||||
{
|
|
||||||
delete a_Monster;
|
|
||||||
a_Monster = nullptr;
|
|
||||||
return cEntity::INVALID_ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Initialize the monster into the current world.
|
// Initialize the monster into the current world.
|
||||||
if (!a_Monster->Initialize(*this))
|
if (!a_Monster->Initialize(*this))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user