Implement slime chunks. (#5484)
* Implement slime chunks. * add cWorld::IsSlimeChunk * add documentation for cWorld::IsSlimeChunk
This commit is contained in:
parent
dcad86e776
commit
669392d44a
@ -2315,6 +2315,27 @@ function OnAllChunksAvailable()</pre> All return values from the callbacks are i
|
|||||||
},
|
},
|
||||||
Notes = "Returns whether or not saving chunk data is enabled. If disabled, the world will keep dirty chunks in memory forever, and will simply regenerate non-dirty chunks that are unloaded.",
|
Notes = "Returns whether or not saving chunk data is enabled. If disabled, the world will keep dirty chunks in memory forever, and will simply regenerate non-dirty chunks that are unloaded.",
|
||||||
},
|
},
|
||||||
|
IsSlimeChunk =
|
||||||
|
{
|
||||||
|
Params =
|
||||||
|
{
|
||||||
|
{
|
||||||
|
Name = "ChunkX",
|
||||||
|
Type = "number",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name = "ChunkZ",
|
||||||
|
Type = "number",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Returns =
|
||||||
|
{
|
||||||
|
{
|
||||||
|
Type = "boolean",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Notes = "Returns whether slimes can spawn in the chunk.",
|
||||||
|
},
|
||||||
IsTrapdoorOpen =
|
IsTrapdoorOpen =
|
||||||
{
|
{
|
||||||
Params =
|
Params =
|
||||||
|
@ -1980,3 +1980,12 @@ NIBBLETYPE cChunk::GetTimeAlteredLight(NIBBLETYPE a_Skylight) const
|
|||||||
// Because NIBBLETYPE is unsigned, we clamp it to 0 .. 15 by checking for values above 15
|
// Because NIBBLETYPE is unsigned, we clamp it to 0 .. 15 by checking for values above 15
|
||||||
return (a_Skylight < 16)? a_Skylight : 0;
|
return (a_Skylight < 16)? a_Skylight : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool cChunk::IsSlimeChunk() const
|
||||||
|
{
|
||||||
|
return m_World->IsSlimeChunk(m_PosX, m_PosZ);
|
||||||
|
}
|
||||||
|
@ -452,6 +452,8 @@ public:
|
|||||||
return cChunkDef::RelativeToAbsolute(a_RelBlockPosition, {m_PosX, m_PosZ});
|
return cChunkDef::RelativeToAbsolute(a_RelBlockPosition, {m_PosX, m_PosZ});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Returns true if slimes should spawn in the chunk. */
|
||||||
|
bool IsSlimeChunk() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -220,7 +220,10 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, Vector3i a_RelPos, eMonsterType
|
|||||||
(!cBlockInfo::IsTransparent(BlockBelow)) ||
|
(!cBlockInfo::IsTransparent(BlockBelow)) ||
|
||||||
(a_DisableSolidBelowCheck)) &&
|
(a_DisableSolidBelowCheck)) &&
|
||||||
(
|
(
|
||||||
(a_RelPos.y <= 40) ||
|
(
|
||||||
|
(a_RelPos.y <= 40) &&
|
||||||
|
a_Chunk->IsSlimeChunk()
|
||||||
|
) ||
|
||||||
(
|
(
|
||||||
(a_Biome == biSwampland) &&
|
(a_Biome == biSwampland) &&
|
||||||
(a_RelPos.y >= 50) &&
|
(a_RelPos.y >= 50) &&
|
||||||
|
@ -3229,3 +3229,13 @@ void cWorld::cChunkGeneratorCallbacks::CallHookChunkGenerated (cChunkDesc & a_Ch
|
|||||||
*m_World, a_ChunkDesc.GetChunkX(), a_ChunkDesc.GetChunkZ(), &a_ChunkDesc
|
*m_World, a_ChunkDesc.GetChunkX(), a_ChunkDesc.GetChunkZ(), &a_ChunkDesc
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool cWorld::IsSlimeChunk(int a_ChunkX, int a_ChunkZ) const
|
||||||
|
{
|
||||||
|
cNoise Noise(GetSeed());
|
||||||
|
return (Noise.IntNoise2DInt(a_ChunkX, a_ChunkZ) / 8) % 10 == 0; // 10% chance
|
||||||
|
}
|
||||||
|
@ -843,7 +843,7 @@ public:
|
|||||||
virtual bool IsWeatherWetAtXYZ(Vector3i a_Position) override;
|
virtual bool IsWeatherWetAtXYZ(Vector3i a_Position) override;
|
||||||
|
|
||||||
/** Returns the seed of the world. */
|
/** Returns the seed of the world. */
|
||||||
int GetSeed(void) { return m_Generator.GetSeed(); }
|
int GetSeed(void) const { return m_Generator.GetSeed(); }
|
||||||
|
|
||||||
// tolua_end
|
// tolua_end
|
||||||
|
|
||||||
@ -892,6 +892,8 @@ public:
|
|||||||
as at least one requests is active the chunk will be ticked). */
|
as at least one requests is active the chunk will be ticked). */
|
||||||
void SetChunkAlwaysTicked(int a_ChunkX, int a_ChunkZ, bool a_AlwaysTicked = true); // tolua_export
|
void SetChunkAlwaysTicked(int a_ChunkX, int a_ChunkZ, bool a_AlwaysTicked = true); // tolua_export
|
||||||
|
|
||||||
|
/** Returns true if slimes should spawn in the chunk. */
|
||||||
|
bool IsSlimeChunk(int a_ChunkX, int a_ChunkZ) const; // tolua_export
|
||||||
private:
|
private:
|
||||||
|
|
||||||
class cTickThread:
|
class cTickThread:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user