From 19ea5d5423a04e91576f8f5772aebedbff6292cb Mon Sep 17 00:00:00 2001 From: samoatesgames Date: Fri, 13 Nov 2015 15:08:16 +0000 Subject: Improved spawn location calculations. - Supports Overworld and Nether spawns. - Supports spawning under objects, but still above ground (e.g. under the leaves of a tree). - Protects against spawning in oceans. - Protects against spawning in water. - Uses a radial search about the origin, rather than a linear. - Correctly calculates Nether spawn on spawn world generation (fixes: cuberite#2548) - Fixes a bug in CheckPlayerSpawnPoint() where the X offset was used in both the X and Z coords (BLOCKTYPE BlockType = GetBlock(a_PosX + Coords[i].x, a_PosY, a_PosZ + Coords[i].x);) --- src/World.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/World.h') diff --git a/src/World.h b/src/World.h index 30ac52763..512654ab8 100644 --- a/src/World.h +++ b/src/World.h @@ -1042,7 +1042,11 @@ private: void UpdateSkyDarkness(void); /** Generates a random spawnpoint on solid land by walking chunks and finding their biomes */ - void GenerateRandomSpawn(void); + void GenerateRandomSpawn(int a_MaxSpawnRadius); + + /** Can the specified coordinates be used as a spawn point? + Returns true if spawn position is valid and sets a_Y to the valid spawn height */ + bool CanSpawnAt(double a_X, double & a_Y, double a_Z); /** Check if player starting point is acceptable */ bool CheckPlayerSpawnPoint(int a_PosX, int a_PosY, int a_PosZ); -- cgit v1.2.3