BlocksController.hpp tabs -> spaces
This commit is contained in:
@@ -53,8 +53,8 @@ int Clock::getTickId() const {
|
|||||||
|
|
||||||
BlocksController::BlocksController(Level* level, uint padding)
|
BlocksController::BlocksController(Level* level, uint padding)
|
||||||
: level(level),
|
: level(level),
|
||||||
chunks(level->chunks.get()),
|
chunks(level->chunks.get()),
|
||||||
lighting(level->lighting.get()),
|
lighting(level->lighting.get()),
|
||||||
randTickClock(20, 3),
|
randTickClock(20, 3),
|
||||||
blocksTickClock(20, 1),
|
blocksTickClock(20, 1),
|
||||||
worldTickClock(20, 1),
|
worldTickClock(20, 1),
|
||||||
@@ -150,49 +150,49 @@ void BlocksController::randomTick(int tickid, int parts) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t BlocksController::createBlockInventory(int x, int y, int z) {
|
int64_t BlocksController::createBlockInventory(int x, int y, int z) {
|
||||||
auto chunk = chunks->getChunkByVoxel(x, y, z);
|
auto chunk = chunks->getChunkByVoxel(x, y, z);
|
||||||
if (chunk == nullptr) {
|
if (chunk == nullptr) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int lx = x - chunk->x * CHUNK_W;
|
int lx = x - chunk->x * CHUNK_W;
|
||||||
int lz = z - chunk->z * CHUNK_D;
|
int lz = z - chunk->z * CHUNK_D;
|
||||||
auto inv = chunk->getBlockInventory(lx, y, lz);
|
auto inv = chunk->getBlockInventory(lx, y, lz);
|
||||||
if (inv == nullptr) {
|
if (inv == nullptr) {
|
||||||
auto indices = level->content->getIndices();
|
auto indices = level->content->getIndices();
|
||||||
auto def = indices->getBlockDef(chunk->voxels[vox_index(lx, y, lz)].id);
|
auto def = indices->getBlockDef(chunk->voxels[vox_index(lx, y, lz)].id);
|
||||||
int invsize = def->inventorySize;
|
int invsize = def->inventorySize;
|
||||||
if (invsize == 0) {
|
if (invsize == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
inv = level->inventories->create(invsize);
|
inv = level->inventories->create(invsize);
|
||||||
chunk->addBlockInventory(inv, lx, y, lz);
|
chunk->addBlockInventory(inv, lx, y, lz);
|
||||||
}
|
}
|
||||||
return inv->getId();
|
return inv->getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlocksController::bindInventory(int64_t invid, int x, int y, int z) {
|
void BlocksController::bindInventory(int64_t invid, int x, int y, int z) {
|
||||||
auto chunk = chunks->getChunkByVoxel(x, y, z);
|
auto chunk = chunks->getChunkByVoxel(x, y, z);
|
||||||
if (chunk == nullptr) {
|
if (chunk == nullptr) {
|
||||||
throw std::runtime_error("block does not exists");
|
throw std::runtime_error("block does not exists");
|
||||||
}
|
}
|
||||||
if (invid <= 0) {
|
if (invid <= 0) {
|
||||||
throw std::runtime_error("unable to bind virtual inventory");
|
throw std::runtime_error("unable to bind virtual inventory");
|
||||||
}
|
}
|
||||||
int lx = x - chunk->x * CHUNK_W;
|
int lx = x - chunk->x * CHUNK_W;
|
||||||
int lz = z - chunk->z * CHUNK_D;
|
int lz = z - chunk->z * CHUNK_D;
|
||||||
chunk->addBlockInventory(level->inventories->get(invid), lx, y, lz);
|
chunk->addBlockInventory(level->inventories->get(invid), lx, y, lz);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlocksController::unbindInventory(int x, int y, int z) {
|
void BlocksController::unbindInventory(int x, int y, int z) {
|
||||||
auto chunk = chunks->getChunkByVoxel(x, y, z);
|
auto chunk = chunks->getChunkByVoxel(x, y, z);
|
||||||
if (chunk == nullptr) {
|
if (chunk == nullptr) {
|
||||||
throw std::runtime_error("block does not exists");
|
throw std::runtime_error("block does not exists");
|
||||||
}
|
}
|
||||||
int lx = x - chunk->x * CHUNK_W;
|
int lx = x - chunk->x * CHUNK_W;
|
||||||
int lz = z - chunk->z * CHUNK_D;
|
int lz = z - chunk->z * CHUNK_D;
|
||||||
chunk->removeBlockInventory(lx, y, lz);
|
chunk->removeBlockInventory(lx, y, lz);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user