summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorSamuel Barney <samjbarney@gmail.com>2013-10-29 19:43:41 +0100
committerSamuel Barney <samjbarney@gmail.com>2013-10-29 19:43:41 +0100
commite94307c29242e9d7e663c774840568a2b73fd400 (patch)
treea4372da37ee02b0e3912ff73defa3a79e45faa71 /source
parentUpdate to allow the light map to remain the same, but allow alteration of sky light values based on time. (diff)
downloadcuberite-e94307c29242e9d7e663c774840568a2b73fd400.tar
cuberite-e94307c29242e9d7e663c774840568a2b73fd400.tar.gz
cuberite-e94307c29242e9d7e663c774840568a2b73fd400.tar.bz2
cuberite-e94307c29242e9d7e663c774840568a2b73fd400.tar.lz
cuberite-e94307c29242e9d7e663c774840568a2b73fd400.tar.xz
cuberite-e94307c29242e9d7e663c774840568a2b73fd400.tar.zst
cuberite-e94307c29242e9d7e663c774840568a2b73fd400.zip
Diffstat (limited to 'source')
-rw-r--r--source/Chunk.h2
-rw-r--r--source/MobSpawner.cpp24
-rw-r--r--source/MobSpawner.h4
-rw-r--r--source/World.cpp1
-rw-r--r--source/World.h4
5 files changed, 16 insertions, 19 deletions
diff --git a/source/Chunk.h b/source/Chunk.h
index 8648bdd24..63a8f75cd 100644
--- a/source/Chunk.h
+++ b/source/Chunk.h
@@ -329,7 +329,7 @@ public:
/// Same as QueueTickBlock(), but relative coords needn't be in this chunk (uses m_Neighbor-s in such a case), ignores unsuccessful attempts
void UnboundedQueueTickBlock(int a_RelX, int a_RelY, int a_RelZ);
- // Light alterations based on time
+ /// Light alterations based on time
NIBBLETYPE GetTimeAlteredLight(NIBBLETYPE a_Skylight) const;
diff --git a/source/MobSpawner.cpp b/source/MobSpawner.cpp
index 7c7b25b60..d4926bbe5 100644
--- a/source/MobSpawner.cpp
+++ b/source/MobSpawner.cpp
@@ -124,20 +124,15 @@ cMonster::eType cMobSpawner::ChooseMobType(EMCSBiome a_Biome)
-bool cMobSpawner::CanSpawnHere(const cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, cMonster::eType a_MobType, EMCSBiome a_Biome)
+bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, cMonster::eType a_MobType, EMCSBiome a_Biome)
{
BLOCKTYPE TargetBlock;
- BLOCKTYPE BlockAbove;
- BLOCKTYPE BlockBelow;
- NIBBLETYPE BlockLight;
- NIBBLETYPE SkyLight;
if (m_AllowedTypes.find(a_MobType) != m_AllowedTypes.end() && a_Chunk->UnboundedRelGetBlockType(a_RelX, a_RelY, a_RelZ, TargetBlock))
{
-
- a_Chunk->UnboundedRelGetBlockBlockLight(a_RelX, a_RelY, a_RelZ, BlockLight);
- a_Chunk->UnboundedRelGetBlockSkyLight(a_RelX, a_RelY, a_RelZ, SkyLight);
- a_Chunk->UnboundedRelGetBlockType(a_RelX, a_RelY + 1, a_RelZ, BlockAbove);
- a_Chunk->UnboundedRelGetBlockType(a_RelX, a_RelY - 1, a_RelZ, BlockBelow);
+ NIBBLETYPE BlockLight = a_Chunk->GetBlockLight(a_RelX, a_RelY, a_RelZ);
+ NIBBLETYPE SkyLight = a_Chunk->GetSkyLight(a_RelX, a_RelY, a_RelZ);
+ BLOCKTYPE BlockAbove = a_Chunk->GetBlock(a_RelX, a_RelY + 1, a_RelZ);
+ BLOCKTYPE BlockBelow = a_Chunk->GetBlock(a_RelX, a_RelY - 1, a_RelZ);
SkyLight = a_Chunk->GetTimeAlteredLight(SkyLight);
@@ -168,11 +163,10 @@ bool cMobSpawner::CanSpawnHere(const cChunk * a_Chunk, int a_RelX, int a_RelY, i
{
if (a_RelY < 250)
{
- BLOCKTYPE BlockTop;
- a_Chunk->UnboundedRelGetBlockType(a_RelX, a_RelY + 2, a_RelZ, BlockTop);
+ BLOCKTYPE BlockTop = a_Chunk->GetBlock(a_RelX, a_RelY + 2, a_RelZ);
if (BlockTop == E_BLOCK_AIR)
{
- a_Chunk->UnboundedRelGetBlockType(a_RelX, a_RelY + 3, a_RelZ, BlockTop);
+ BlockTop = a_Chunk->GetBlock(a_RelX, a_RelY + 3, a_RelZ);
return (TargetBlock == E_BLOCK_AIR) && (BlockAbove == E_BLOCK_AIR) && (BlockTop == E_BLOCK_AIR) && (!g_BlockTransparent[BlockBelow]) &&
(SkyLight <= 7) && (BlockLight <= 7);
}
@@ -227,7 +221,7 @@ bool cMobSpawner::CanSpawnHere(const cChunk * a_Chunk, int a_RelX, int a_RelY, i
-cMonster* cMobSpawner::TryToSpawnHere(const cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, EMCSBiome a_Biome, int& a_MaxPackSize)
+cMonster* cMobSpawner::TryToSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, EMCSBiome a_Biome, int& a_MaxPackSize)
{
cMonster* toReturn = NULL;
if (m_NewPack)
@@ -248,6 +242,8 @@ cMonster* cMobSpawner::TryToSpawnHere(const cChunk * a_Chunk, int a_RelX, int a_
m_NewPack = false;
}
+ // Make sure we are looking at the right chunk to spawn in
+ a_Chunk = a_Chunk->GetRelNeighborChunkAdjustCoords(a_RelX, a_RelZ);
if (CanSpawnHere(a_Chunk, a_RelX, a_RelY, a_RelZ, m_MobType, a_Biome))
{
diff --git a/source/MobSpawner.h b/source/MobSpawner.h
index 22adb00f4..ea6636310 100644
--- a/source/MobSpawner.h
+++ b/source/MobSpawner.h
@@ -39,7 +39,7 @@ public :
// if this is the first of a Pack : determine the type of monster
// BlockType & BlockMeta are used to decide what kind of Mob can Spawn here
// MaxPackSize is set to the maximal size for a pack this type of mob
- cMonster * TryToSpawnHere(const cChunk * a_Chunk, int A_RelX, int a_RelY, int a_RelZ, EMCSBiome a_Biome, int& a_MaxPackSize);
+ cMonster * TryToSpawnHere(cChunk * a_Chunk, int A_RelX, int a_RelY, int a_RelZ, EMCSBiome a_Biome, int& a_MaxPackSize);
// mark the beginning of a new Pack
// all mobs of the same Pack are the same type
@@ -53,7 +53,7 @@ public :
protected :
// return true if specified type of mob can spawn on specified block
- bool CanSpawnHere(const cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, cMonster::eType a_MobType, EMCSBiome a_Biome);
+ bool CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, cMonster::eType a_MobType, EMCSBiome a_Biome);
// return a random type that can spawn on specified biome.
// returns E_ENTITY_TYPE_DONOTUSE if none is possible
diff --git a/source/World.cpp b/source/World.cpp
index dcd51afcf..ad34dc6a5 100644
--- a/source/World.cpp
+++ b/source/World.cpp
@@ -609,6 +609,7 @@ void cWorld::Tick(float a_Dt)
m_WorldAge = (Int64)(m_WorldAgeSecs * 20.0);
m_TimeOfDay = (Int64)(m_TimeOfDaySecs * 20.0);
+ // Updates the sky darkness based on current time of day
UpdateSkyDarkness();
// Broadcast time update every 40 ticks (2 seconds)
diff --git a/source/World.h b/source/World.h
index 5976321e1..c4fd06d0b 100644
--- a/source/World.h
+++ b/source/World.h
@@ -593,7 +593,7 @@ public:
void TabCompleteUserName(const AString & a_Text, AStringVector & a_Results);
/// Get the current darkness level based on the time
- Int64 GetSkyDarkness() { return m_SkyDarkness; }
+ NIBBLETYPE GetSkyDarkness() { return m_SkyDarkness; }
private:
@@ -639,7 +639,7 @@ private:
Int64 m_LastSave; // The last WorldAge (in ticks) in which save-all was triggerred
std::map<cMonster::eFamily,Int64> m_LastSpawnMonster; // The last WorldAge (in ticks) in which a monster was spawned (for each megatype of monster) // MG TODO : find a way to optimize without creating unmaintenability (if mob IDs are becoming unrowed)
- Int64 m_SkyDarkness;
+ NIBBLETYPE m_SkyDarkness;
eGameMode m_GameMode;
bool m_bEnabledPVP;