Skip to content

Commit 39f5c69

Browse files
committed
fix crash when overwriting terrain with a chest
Closes #48
1 parent e81e75a commit 39f5c69

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

src/procedures.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,21 @@ uint8_t makeBlockChange (short x, uint8_t y, short z, uint8_t block) {
434434
}
435435
#endif
436436
if (is_base_block) block_changes[i].block = 0xFF;
437-
else block_changes[i].block = block;
437+
else {
438+
#ifdef ALLOW_CHESTS
439+
// When placing chests, just unallocate the target block and fall
440+
// through to the chest-specific routine below.
441+
if (block == B_chest) {
442+
block_changes[i].block = 0xFF;
443+
if (first_gap > i) first_gap = i;
444+
#ifndef DISK_SYNC_BLOCKS_ON_INTERVAL
445+
writeBlockChangesToDisk(i, i);
446+
#endif
447+
break;
448+
}
449+
#endif
450+
block_changes[i].block = block;
451+
}
438452
#ifndef DISK_SYNC_BLOCKS_ON_INTERVAL
439453
writeBlockChangesToDisk(i, i);
440454
#endif

0 commit comments

Comments
 (0)