1
0

MoveToWorld must always be provided a world

This commit is contained in:
Tiger Wang
2020-04-10 21:08:19 +01:00
parent e98f93a079
commit 50893667db
5 changed files with 47 additions and 45 deletions

View File

@@ -17,7 +17,7 @@ const double cNetherPortalScanner::AcrossOffset = 0.5;
cNetherPortalScanner::cNetherPortalScanner(cEntity & a_MovingEntity, cWorld * a_DestinationWorld, Vector3d a_DestPosition, int a_MaxY) :
cNetherPortalScanner::cNetherPortalScanner(cEntity & a_MovingEntity, cWorld & a_DestinationWorld, Vector3d a_DestPosition, int a_MaxY) :
m_EntityID(a_MovingEntity.GetUniqueID()),
m_SourceWorld(*a_MovingEntity.GetWorld()),
m_World(a_DestinationWorld),
@@ -39,7 +39,7 @@ cNetherPortalScanner::cNetherPortalScanner(cEntity & a_MovingEntity, cWorld * a_
Add(x, z);
}
}
Enable(*a_DestinationWorld->GetChunkMap());
Enable(*a_DestinationWorld.GetChunkMap());
}
@@ -49,7 +49,7 @@ cNetherPortalScanner::cNetherPortalScanner(cEntity & a_MovingEntity, cWorld * a_
void cNetherPortalScanner::OnChunkAvailable(int a_ChunkX, int a_ChunkZ)
{
cChunkDef::BlockTypes blocks;
m_World->GetChunkBlockTypes(a_ChunkX, a_ChunkZ, blocks);
m_World.GetChunkBlockTypes(a_ChunkX, a_ChunkZ, blocks);
// Iterate through all of the blocks in the chunk
for (unsigned int i = 0; i < cChunkDef::NumBlocks; i++)
@@ -92,7 +92,7 @@ bool cNetherPortalScanner::IsValidBuildLocation(Vector3i a_BlockPos)
{
for (int j = 0; j < PortalLength; j++)
{
BLOCKTYPE blocktype = m_World->GetBlock(a_BlockPos.x + i, a_BlockPos.y, a_BlockPos.z + j);
BLOCKTYPE blocktype = m_World.GetBlock(a_BlockPos.x + i, a_BlockPos.y, a_BlockPos.z + j);
if (!cBlockInfo::IsSolid(blocktype))
{
return false;
@@ -101,7 +101,7 @@ bool cNetherPortalScanner::IsValidBuildLocation(Vector3i a_BlockPos)
// Check the airspace
for (int k = 1; k < PortalHeight; k++)
{
blocktype = m_World->GetBlock(a_BlockPos.x + i, a_BlockPos.y + k, a_BlockPos.z + j);
blocktype = m_World.GetBlock(a_BlockPos.x + i, a_BlockPos.y + k, a_BlockPos.z + j);
if (blocktype != E_BLOCK_AIR)
{
return false;
@@ -121,15 +121,15 @@ bool cNetherPortalScanner::OnAllChunksAvailable(void)
if (m_FoundPortal)
{
// Find the bottom of this portal
while (m_World->GetBlock(m_PortalLoc.x, m_PortalLoc.y, m_PortalLoc.z) == E_BLOCK_NETHER_PORTAL)
while (m_World.GetBlock(m_PortalLoc.x, m_PortalLoc.y, m_PortalLoc.z) == E_BLOCK_NETHER_PORTAL)
{
m_PortalLoc.y -= 1;
}
m_PortalLoc.y += 1;
// Figure out which way the portal is facing
int BXP = m_World->GetBlock(m_PortalLoc.x + 1, m_PortalLoc.y, m_PortalLoc.z);
int BXM = m_World->GetBlock(m_PortalLoc.x - 1, m_PortalLoc.y, m_PortalLoc.z);
int BXP = m_World.GetBlock(m_PortalLoc.x + 1, m_PortalLoc.y, m_PortalLoc.z);
int BXM = m_World.GetBlock(m_PortalLoc.x - 1, m_PortalLoc.y, m_PortalLoc.z);
if ((BXP == E_BLOCK_NETHER_PORTAL) || (BXM == E_BLOCK_NETHER_PORTAL))
{
// The long axis is along X
@@ -208,11 +208,11 @@ void cNetherPortalScanner::BuildNetherPortal(Vector3i a_Location, Direction a_Di
{
if (a_Direction == Direction::Y)
{
m_World->SetBlock(x + i, y + k, z + j, E_BLOCK_AIR, 0);
m_World.SetBlock(x + i, y + k, z + j, E_BLOCK_AIR, 0);
}
else if (a_Direction == Direction::X)
{
m_World->SetBlock(x + j, y + k, z + i, E_BLOCK_AIR, 0);
m_World.SetBlock(x + j, y + k, z + i, E_BLOCK_AIR, 0);
}
}
}
@@ -226,11 +226,11 @@ void cNetherPortalScanner::BuildNetherPortal(Vector3i a_Location, Direction a_Di
// +2 on the short axis because that's where we deposit the entity
if (a_Direction == Direction::Y)
{
m_World->SetBlock(x + 2, y, z + j, E_BLOCK_OBSIDIAN, 0);
m_World.SetBlock(x + 2, y, z + j, E_BLOCK_OBSIDIAN, 0);
}
else if (a_Direction == Direction::X)
{
m_World->SetBlock(x + j, y, z + 2, E_BLOCK_OBSIDIAN, 0);
m_World.SetBlock(x + j, y, z + 2, E_BLOCK_OBSIDIAN, 0);
}
}
}
@@ -240,31 +240,31 @@ void cNetherPortalScanner::BuildNetherPortal(Vector3i a_Location, Direction a_Di
{
if (a_Direction == Direction::Y)
{
m_World->SetBlock(x + 1, y + i, z, E_BLOCK_OBSIDIAN, 0);
m_World->SetBlock(x + 1, y + i, z + 3, E_BLOCK_OBSIDIAN, 0);
m_World.SetBlock(x + 1, y + i, z, E_BLOCK_OBSIDIAN, 0);
m_World.SetBlock(x + 1, y + i, z + 3, E_BLOCK_OBSIDIAN, 0);
}
else if (a_Direction == Direction::X)
{
m_World->SetBlock(x, y + i, z + 1, E_BLOCK_OBSIDIAN, 0);
m_World->SetBlock(x + 3, y + i, z + 1, E_BLOCK_OBSIDIAN, 0);
m_World.SetBlock(x, y + i, z + 1, E_BLOCK_OBSIDIAN, 0);
m_World.SetBlock(x + 3, y + i, z + 1, E_BLOCK_OBSIDIAN, 0);
}
}
for (int i = 0; i < PortalLength; i++)
{
if (a_Direction == Direction::Y)
{
m_World->SetBlock(x + 1, y + 4, z + i, E_BLOCK_OBSIDIAN, 0);
m_World->SetBlock(x + 1, y, z + i, E_BLOCK_OBSIDIAN, 0);
m_World.SetBlock(x + 1, y + 4, z + i, E_BLOCK_OBSIDIAN, 0);
m_World.SetBlock(x + 1, y, z + i, E_BLOCK_OBSIDIAN, 0);
}
else if (a_Direction == Direction::X)
{
m_World->SetBlock(x + i, y + 4, z + 1, E_BLOCK_OBSIDIAN, 0);
m_World->SetBlock(x + i, y, z + 1, E_BLOCK_OBSIDIAN, 0);
m_World.SetBlock(x + i, y + 4, z + 1, E_BLOCK_OBSIDIAN, 0);
m_World.SetBlock(x + i, y, z + 1, E_BLOCK_OBSIDIAN, 0);
}
}
// Fill the frame (place a fire in the bottom)
m_World->SetBlock(x + 1, y + 1, z + 1, E_BLOCK_FIRE, 0);
m_World.SetBlock(x + 1, y + 1, z + 1, E_BLOCK_FIRE, 0);
}