From d73a0cd8b020b0a589e496bed56e6740314d9101 Mon Sep 17 00:00:00 2001 From: Samuel Barney Date: Mon, 21 Oct 2013 09:41:48 -0600 Subject: Current Mob Spawning code. --- source/Chunk.cpp | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'source/Chunk.cpp') diff --git a/source/Chunk.cpp b/source/Chunk.cpp index 21401163b..944cf82d9 100644 --- a/source/Chunk.cpp +++ b/source/Chunk.cpp @@ -539,14 +539,29 @@ void cChunk::SpawnMobs(cMobSpawner& a_MobSpawner) // MG TODO: fix the "light" thing, I'm pretty sure that UnboundedRelGetBlock s not returning the right thing // MG TODO : check that "Level" really means Y - cEntity* newMob = a_MobSpawner.TryToSpawnHere(BlockType, BlockMeta, BlockType_below, BlockMeta_below, BlockType_above, BlockMeta_above, Biome, Try_Y, MaxNbOfSuccess); - if (newMob) + NIBBLETYPE SkyLight = GetSkyLight(Try_X, Try_Y+1, Try_Z); + if (!SkyLight) + SkyLight = GetSkyLight(Try_X, Try_Y, Try_Z); + if (!SkyLight) + SkyLight = GetSkyLight(Try_X, Try_Y - 1, Try_Z); + + NIBBLETYPE BlockLight = GetBlockLight(Try_X, Try_Y+1, Try_Z); + if (!BlockLight) + BlockLight = GetBlockLight(Try_X, Try_Y, Try_Z); + if (!BlockLight) + BlockLight = GetBlockLight(Try_X, Try_Y - 1, Try_Z); + + if (IsLightValid()) { - int WorldX, WorldY, WorldZ; - PositionToWorldPosition(Try_X, Try_Y, Try_Z, WorldX, WorldY, WorldZ); - newMob->SetPosition(WorldX, WorldY, WorldZ); - LOGD("Spawning %s #%i at %d,%d,%d",newMob->GetClass(),newMob->GetUniqueID(),WorldX, WorldY, WorldZ); - NumberOfSuccess++; + cEntity* newMob = a_MobSpawner.TryToSpawnHere(BlockType, BlockMeta, BlockType_below, BlockMeta_below, BlockType_above, BlockMeta_above, SkyLight, BlockLight, Biome, Try_Y, MaxNbOfSuccess); + if (newMob) + { + int WorldX, WorldY, WorldZ; + PositionToWorldPosition(Try_X, Try_Y, Try_Z, WorldX, WorldY, WorldZ); + newMob->SetPosition(WorldX, WorldY, WorldZ); + LOGD("Spawning %s #%i at %d,%d,%d",newMob->GetClass(),newMob->GetUniqueID(),WorldX, WorldY, WorldZ); + NumberOfSuccess++; + } } } -- cgit v1.2.3 From 56fa632d5e2b48a81f2a90878cb3656d1d3d563c Mon Sep 17 00:00:00 2001 From: Samuel Barney Date: Mon, 21 Oct 2013 10:03:05 -0600 Subject: Swapped which block is checked for light first. --- source/Chunk.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source/Chunk.cpp') diff --git a/source/Chunk.cpp b/source/Chunk.cpp index 944cf82d9..5a54371ad 100644 --- a/source/Chunk.cpp +++ b/source/Chunk.cpp @@ -539,15 +539,15 @@ void cChunk::SpawnMobs(cMobSpawner& a_MobSpawner) // MG TODO: fix the "light" thing, I'm pretty sure that UnboundedRelGetBlock s not returning the right thing // MG TODO : check that "Level" really means Y - NIBBLETYPE SkyLight = GetSkyLight(Try_X, Try_Y+1, Try_Z); + NIBBLETYPE SkyLight = GetSkyLight(Try_X, Try_Y, Try_Z); if (!SkyLight) - SkyLight = GetSkyLight(Try_X, Try_Y, Try_Z); + SkyLight = GetSkyLight(Try_X, Try_Y + 1, Try_Z); if (!SkyLight) SkyLight = GetSkyLight(Try_X, Try_Y - 1, Try_Z); - NIBBLETYPE BlockLight = GetBlockLight(Try_X, Try_Y+1, Try_Z); + NIBBLETYPE BlockLight = GetBlockLight(Try_X, Try_Y, Try_Z); if (!BlockLight) - BlockLight = GetBlockLight(Try_X, Try_Y, Try_Z); + BlockLight = GetBlockLight(Try_X, Try_Y + 1, Try_Z); if (!BlockLight) BlockLight = GetBlockLight(Try_X, Try_Y - 1, Try_Z); -- cgit v1.2.3 From 6e361f195fa61ff6585f78dd7cd7302b1dba5619 Mon Sep 17 00:00:00 2001 From: Samuel Barney Date: Mon, 21 Oct 2013 14:38:38 -0600 Subject: Added two new unbounded del functions to deal with looking up the lighting. --- source/Chunk.cpp | 111 +++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 100 insertions(+), 11 deletions(-) (limited to 'source/Chunk.cpp') diff --git a/source/Chunk.cpp b/source/Chunk.cpp index 5a54371ad..ea6fed50c 100644 --- a/source/Chunk.cpp +++ b/source/Chunk.cpp @@ -539,17 +539,10 @@ void cChunk::SpawnMobs(cMobSpawner& a_MobSpawner) // MG TODO: fix the "light" thing, I'm pretty sure that UnboundedRelGetBlock s not returning the right thing // MG TODO : check that "Level" really means Y - NIBBLETYPE SkyLight = GetSkyLight(Try_X, Try_Y, Try_Z); - if (!SkyLight) - SkyLight = GetSkyLight(Try_X, Try_Y + 1, Try_Z); - if (!SkyLight) - SkyLight = GetSkyLight(Try_X, Try_Y - 1, Try_Z); - - NIBBLETYPE BlockLight = GetBlockLight(Try_X, Try_Y, Try_Z); - if (!BlockLight) - BlockLight = GetBlockLight(Try_X, Try_Y + 1, Try_Z); - if (!BlockLight) - BlockLight = GetBlockLight(Try_X, Try_Y - 1, Try_Z); + + NIBBLETYPE SkyLight = UnboundedRelGetSkyLight(Try_X, Try_Y, Try_Z); + + NIBBLETYPE BlockLight = UnboundedRelGetBlockLight(Try_X, Try_Y, Try_Z); if (IsLightValid()) { @@ -1363,6 +1356,102 @@ void cChunk::UnboundedQueueTickBlock(int a_RelX, int a_RelY, int a_RelZ) +NIBBLETYPE cChunk::UnboundedRelGetSkyLight(int a_RelX, int a_RelY, int a_RelZ) +{ +if ((a_RelY < 0) || (a_RelY > cChunkDef::Height)) + { + LOGWARNING("UnboundedRelGetSkyLight(): requesting a block with a_RelY out of range: %d", a_RelY); + return -1; + } + + // Is it in this chunk? + if ((a_RelX >= 0) && (a_RelX < cChunkDef::Width) && (a_RelZ >= 0) && (a_RelZ < cChunkDef::Width)) + { + if (!IsValid()) + { + return -1; + } + return GetSkyLight(a_RelX, a_RelY, a_RelZ); + } + + // Not in this chunk, try walking the neighbors first: + if ((a_RelX < 0) && (m_NeighborXM != NULL)) + { + return m_NeighborXM->UnboundedRelGetSkyLight(a_RelX + cChunkDef::Width, a_RelY, a_RelZ); + } + if ((a_RelX >= cChunkDef::Width) && (m_NeighborXP != NULL)) + { + return m_NeighborXP->UnboundedRelGetSkyLight(a_RelX - cChunkDef::Width, a_RelY, a_RelZ); + } + if ((a_RelZ < 0) && (m_NeighborZM != NULL)) + { + return m_NeighborZM->UnboundedRelGetSkyLight(a_RelX, a_RelY, a_RelZ + cChunkDef::Width); + } + if ((a_RelZ >= cChunkDef::Width) && (m_NeighborZP != NULL)) + { + return m_NeighborZP->UnboundedRelGetSkyLight(a_RelX, a_RelY, a_RelZ - cChunkDef::Width); + } + + // Neighbors not available, use the chunkmap to locate the chunk: + return m_ChunkMap->GetBlockSkyLight( + m_PosX * cChunkDef::Width + a_RelX, + ZERO_CHUNK_Y * cChunkDef::Height + a_RelY, + m_PosZ * cChunkDef::Width + a_RelZ + ); +} + + + + + +NIBBLETYPE cChunk::UnboundedRelGetBlockLight(int a_RelX, int a_RelY, int a_RelZ) +{ +if ((a_RelY < 0) || (a_RelY > cChunkDef::Height)) + { + LOGWARNING("UnboundedRelGetBlockLight(): requesting a block with a_RelY out of range: %d", a_RelY); + return -1; + } + + // Is it in this chunk? + if ((a_RelX >= 0) && (a_RelX < cChunkDef::Width) && (a_RelZ >= 0) && (a_RelZ < cChunkDef::Width)) + { + if (!IsValid()) + { + return -1; + } + return GetBlockLight(a_RelX, a_RelY, a_RelZ); + } + + // Not in this chunk, try walking the neighbors first: + if ((a_RelX < 0) && (m_NeighborXM != NULL)) + { + return m_NeighborXM->UnboundedRelGetBlockLight(a_RelX + cChunkDef::Width, a_RelY, a_RelZ); + } + if ((a_RelX >= cChunkDef::Width) && (m_NeighborXP != NULL)) + { + return m_NeighborXP->UnboundedRelGetBlockLight(a_RelX - cChunkDef::Width, a_RelY, a_RelZ); + } + if ((a_RelZ < 0) && (m_NeighborZM != NULL)) + { + return m_NeighborZM->UnboundedRelGetBlockLight(a_RelX, a_RelY, a_RelZ + cChunkDef::Width); + } + if ((a_RelZ >= cChunkDef::Width) && (m_NeighborZP != NULL)) + { + return m_NeighborZP->UnboundedRelGetBlockLight(a_RelX, a_RelY, a_RelZ - cChunkDef::Width); + } + + // Neighbors not available, use the chunkmap to locate the chunk: + return m_ChunkMap->GetBlockBlockLight( + m_PosX * cChunkDef::Width + a_RelX, + ZERO_CHUNK_Y * cChunkDef::Height + a_RelY, + m_PosZ * cChunkDef::Width + a_RelZ + ); +} + + + + + int cChunk::GetHeight( int a_X, int a_Z ) { ASSERT((a_X >= 0) && (a_X < Width) && (a_Z >= 0) && (a_Z < Width)); -- cgit v1.2.3 From d6d73a1754b67bc38404dcac54947812076b83ea Mon Sep 17 00:00:00 2001 From: Samuel Barney Date: Tue, 22 Oct 2013 17:10:32 -0600 Subject: Invalid light value is now 127 --- source/Chunk.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source/Chunk.cpp') diff --git a/source/Chunk.cpp b/source/Chunk.cpp index ea6fed50c..32a8b5c0f 100644 --- a/source/Chunk.cpp +++ b/source/Chunk.cpp @@ -544,7 +544,7 @@ void cChunk::SpawnMobs(cMobSpawner& a_MobSpawner) NIBBLETYPE BlockLight = UnboundedRelGetBlockLight(Try_X, Try_Y, Try_Z); - if (IsLightValid()) + if (IsLightValid() && (SkyLight != 127) && (BlockLight != 127)) { cEntity* newMob = a_MobSpawner.TryToSpawnHere(BlockType, BlockMeta, BlockType_below, BlockMeta_below, BlockType_above, BlockMeta_above, SkyLight, BlockLight, Biome, Try_Y, MaxNbOfSuccess); if (newMob) @@ -1361,7 +1361,7 @@ NIBBLETYPE cChunk::UnboundedRelGetSkyLight(int a_RelX, int a_RelY, int a_RelZ) if ((a_RelY < 0) || (a_RelY > cChunkDef::Height)) { LOGWARNING("UnboundedRelGetSkyLight(): requesting a block with a_RelY out of range: %d", a_RelY); - return -1; + return 127; } // Is it in this chunk? @@ -1369,7 +1369,7 @@ if ((a_RelY < 0) || (a_RelY > cChunkDef::Height)) { if (!IsValid()) { - return -1; + return 127; } return GetSkyLight(a_RelX, a_RelY, a_RelZ); } @@ -1409,7 +1409,7 @@ NIBBLETYPE cChunk::UnboundedRelGetBlockLight(int a_RelX, int a_RelY, int a_RelZ) if ((a_RelY < 0) || (a_RelY > cChunkDef::Height)) { LOGWARNING("UnboundedRelGetBlockLight(): requesting a block with a_RelY out of range: %d", a_RelY); - return -1; + return 127; } // Is it in this chunk? @@ -1417,7 +1417,7 @@ if ((a_RelY < 0) || (a_RelY > cChunkDef::Height)) { if (!IsValid()) { - return -1; + return 127; } return GetBlockLight(a_RelX, a_RelY, a_RelZ); } -- cgit v1.2.3 From f558f3c6d29931090378f75f7ea0ba84e81fead0 Mon Sep 17 00:00:00 2001 From: Samuel Barney Date: Wed, 23 Oct 2013 17:41:24 -0600 Subject: Removed my hackish Light functions --- source/Chunk.cpp | 96 -------------------------------------------------------- 1 file changed, 96 deletions(-) (limited to 'source/Chunk.cpp') diff --git a/source/Chunk.cpp b/source/Chunk.cpp index 32a8b5c0f..2e81bf852 100644 --- a/source/Chunk.cpp +++ b/source/Chunk.cpp @@ -1356,102 +1356,6 @@ void cChunk::UnboundedQueueTickBlock(int a_RelX, int a_RelY, int a_RelZ) -NIBBLETYPE cChunk::UnboundedRelGetSkyLight(int a_RelX, int a_RelY, int a_RelZ) -{ -if ((a_RelY < 0) || (a_RelY > cChunkDef::Height)) - { - LOGWARNING("UnboundedRelGetSkyLight(): requesting a block with a_RelY out of range: %d", a_RelY); - return 127; - } - - // Is it in this chunk? - if ((a_RelX >= 0) && (a_RelX < cChunkDef::Width) && (a_RelZ >= 0) && (a_RelZ < cChunkDef::Width)) - { - if (!IsValid()) - { - return 127; - } - return GetSkyLight(a_RelX, a_RelY, a_RelZ); - } - - // Not in this chunk, try walking the neighbors first: - if ((a_RelX < 0) && (m_NeighborXM != NULL)) - { - return m_NeighborXM->UnboundedRelGetSkyLight(a_RelX + cChunkDef::Width, a_RelY, a_RelZ); - } - if ((a_RelX >= cChunkDef::Width) && (m_NeighborXP != NULL)) - { - return m_NeighborXP->UnboundedRelGetSkyLight(a_RelX - cChunkDef::Width, a_RelY, a_RelZ); - } - if ((a_RelZ < 0) && (m_NeighborZM != NULL)) - { - return m_NeighborZM->UnboundedRelGetSkyLight(a_RelX, a_RelY, a_RelZ + cChunkDef::Width); - } - if ((a_RelZ >= cChunkDef::Width) && (m_NeighborZP != NULL)) - { - return m_NeighborZP->UnboundedRelGetSkyLight(a_RelX, a_RelY, a_RelZ - cChunkDef::Width); - } - - // Neighbors not available, use the chunkmap to locate the chunk: - return m_ChunkMap->GetBlockSkyLight( - m_PosX * cChunkDef::Width + a_RelX, - ZERO_CHUNK_Y * cChunkDef::Height + a_RelY, - m_PosZ * cChunkDef::Width + a_RelZ - ); -} - - - - - -NIBBLETYPE cChunk::UnboundedRelGetBlockLight(int a_RelX, int a_RelY, int a_RelZ) -{ -if ((a_RelY < 0) || (a_RelY > cChunkDef::Height)) - { - LOGWARNING("UnboundedRelGetBlockLight(): requesting a block with a_RelY out of range: %d", a_RelY); - return 127; - } - - // Is it in this chunk? - if ((a_RelX >= 0) && (a_RelX < cChunkDef::Width) && (a_RelZ >= 0) && (a_RelZ < cChunkDef::Width)) - { - if (!IsValid()) - { - return 127; - } - return GetBlockLight(a_RelX, a_RelY, a_RelZ); - } - - // Not in this chunk, try walking the neighbors first: - if ((a_RelX < 0) && (m_NeighborXM != NULL)) - { - return m_NeighborXM->UnboundedRelGetBlockLight(a_RelX + cChunkDef::Width, a_RelY, a_RelZ); - } - if ((a_RelX >= cChunkDef::Width) && (m_NeighborXP != NULL)) - { - return m_NeighborXP->UnboundedRelGetBlockLight(a_RelX - cChunkDef::Width, a_RelY, a_RelZ); - } - if ((a_RelZ < 0) && (m_NeighborZM != NULL)) - { - return m_NeighborZM->UnboundedRelGetBlockLight(a_RelX, a_RelY, a_RelZ + cChunkDef::Width); - } - if ((a_RelZ >= cChunkDef::Width) && (m_NeighborZP != NULL)) - { - return m_NeighborZP->UnboundedRelGetBlockLight(a_RelX, a_RelY, a_RelZ - cChunkDef::Width); - } - - // Neighbors not available, use the chunkmap to locate the chunk: - return m_ChunkMap->GetBlockBlockLight( - m_PosX * cChunkDef::Width + a_RelX, - ZERO_CHUNK_Y * cChunkDef::Height + a_RelY, - m_PosZ * cChunkDef::Width + a_RelZ - ); -} - - - - - int cChunk::GetHeight( int a_X, int a_Z ) { ASSERT((a_X >= 0) && (a_X < Width) && (a_Z >= 0) && (a_Z < Width)); -- cgit v1.2.3 From 00480a1d9a4c0c48b32cfe7b2f3f20270dcb19ce Mon Sep 17 00:00:00 2001 From: Samuel Barney Date: Wed, 23 Oct 2013 17:51:14 -0600 Subject: Using provided UnboundedRelGetBlockBlockLight and UnboundedRelGetBlockSkyLight. --- source/Chunk.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'source/Chunk.cpp') diff --git a/source/Chunk.cpp b/source/Chunk.cpp index e4e5a7ca1..35da4c266 100644 --- a/source/Chunk.cpp +++ b/source/Chunk.cpp @@ -536,15 +536,13 @@ void cChunk::SpawnMobs(cMobSpawner& a_MobSpawner) // check player and playerspawn presence < 24 blocks // check mobs presence on the block - // MG TODO: fix the "light" thing, I'm pretty sure that UnboundedRelGetBlock s not returning the right thing - // MG TODO : check that "Level" really means Y - NIBBLETYPE SkyLight = UnboundedRelGetSkyLight(Try_X, Try_Y, Try_Z); + NIBBLETYPE SkyLight = 0; - NIBBLETYPE BlockLight = UnboundedRelGetBlockLight(Try_X, Try_Y, Try_Z); + NIBBLETYPE BlockLight = 0; - if (IsLightValid() && (SkyLight != 127) && (BlockLight != 127)) + if (IsLightValid() && (UnboundedRelGetBlockBlockLight(Try_X, Try_Y, Try_Z, BlockLight)) && (UnboundedRelGetBlockSkyLight(Try_X, Try_Y, Try_Z, SkyLight))) { cEntity* newMob = a_MobSpawner.TryToSpawnHere(BlockType, BlockMeta, BlockType_below, BlockMeta_below, BlockType_above, BlockMeta_above, SkyLight, BlockLight, Biome, Try_Y, MaxNbOfSuccess); if (newMob) -- cgit v1.2.3 From 0b853dca93fdeca797825d4a0959cb3f3127dc04 Mon Sep 17 00:00:00 2001 From: Samuel Barney Date: Sat, 26 Oct 2013 03:50:34 -0600 Subject: Moving spawning position to the center of the block. --- source/Chunk.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source/Chunk.cpp') diff --git a/source/Chunk.cpp b/source/Chunk.cpp index 35da4c266..0892020e2 100644 --- a/source/Chunk.cpp +++ b/source/Chunk.cpp @@ -549,7 +549,9 @@ void cChunk::SpawnMobs(cMobSpawner& a_MobSpawner) { int WorldX, WorldY, WorldZ; PositionToWorldPosition(Try_X, Try_Y, Try_Z, WorldX, WorldY, WorldZ); - newMob->SetPosition(WorldX, WorldY, WorldZ); + double ActualX = WorldX + 0.5; + double ActualZ = WorldZ + 0.5; + newMob->SetPosition(ActualX, WorldY, ActualZ); LOGD("Spawning %s #%i at %d,%d,%d",newMob->GetClass(),newMob->GetUniqueID(),WorldX, WorldY, WorldZ); NumberOfSuccess++; } -- cgit v1.2.3 From 16bac5ace9a2388cee3fd0d9192b7cd69a06152d Mon Sep 17 00:00:00 2001 From: Samuel Barney Date: Mon, 28 Oct 2013 09:49:06 -0600 Subject: Made mob spawning code use the chunk so that it could use varying sizes of areas for different mobs. --- source/Chunk.cpp | 52 ++++++++++++++++++++-------------------------------- 1 file changed, 20 insertions(+), 32 deletions(-) (limited to 'source/Chunk.cpp') diff --git a/source/Chunk.cpp b/source/Chunk.cpp index 0892020e2..637b72b2b 100644 --- a/source/Chunk.cpp +++ b/source/Chunk.cpp @@ -519,42 +519,30 @@ void cChunk::SpawnMobs(cMobSpawner& a_MobSpawner) ASSERT(Try_Y > 0); ASSERT(Try_Y < cChunkDef::Height-1); - BLOCKTYPE BlockType; - NIBBLETYPE BlockMeta; - BLOCKTYPE BlockType_below; - NIBBLETYPE BlockMeta_below; - BLOCKTYPE BlockType_above; - NIBBLETYPE BlockMeta_above; - if (UnboundedRelGetBlock(Try_X, Try_Y , Try_Z, BlockType, BlockMeta) && - UnboundedRelGetBlock(Try_X, Try_Y-1, Try_Z, BlockType_below, BlockMeta_below)&& - UnboundedRelGetBlock(Try_X, Try_Y+1, Try_Z, BlockType_above, BlockMeta_above) - ) - { - EMCSBiome Biome = m_ChunkMap->GetBiomeAt (Try_X, Try_Z); - // MG TODO : - // Moon cycle (for slime) - // check player and playerspawn presence < 24 blocks - // check mobs presence on the block + EMCSBiome Biome = m_ChunkMap->GetBiomeAt (Try_X, Try_Z); + // MG TODO : + // Moon cycle (for slime) + // check player and playerspawn presence < 24 blocks + // check mobs presence on the block - // MG TODO : check that "Level" really means Y - - NIBBLETYPE SkyLight = 0; + // MG TODO : check that "Level" really means Y + + NIBBLETYPE SkyLight = 0; - NIBBLETYPE BlockLight = 0; + NIBBLETYPE BlockLight = 0; - if (IsLightValid() && (UnboundedRelGetBlockBlockLight(Try_X, Try_Y, Try_Z, BlockLight)) && (UnboundedRelGetBlockSkyLight(Try_X, Try_Y, Try_Z, SkyLight))) + if (IsLightValid()) + { + cEntity* newMob = a_MobSpawner.TryToSpawnHere(this, Try_X, Try_Y, Try_Z, Biome, MaxNbOfSuccess); + if (newMob) { - cEntity* newMob = a_MobSpawner.TryToSpawnHere(BlockType, BlockMeta, BlockType_below, BlockMeta_below, BlockType_above, BlockMeta_above, SkyLight, BlockLight, Biome, Try_Y, MaxNbOfSuccess); - if (newMob) - { - int WorldX, WorldY, WorldZ; - PositionToWorldPosition(Try_X, Try_Y, Try_Z, WorldX, WorldY, WorldZ); - double ActualX = WorldX + 0.5; - double ActualZ = WorldZ + 0.5; - newMob->SetPosition(ActualX, WorldY, ActualZ); - LOGD("Spawning %s #%i at %d,%d,%d",newMob->GetClass(),newMob->GetUniqueID(),WorldX, WorldY, WorldZ); - NumberOfSuccess++; - } + int WorldX, WorldY, WorldZ; + PositionToWorldPosition(Try_X, Try_Y, Try_Z, WorldX, WorldY, WorldZ); + double ActualX = WorldX + 0.5; + double ActualZ = WorldZ + 0.5; + newMob->SetPosition(ActualX, WorldY, ActualZ); + LOGD("Spawning %s #%i at %d,%d,%d",newMob->GetClass(),newMob->GetUniqueID(),WorldX, WorldY, WorldZ); + NumberOfSuccess++; } } -- cgit v1.2.3 From 47283f9daa4a19514c211ceb1dc1e4bc7c06b26d Mon Sep 17 00:00:00 2001 From: Samuel Barney Date: Mon, 28 Oct 2013 16:38:34 -0600 Subject: Got spiders and other mobs respecting night and day for spawning --- source/Chunk.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/Chunk.cpp') diff --git a/source/Chunk.cpp b/source/Chunk.cpp index 637b72b2b..038831896 100644 --- a/source/Chunk.cpp +++ b/source/Chunk.cpp @@ -533,7 +533,8 @@ void cChunk::SpawnMobs(cMobSpawner& a_MobSpawner) if (IsLightValid()) { - cEntity* newMob = a_MobSpawner.TryToSpawnHere(this, Try_X, Try_Y, Try_Z, Biome, MaxNbOfSuccess); + int TimeOfDay = m_World->GetTimeOfDay(); + cEntity* newMob = a_MobSpawner.TryToSpawnHere(this, Try_X, Try_Y, Try_Z, Biome, TimeOfDay, MaxNbOfSuccess); if (newMob) { int WorldX, WorldY, WorldZ; -- cgit v1.2.3 From e1a06153b2e93473af58e1d801998ff7f388dc6d Mon Sep 17 00:00:00 2001 From: Samuel Barney Date: Tue, 29 Oct 2013 10:44:51 -0600 Subject: Update to allow the light map to remain the same, but allow alteration of sky light values based on time. --- source/Chunk.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'source/Chunk.cpp') diff --git a/source/Chunk.cpp b/source/Chunk.cpp index c419cf7f2..b38f5ea19 100644 --- a/source/Chunk.cpp +++ b/source/Chunk.cpp @@ -533,8 +533,7 @@ void cChunk::SpawnMobs(cMobSpawner& a_MobSpawner) if (IsLightValid()) { - int TimeOfDay = m_World->GetTimeOfDay(); - cEntity* newMob = a_MobSpawner.TryToSpawnHere(this, Try_X, Try_Y, Try_Z, Biome, TimeOfDay, MaxNbOfSuccess); + cEntity* newMob = a_MobSpawner.TryToSpawnHere(this, Try_X, Try_Y, Try_Z, Biome, MaxNbOfSuccess); if (newMob) { int WorldX, WorldY, WorldZ; @@ -2787,6 +2786,16 @@ Vector3i cChunk::PositionToWorldPosition(int a_RelX, int a_RelY, int a_RelZ) +NIBBLETYPE cChunk::GetTimeAlteredLight(NIBBLETYPE a_Skylight) const +{ + a_Skylight -= m_World->GetSkyDarkness(); + return (a_Skylight < 16)? a_Skylight : 0; +} + + + + + #if !C_CHUNK_USE_INLINE # include "cChunk.inl.h" #endif -- cgit v1.2.3 From 7157c392fa81f699ec66a5eda495a9bad465ea81 Mon Sep 17 00:00:00 2001 From: Samuel Barney Date: Wed, 30 Oct 2013 16:14:42 -0600 Subject: Last of the nitpicker note fixes. Added some inline commenting. --- source/Chunk.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'source/Chunk.cpp') diff --git a/source/Chunk.cpp b/source/Chunk.cpp index b38f5ea19..be75eae41 100644 --- a/source/Chunk.cpp +++ b/source/Chunk.cpp @@ -2789,6 +2789,7 @@ Vector3i cChunk::PositionToWorldPosition(int a_RelX, int a_RelY, int a_RelZ) NIBBLETYPE cChunk::GetTimeAlteredLight(NIBBLETYPE a_Skylight) const { a_Skylight -= m_World->GetSkyDarkness(); + // Because NIBBLETYPE is unsigned, we clamp it to 0 .. 15 by checking for values above 15 return (a_Skylight < 16)? a_Skylight : 0; } -- cgit v1.2.3