Merge pull request #590 from MihailRis/speed-up-block-set

Speed up block.set
This commit is contained in:
MihailRis 2025-08-16 13:56:48 +03:00 • committed by GitHub
commit 6ef27faf89
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 18 additions and 14 deletions

View file

@ -101,12 +101,9 @@ static int l_set(lua::State* L) {
if (static_cast<size_t>(id) >= indices->blocks.count()) {
return 0;
}
int cx = floordiv<CHUNK_W>(x);
int cz = floordiv<CHUNK_D>(z);
if (!blocks_agent::get_chunk(*level->chunks, cx, cz)) {
if (!blocks_agent::set(*level->chunks, x, y, z, id, int2blockstate(state))) {
return 0;
}
blocks_agent::set(*level->chunks, x, y, z, id, int2blockstate(state));
auto chunksController = controller->getChunksController();
if (chunksController == nullptr) {