Skip to content

Commit e608269

Browse files
committed
Fix client-graph-world npe
1 parent d64f44f commit e608269

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Changes:
2+
3+
* Fixed client-sided graph worlds throwing NPEs when trying to get a graph at an empty block-pos.

modules/syncing-core-xplat/src/main/java/com/kneelawk/graphlib/syncing/impl/graph/simple/SimpleClientGraphWorld.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@
3030
import java.util.stream.LongStream;
3131
import java.util.stream.Stream;
3232

33-
import net.minecraft.core.BlockPos;
34-
import net.minecraft.core.SectionPos;
35-
import net.minecraft.world.level.ChunkPos;
36-
import net.minecraft.world.level.Level;
37-
3833
import org.jetbrains.annotations.NotNull;
3934
import org.jetbrains.annotations.Nullable;
4035

@@ -44,6 +39,11 @@
4439
import it.unimi.dsi.fastutil.longs.LongLinkedOpenHashSet;
4540
import it.unimi.dsi.fastutil.longs.LongSet;
4641

42+
import net.minecraft.core.BlockPos;
43+
import net.minecraft.core.SectionPos;
44+
import net.minecraft.world.level.ChunkPos;
45+
import net.minecraft.world.level.Level;
46+
4747
import com.kneelawk.graphlib.api.graph.BlockGraph;
4848
import com.kneelawk.graphlib.api.graph.GraphUniverse;
4949
import com.kneelawk.graphlib.api.graph.GraphView;
@@ -187,7 +187,10 @@ public boolean linkExistsAt(@NotNull LinkPos pos) {
187187
SimpleBlockGraphChunk chunk = manager.getIfExists(SectionPos.of(pos));
188188
if (chunk == null) return LongStream.empty();
189189

190-
return chunk.getGraphsAt(pos).longStream();
190+
LongSet graphsAt = chunk.getGraphsAt(pos);
191+
if (graphsAt == null) return LongStream.empty();
192+
193+
return graphsAt.longStream();
191194
}
192195

193196
@Override

0 commit comments

Comments
 (0)