Merge branch 'main' into console-tabs
This commit is contained in:
commit
86beea0a61
@ -3,5 +3,5 @@
|
||||
"base:falling_block"
|
||||
],
|
||||
"skeleton-name": "base:block",
|
||||
"hitbox": [0.8, 0.8, 0.8]
|
||||
"hitbox": [0.98, 0.98, 0.98]
|
||||
}
|
||||
|
||||
@ -571,7 +571,7 @@ void Hud::draw(const DrawContext& ctx){
|
||||
|
||||
// Crosshair
|
||||
if (!pause && !inventoryOpen && !player->debug) {
|
||||
DrawContext chctx = ctx.sub();
|
||||
DrawContext chctx = ctx.sub(batch);
|
||||
chctx.setBlendMode(BlendMode::inversion);
|
||||
auto texture = assets->get<Texture>("gui/crosshair");
|
||||
batch->texture(texture);
|
||||
|
||||
@ -45,6 +45,10 @@ void Inventory::move(
|
||||
}
|
||||
}
|
||||
|
||||
void Inventory::resize(uint newSize) {
|
||||
slots.resize(newSize);
|
||||
}
|
||||
|
||||
void Inventory::deserialize(const dv::value& src) {
|
||||
id = src["id"].asInteger(1);
|
||||
auto& slotsarr = src["slots"];
|
||||
|
||||
@ -35,6 +35,8 @@ public:
|
||||
size_t end = -1
|
||||
);
|
||||
|
||||
void resize(uint newSize);
|
||||
|
||||
void deserialize(const dv::value& src) override;
|
||||
|
||||
dv::value serialize() const override;
|
||||
|
||||
@ -39,10 +39,10 @@ void ChunksStorage::remove(int x, int z) {
|
||||
}
|
||||
}
|
||||
|
||||
static void verifyLoadedChunk(ContentIndices* indices, Chunk* chunk) {
|
||||
static void check_voxels(const ContentIndices& indices, Chunk* chunk) {
|
||||
for (size_t i = 0; i < CHUNK_VOL; i++) {
|
||||
blockid_t id = chunk->voxels[i].id;
|
||||
if (indices->blocks.get(id) == nullptr) {
|
||||
if (indices.blocks.get(id) == nullptr) {
|
||||
auto logline = logger.error();
|
||||
logline << "corruped block detected at " << i << " of chunk ";
|
||||
logline << chunk->x << "x" << chunk->z;
|
||||
@ -59,9 +59,26 @@ std::shared_ptr<Chunk> ChunksStorage::create(int x, int z) {
|
||||
auto chunk = std::make_shared<Chunk>(x, z);
|
||||
store(chunk);
|
||||
if (auto data = regions.getVoxels(chunk->x, chunk->z)) {
|
||||
const auto& indices = *level->content->getIndices();
|
||||
|
||||
chunk->decode(data.get());
|
||||
check_voxels(indices, chunk.get());
|
||||
|
||||
auto invs = regions.fetchInventories(chunk->x, chunk->z);
|
||||
auto iterator = invs.begin();
|
||||
while (iterator != invs.end()) {
|
||||
uint index = iterator->first;
|
||||
const auto& def = indices.blocks.require(chunk->voxels[index].id);
|
||||
if (def.inventorySize == 0) {
|
||||
iterator = invs.erase(iterator);
|
||||
continue;
|
||||
}
|
||||
auto& inventory = iterator->second;
|
||||
if (def.inventorySize != inventory->size()) {
|
||||
inventory->resize(def.inventorySize);
|
||||
}
|
||||
++iterator;
|
||||
}
|
||||
chunk->setBlockInventories(std::move(invs));
|
||||
|
||||
auto entitiesData = regions.fetchEntities(chunk->x, chunk->z);
|
||||
@ -74,7 +91,6 @@ std::shared_ptr<Chunk> ChunksStorage::create(int x, int z) {
|
||||
for (auto& entry : chunk->inventories) {
|
||||
level->inventories->store(entry.second);
|
||||
}
|
||||
verifyLoadedChunk(level->content->getIndices(), chunk.get());
|
||||
}
|
||||
if (auto lights = regions.getLights(chunk->x, chunk->z)) {
|
||||
chunk->lightmap.set(lights.get());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user