14 m_MonsterFamily(a_MonsterFamily),
18 for (std::set<eMonsterType>::const_iterator itr = a_AllowedTypes.begin(); itr != a_AllowedTypes.end(); ++itr)
51 std::vector<eMonsterType> AllowedMobs;
58 AllowedMobs.push_back(MobType);
63 if (AllowedMobs.empty())
88 auto TargetBlock = a_Chunk->
GetBlock(a_RelPos);
103 (a_RelPos.
y <= 63) &&
167 if (a_RelPos.
y < 250)
193 (Random.RandBool(0.01))
203 (a_RelPos.
y >= 45) &&
211 const int AMOUNT_MOON_PHASES = 8;
212 auto maxLight = Random.RandInt(0, 7);
213 auto moonPhaseNumber =
static_cast<int>(std::floor(a_Chunk->
GetWorld()->
GetWorldAge().count() / 24000)) % AMOUNT_MOON_PHASES;
214 auto moonThreshold =
static_cast<float>(std::abs(moonPhaseNumber - (AMOUNT_MOON_PHASES / 2)) / (AMOUNT_MOON_PHASES / 2));
221 (a_DisableSolidBelowCheck)) &&
224 (a_RelPos.
y <= 40) &&
229 (a_RelPos.
y >= 50) &&
230 (a_RelPos.
y <= 70) &&
231 (SkyLight <= maxLight) &&
232 (BlockLight <= maxLight) &&
233 (Random.RandBool(moonThreshold)) &&
234 (Random.RandBool(0.5))
262 (a_RelPos.
y >= 62) &&
263 (Random.RandBool(2.0 / 3.0))
269 bool CanSpawn =
true;
270 bool HasFloor =
false;
271 for (
int x = 0; x < 2; ++x)
273 for (
int z = 0; z < 2; ++z)
276 CanSpawn = CanSpawn && (TargetBlock ==
E_BLOCK_AIR);
290 return CanSpawn && HasFloor && (SkyLight <= 7) && (BlockLight <= 7);
297 (a_RelPos.
y >= 45) &&
310 (Random.RandBool(0.6))
344 LOGD(
"MG TODO: Write spawning rule for mob type %d", a_MobType);
357 std::set<eMonsterType> ListOfSpawnables;
366 return ListOfSpawnables;
399 ListOfSpawnables.insert(
mtHorse);
406 ListOfSpawnables.insert(
mtWolf);
420 ListOfSpawnables.insert(
mtWolf);
451 ListOfSpawnables.insert(
mtSheep);
452 ListOfSpawnables.insert(
mtPig);
453 ListOfSpawnables.insert(
mtCow);
456 ListOfSpawnables.insert(
mtSlime);
459 ListOfSpawnables.insert(
mtBat);
464 ListOfSpawnables.insert(
mtSquid);
467 ListOfSpawnables.insert(
mtBlaze);
468 ListOfSpawnables.insert(
mtGhast);
473 return ListOfSpawnables;
484 static const double RangeLimit = 24;
524 auto NewMobPtr = NewMob.get();
EMCSBiome
Biome IDs The first batch corresponds to the clientside biomes, used by MineCraft.
bool IsBlockWater(BLOCKTYPE a_BlockType)
unsigned char BLOCKTYPE
The datatype used by blockdata.
MTRand & GetRandomProvider()
Returns the current thread's random number source.
eMonsterType
Identifies individual monster type.
static bool IsTransparent(BLOCKTYPE Block)
Is a block transparent? (https://minecraft.wiki/w/Opacity)
NIBBLETYPE GetBlockLight(Vector3i a_RelPos) const
Get the level of artificial light illuminating the block (0 - 15)
bool IsSlimeChunk() const
Returns true if slimes should spawn in the chunk.
BLOCKTYPE GetBlock(int a_RelX, int a_RelY, int a_RelZ) const
Vector3i RelativeToAbsolute(Vector3i a_RelBlockPosition) const
Converts the coord relative to this chunk into an absolute coord.
NIBBLETYPE GetSkyLight(Vector3i a_RelPos) const
Get the level of sky light illuminating the block (0 - 15) independent of daytime.
NIBBLETYPE GetTimeAlteredLight(NIBBLETYPE a_Skylight) const
Light alterations based on time.
cWorld * GetWorld(void) const
bool UnboundedRelGetBlockType(Vector3i a_RelCoords, BLOCKTYPE &a_BlockType) const
Same as GetBlockType(), but relative coords needn't be in this chunk (uses m_Neighbor-s or m_ChunkMap...
static bool IsValidHeight(Vector3i a_BlockPosition)
Validates a height-coordinate.
IntType RandInt(IntType a_Min, IntType a_Max)
Return a random IntType in the range [a_Min, a_Max].
static std::unique_ptr< cMonster > NewMonsterFromType(eMonsterType a_MobType)
Creates a new object of the specified mob.
static eFamily FamilyFromType(eMonsterType a_MobType)
Returns the mob family based on the type.
bool CheckPackCenter(BLOCKTYPE a_BlockType)
Check if specified block can be a Pack center for this spawner.
cMobSpawner(cMonster::eFamily MobFamily, const std::set< eMonsterType > &a_AllowedTypes)
Constructor a_MobFamily is the Family of mobs that this spawner will spawn a_AllowedTypes is the set ...
static std::set< eMonsterType > GetAllowedMobTypes(EMCSBiome a_Biome)
Returns all mob types that can spawn that biome.
eMonsterType ChooseMobType(EMCSBiome a_Biome)
Returns a random type that can spawn in the specified biome.
std::vector< std::unique_ptr< cMonster > > m_Spawned
bool CanSpawnAnything(void)
void NewPack(void)
Mark the beginning of a new Pack.
std::set< eMonsterType > m_AllowedTypes
cMonster * TryToSpawnHere(cChunk *a_Chunk, Vector3i a_RelPos, EMCSBiome a_Biome, int &a_MaxPackSize)
Try to create a monster here If this is the first of a Pack, determine the type of monster a_Biome,...
cMonster::eFamily m_MonsterFamily
static bool CanSpawnHere(cChunk *a_Chunk, Vector3i a_RelPos, eMonsterType a_MobType, EMCSBiome a_Biome, bool a_DisableSolidBelowCheck=false)
Returns true if specified type of mob can spawn on specified block.
Vector3< T > addedY(T a_AddY) const
Returns a copy of this vector moved by the specified amount on the y axis.
Vector3< T > addedXZ(T a_AddX, T a_AddZ) const
Returns a copy of this vector moved by the specified amount on the X and Z axes.
virtual cTickTimeLong GetWorldAge(void) const override
bool DoWithNearestPlayer(Vector3d a_Pos, double a_RangeLimit, cPlayerListCallback a_Callback, bool a_CheckLineOfSight=true, bool a_IgnoreSpectator=true)
Calls the callback for nearest player for given position, Returns false if player not found,...