summary refs log tree commit diff
path: root/src/World/ChunkRegistry.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/World/ChunkRegistry.cpp')
-rw-r--r--src/World/ChunkRegistry.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/World/ChunkRegistry.cpp b/src/World/ChunkRegistry.cpp
index 97896fe..95ae6bd 100644
--- a/src/World/ChunkRegistry.cpp
+++ b/src/World/ChunkRegistry.cpp
@@ -14,11 +14,12 @@ ChunkRegistry::Data& ChunkRegistry::get(ChunkIndex index) {
     return entry->second;
 }
 
-ChunkRegistry::Data& ChunkRegistry::find(Position::BlockWorld pos) {
-    return get(ChunkIndex::from_position(pos));
+ChunkRegistry::Data* ChunkRegistry::find(Position::BlockWorld pos) {
+    if (!Chunk::is_valid_position(pos.to_local())) return nullptr;
+    return &get(ChunkIndex::from_position(pos));
 }
 
-ChunkRegistry::Data& ChunkRegistry::find(Position::World pos) {
+ChunkRegistry::Data* ChunkRegistry::find(Position::World pos) {
     return find(pos.round_to_block());
 }