XtreemNodes/include/MapBlock.h
2022-10-28 23:47:09 -04:00

84 lines
1.1 KiB
C++

#ifndef MAPBLOCK_H
#define MAPBLOCK_H
#include "Base.h"
#include <math.h>
class NodeManager
{
public:
int blockX;
int blockZ;
NodeManager()
{
}
virtual ~NodeManager()
{
}
void addNode(int id, int meta, int x, int y, int z)
{
mapBlock[256 * y + z * 16 + x] = id;
}
bool isAir(int x, int y, int z)
{
return getNodeAt(x, y, z) == 0;
}
int getNodeAt(int x, int y, int z)
{
return x < 16 && z < 16 && x >= 0 && z >= 0 ? mapBlock[256 * y + z * 16 + x] : 0;
}
protected:
private:
int mapBlock[65536];
};
class BlockManager
{
public:
NodeManager mapBlocks[8][8]; // 8 x 8 blocks
BlockManager()
{
}
private:
};
class BlockUtilities
{
public:
BlockUtilities()
{
}
static Position2D getBlockFromNodeCoordinates(int x, int z)
{
Position2D pos2d;
pos2d.x = floor(x / 16);
pos2d.z = floor(z / 16);
return pos2d;
}
};
#endif