1
0

Fixed non-natural spawning near player (egg, breeding, etc.)

This commit is contained in:
LogicParrot 2016-01-16 12:28:13 +02:00
parent 5ca2f4fd0c
commit ac2c79f797
2 changed files with 187 additions and 186 deletions

View File

@ -3,6 +3,7 @@
#include "MobSpawner.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)
{
cFastRandom Random;
BLOCKTYPE TargetBlock = E_BLOCK_AIR;
if (a_Chunk->UnboundedRelGetBlockType(a_RelX, a_RelY, a_RelZ, TargetBlock))
if (a_Chunk == nullptr)
{
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))
{
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;
}

View File

@ -3504,15 +3504,6 @@ UInt32 cWorld::SpawnMobFinalize(cMonster * a_Monster)
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.
if (!a_Monster->Initialize(*this))
{