You can change axis ordering by setting AXIS_ORDER to AXIS_ORDER_XZY in cChunk.h !THIS WILL SCREW UP YOUR WORLDS THOUGH!
Still need to update world storage schemes, converters and such git-svn-id: http://mc-server.googlecode.com/svn/trunk@390 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
parent
62ba8f5a20
commit
68f3ea56bd
@ -539,7 +539,11 @@ void cChunk::Tick(float a_Dt, MTRand & a_TickRandom)
|
||||
|
||||
case E_BLOCK_GRASS:
|
||||
{
|
||||
#if AXIS_ORDER == AXIS_ORDER_YZX
|
||||
char AboveBlock = GetBlock( Index+1 );
|
||||
#else if AXIS_ORDER == AXIS_ORDER_XZY
|
||||
char AboveBlock = GetBlock( Index + (c_ChunkWidth*c_ChunkWidth) );
|
||||
#endif
|
||||
if (!( (AboveBlock == 0) || (g_BlockOneHitDig[AboveBlock]) || (g_BlockTransparent[AboveBlock]) ) ) //changed to not allow grass if any one hit object is on top
|
||||
{
|
||||
FastSetBlock( m_BlockTickX, m_BlockTickY, m_BlockTickZ, E_BLOCK_DIRT, GetNibble( m_BlockMeta, Index ) );
|
||||
|
@ -26,6 +26,10 @@ It will help us when the new chunk format comes out and we need to patch everyth
|
||||
*/
|
||||
#define ZERO_CHUNK_Y 0
|
||||
|
||||
// Used to smoothly convert to new axis ordering. One will be removed when deemed stable.
|
||||
#define AXIS_ORDER_YZX 1 // Original (1.1-)
|
||||
#define AXIS_ORDER_XZY 2 // New (1.2+)
|
||||
#define AXIS_ORDER AXIS_ORDER_YZX
|
||||
|
||||
|
||||
|
||||
@ -234,23 +238,28 @@ public:
|
||||
|
||||
inline static unsigned int MakeIndexNoCheck(int x, int y, int z)
|
||||
{
|
||||
return y + (z * c_ChunkHeight) + (x * c_ChunkHeight * c_ChunkWidth); // 1.1 is YZX
|
||||
//return x + (z * c_ChunkWidth) + (y * c_ChunkWidth * c_ChunkHeight); // 1.2 is XZY
|
||||
#if AXIS_ORDER == AXIS_ORDER_XZY
|
||||
return x + (z * c_ChunkWidth) + (y * c_ChunkWidth * c_ChunkWidth); // 1.2 is XZY
|
||||
#else if AXIS_ORDER == AXIS_ORDER_YZX
|
||||
return y + (z * c_ChunkHeight) + (x * c_ChunkHeight * c_ChunkWidth); // 1.1 is YZX
|
||||
#endif
|
||||
}
|
||||
|
||||
inline static Vector3i IndexToCoordinate( unsigned int index )
|
||||
{
|
||||
// return Vector3i( // 1.2
|
||||
// index % c_ChunkWidth, // X
|
||||
// index / (c_ChunkHeight * c_ChunkWidth), // Y
|
||||
// (index / c_ChunkWidth) % c_ChunkWidth // Z
|
||||
// );
|
||||
|
||||
return Vector3i( // 1.1
|
||||
index / (c_ChunkHeight * c_ChunkWidth), // X
|
||||
index % c_ChunkHeight, // Y
|
||||
(index / c_ChunkHeight) % c_ChunkWidth // Z
|
||||
);
|
||||
#if AXIS_ORDER == AXIS_ORDER_XZY
|
||||
return Vector3i( // 1.2
|
||||
index % c_ChunkWidth, // X
|
||||
index / (c_ChunkWidth * c_ChunkWidth), // Y
|
||||
(index / c_ChunkWidth) % c_ChunkWidth // Z
|
||||
);
|
||||
#else if AXIS_ORDER == AXIS_ORDER_YZX
|
||||
return Vector3i( // 1.1
|
||||
index / (c_ChunkHeight * c_ChunkWidth), // X
|
||||
index % c_ChunkHeight, // Y
|
||||
(index / c_ChunkHeight) % c_ChunkWidth // Z
|
||||
);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void MarkDirty(void)
|
||||
|
@ -38,7 +38,11 @@ char cChunk::GetNibble(char* a_Buffer, int x, int y, int z)
|
||||
if( x < c_ChunkWidth && x > -1 && y < c_ChunkHeight && y > -1 && z < c_ChunkWidth && z > -1 )
|
||||
{
|
||||
const int cindex = MakeIndexNoCheck(x, y, z)/2;
|
||||
#if AXIS_ORDER == AXIS_ORDER_XZY
|
||||
if( (x & 1) == 0 )
|
||||
#else if AXIS_ORDER == AXIS_ORDER_YZX
|
||||
if( (y & 1) == 0 )
|
||||
#endif
|
||||
{ // First half byte
|
||||
return (a_Buffer[cindex] & 0x0f);
|
||||
}
|
||||
@ -83,7 +87,11 @@ void cChunk::SetNibble(char* a_Buffer, int x, int y, int z, char light)
|
||||
if( x < c_ChunkWidth && x > -1 && y < c_ChunkHeight && y > -1 && z < c_ChunkWidth && z > -1 )
|
||||
{
|
||||
int cindex = MakeIndexNoCheck(x, y, z)/2;
|
||||
#if AXIS_ORDER == AXIS_ORDER_XZY
|
||||
if( (x & 1) == 0 )
|
||||
#else if AXIS_ORDER == AXIS_ORDER_YZX
|
||||
if( (y & 1) == 0 )
|
||||
#endif
|
||||
{ // First half byte
|
||||
a_Buffer[cindex] &= 0xf0; // Set first half to 0
|
||||
a_Buffer[cindex] |= (light) & 0x0f;
|
||||
|
@ -201,7 +201,7 @@ unsigned int cWorldGenerator::MakeIndex(int x, int y, int z )
|
||||
{
|
||||
ASSERT((x < cChunk::c_ChunkWidth) && (x > -1) && (y < cChunk::c_ChunkHeight) && (y > -1) && (z < cChunk::c_ChunkWidth) && (z > -1));
|
||||
|
||||
return y + (z * cChunk::c_ChunkHeight) + (x * cChunk::c_ChunkHeight * cChunk::c_ChunkWidth);
|
||||
return cChunk::MakeIndexNoCheck( x, y, z );
|
||||
}
|
||||
|
||||
|
||||
@ -433,7 +433,7 @@ void cWorldGenerator::GenerateFoliage(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
|
||||
int xx = x + a_ChunkX * cChunk::c_ChunkWidth;
|
||||
|
||||
int TopY = m_World->GetHeight(xx, zz);
|
||||
int index = MakeIndex(x, TopY - 1, z);
|
||||
int index = cChunk::MakeIndexNoCheck(x, MAX(TopY - 1, 0), z);
|
||||
if (BlockType[index] == BLOCK_GRASS)
|
||||
{
|
||||
float val1 = Noise.CubicNoise2D( xx * 0.1f, zz * 0.1f );
|
||||
|
@ -38,6 +38,8 @@ cPacket_MapChunk::cPacket_MapChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, cha
|
||||
|
||||
unsigned int DataSize = (cChunk::c_ChunkHeight / 16) * (4096 + 2048 + 2048 + 2048);
|
||||
std::auto_ptr<char> AllData(new char[ DataSize ]);
|
||||
|
||||
#if AXIS_ORDER == AXIS_ORDER_YZX
|
||||
memset( AllData.get(), 0, DataSize );
|
||||
|
||||
unsigned int iterator = 0;
|
||||
@ -93,6 +95,13 @@ cPacket_MapChunk::cPacket_MapChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, cha
|
||||
}
|
||||
}
|
||||
}
|
||||
#else if AXIS_ORDER == AXIS_ORDER_XZY
|
||||
for ( int i = 0; i < 16; ++i )
|
||||
{
|
||||
m_BitMap1 |= (1 << i);
|
||||
}
|
||||
memcpy( AllData.get(), a_BlockData, DataSize );
|
||||
#endif
|
||||
|
||||
uLongf CompressedSize = compressBound( DataSize );
|
||||
char * CompressedBlockData = new char[CompressedSize];
|
||||
@ -159,6 +168,7 @@ cPacket_MapChunk::cPacket_MapChunk( const cPacket_MapChunk & a_Copy )
|
||||
|
||||
void cPacket_MapChunk::Serialize(AString & a_Data) const
|
||||
{
|
||||
LOG("Sending chunk [%i, %i]", m_PosX, m_PosZ );
|
||||
AppendByte (a_Data, m_PacketID);
|
||||
|
||||
#if (MINECRAFT_1_2_2 == 1 )
|
||||
|
Loading…
Reference in New Issue
Block a user