Skip to content
This repository has been archived by the owner on May 27, 2023. It is now read-only.

Commit

Permalink
chore: merge #9
Browse files Browse the repository at this point in the history
Fix preloading incorrect chunks in Schematic#build() implementations
  • Loading branch information
LooFifteen committed May 7, 2022
2 parents c7952bf + 9cbd93b commit 329521c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -24,7 +24,7 @@
<dependency>
<groupId>com.github.Minestom</groupId>
<artifactId>Minestom</artifactId>
<version>d7d6721474</version>
<version>64de8f87c0</version>
<scope>provided</scope>
<exclusions>
<exclusion>
Expand Down
Expand Up @@ -126,11 +126,11 @@ public CompletableFuture<Region> build(Instance instance, Pos position) {

List<CompletableFuture<Void>> futures = new ArrayList<>();
for (Region.Block regionBlock : regionBlocks) {
Pos blockPosition = regionBlock.position();
Pos absoluteBlockPosition = regionBlock.position().add(position);
short stateId = regionBlock.stateId();

Block block = Block.fromStateId(stateId);
if (block != null) futures.add(instance.loadOptionalChunk(blockPosition).thenRun(() -> blockBatch.setBlock(blockPosition.add(position), block)));
if (block != null) futures.add(instance.loadOptionalChunk(absoluteBlockPosition).thenRun(() -> blockBatch.setBlock(absoluteBlockPosition, block)));
}

CompletableFuture.allOf(futures.toArray(new CompletableFuture[]{})).join();
Expand Down
Expand Up @@ -146,11 +146,11 @@ public CompletableFuture<Region> build(Instance instance, Pos position) {

List<CompletableFuture<Void>> futures = new ArrayList<>();
for (Region.Block regionBlock : regionBlocks) {
Pos blockPosition = regionBlock.position();
Pos absoluteBlockPosition = regionBlock.position().add(position);
short stateId = regionBlock.stateId();

Block block = Block.fromStateId(stateId);
if (block != null) futures.add(instance.loadOptionalChunk(blockPosition).thenRun(() -> blockBatch.setBlock(blockPosition.add(position), block)));
if (block != null) futures.add(instance.loadOptionalChunk(absoluteBlockPosition).thenRun(() -> blockBatch.setBlock(absoluteBlockPosition, block)));
}

CompletableFuture.allOf(futures.toArray(new CompletableFuture[]{})).join();
Expand Down

0 comments on commit 329521c

Please sign in to comment.