Skip to content

Commit

Permalink
Simplify loadTag return type
Browse files Browse the repository at this point in the history
  • Loading branch information
Johni0702 committed Jan 31, 2024
1 parent 340e020 commit c90f1dc
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/main/java/de/johni0702/minecraft/bobby/FakeChunkManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -269,15 +269,15 @@ public boolean shouldBeLoaded(int x, int z) {
return chunkTracker.isInViewDistance(x, z);
}

private CompletableFuture<Optional<Pair<NbtCompound, FakeChunkStorage>>> loadTag(int x, int z) {
private CompletableFuture<Optional<NbtCompound>> loadTag(int x, int z) {
return loadTag(new ChunkPos(x, z), 0);
}

private CompletableFuture<Optional<Pair<NbtCompound, FakeChunkStorage>>> loadTag(ChunkPos chunkPos, int storageIndex) {
private CompletableFuture<Optional<NbtCompound>> loadTag(ChunkPos chunkPos, int storageIndex) {
FakeChunkStorage storage = storages.get(storageIndex);
return storage.loadTag(chunkPos).thenCompose(maybeTag -> {
if (maybeTag.isPresent()) {
return CompletableFuture.completedFuture(Optional.of(Pair.of(maybeTag.get(), storage)));
return CompletableFuture.completedFuture(maybeTag);
}
if (storageIndex + 1 < storages.size()) {
return loadTag(chunkPos, storageIndex + 1);
Expand Down Expand Up @@ -390,7 +390,7 @@ public void run() {
if (cancelled) {
return;
}
Optional<Pair<NbtCompound, FakeChunkStorage>> value;
Optional<NbtCompound> value;
try {
value = loadTag(x, z).get();
} catch (InterruptedException | ExecutionException e) {
Expand All @@ -400,7 +400,7 @@ public void run() {
if (cancelled) {
return;
}
result = value.map(it -> ChunkSerializer.deserialize(new ChunkPos(x, z), it.getLeft(), world));
result = value.map(it -> ChunkSerializer.deserialize(new ChunkPos(x, z), it, world));
}

public void complete() {
Expand Down

0 comments on commit c90f1dc

Please sign in to comment.